plexus-build-api-0.0.4/ 0000755 0001750 0001750 00000000000 11225167603 014640 5 ustar twerner twerner plexus-build-api-0.0.4/src/ 0000755 0001750 0001750 00000000000 11225167603 015427 5 ustar twerner twerner plexus-build-api-0.0.4/src/test/ 0000755 0001750 0001750 00000000000 11225167603 016406 5 ustar twerner twerner plexus-build-api-0.0.4/src/test/java/ 0000755 0001750 0001750 00000000000 11225167603 017327 5 ustar twerner twerner plexus-build-api-0.0.4/src/test/java/org/ 0000755 0001750 0001750 00000000000 11225167603 020116 5 ustar twerner twerner plexus-build-api-0.0.4/src/test/java/org/sonatype/ 0000755 0001750 0001750 00000000000 11225167603 021760 5 ustar twerner twerner plexus-build-api-0.0.4/src/test/java/org/sonatype/plexus/ 0000755 0001750 0001750 00000000000 11225167603 023300 5 ustar twerner twerner plexus-build-api-0.0.4/src/test/java/org/sonatype/plexus/build/ 0000755 0001750 0001750 00000000000 11225167603 024377 5 ustar twerner twerner plexus-build-api-0.0.4/src/test/java/org/sonatype/plexus/build/incremental/ 0000755 0001750 0001750 00000000000 11225167603 026700 5 ustar twerner twerner plexus-build-api-0.0.4/src/test/java/org/sonatype/plexus/build/incremental/test/ 0000755 0001750 0001750 00000000000 11225167603 027657 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000161 00000000000 011563 L ustar root root plexus-build-api-0.0.4/src/test/java/org/sonatype/plexus/build/incremental/test/TestIncrementalBuildContext.java plexus-build-api-0.0.4/src/test/java/org/sonatype/plexus/build/incremental/test/TestIncrementalBuild0000644 0001750 0001750 00000007500 11145354227 033666 0 ustar twerner twerner /*
Copyright (c) 2008 Sonatype, Inc. All rights reserved.
This program is licensed to you under the Apache License Version 2.0,
and you may not use this file except in compliance with the Apache License Version 2.0.
You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
Unless required by applicable law or agreed to in writing,
software distributed under the Apache License Version 2.0 is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
*/
package org.sonatype.plexus.build.incremental.test;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.Scanner;
import org.sonatype.plexus.build.incremental.BuildContext;
public class TestIncrementalBuildContext implements BuildContext {
private final File basedir;
private final HashSet refresh = new HashSet();
private static final class TestScanner implements Scanner {
private final File basedir;
private final Set files;
private TestScanner(File basedir, Set files) {
this.basedir = basedir;
this.files = files;
}
public void addDefaultExcludes() {
}
public String[] getIncludedDirectories() {
return new String[0];
}
public String[] getIncludedFiles() {
return (String[]) files.toArray(new String[files.size()]);
}
public void scan() {
}
public void setExcludes(String[] excludes) {
}
public void setIncludes(String[] includes) {
}
public File getBasedir() {
return basedir;
}
}
private final Set changedFiles;
private final Set deletedFiles;
private final Map context;
public TestIncrementalBuildContext(File basedir, Set files, Map context) {
this(basedir, files, new HashSet(), context);
}
public TestIncrementalBuildContext(File basedir, Set changedFiles, Set deletedFiles, Map context) {
this.basedir = basedir;
this.changedFiles = changedFiles;
this.deletedFiles = deletedFiles;
this.context = context;
}
public boolean hasDelta(String relpath) {
String basepath = basedir.getAbsolutePath();
if (relpath.startsWith(basepath)) {
relpath = relpath.substring(basepath.length() + 1);
}
return changedFiles.contains(relpath) || deletedFiles.contains(relpath);
}
public boolean hasDelta(List relpaths) {
for(Iterator i = relpaths.iterator(); i.hasNext();) {
String relpath = (String) i.next();
if(hasDelta(relpath)) {
return true;
}
}
return false;
}
public boolean isIncremental() {
return true;
}
public Scanner newDeleteScanner(File basedir) {
return new TestScanner(basedir, deletedFiles);
}
public OutputStream newFileOutputStream(File file) throws IOException {
refresh(file);
return new FileOutputStream(file);
}
public Scanner newScanner(final File basedir) {
return new TestScanner(basedir, changedFiles);
}
public Scanner newScanner(File basedir, boolean ignoreDelta) {
if(ignoreDelta) {
DirectoryScanner directoryScanner = new DirectoryScanner();
directoryScanner.setBasedir(basedir);
return directoryScanner;
}
return newScanner(basedir);
}
public void refresh(File file) {
refresh.add(file.getAbsoluteFile());
}
public Object getValue(String key) {
return context.get(key);
}
public void setValue(String key, Object value) {
context.put(key, value);
}
public Set getRefreshFiles() {
return refresh;
}
}
././@LongLink 0000000 0000000 0000000 00000000152 00000000000 011563 L ustar root root plexus-build-api-0.0.4/src/test/java/org/sonatype/plexus/build/incremental/test/TestFullBuildContext.java plexus-build-api-0.0.4/src/test/java/org/sonatype/plexus/build/incremental/test/TestFullBuildContext0000644 0001750 0001750 00000002060 11145353344 033667 0 ustar twerner twerner /*
Copyright (c) 2008 Sonatype, Inc. All rights reserved.
This program is licensed to you under the Apache License Version 2.0,
and you may not use this file except in compliance with the Apache License Version 2.0.
You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
Unless required by applicable law or agreed to in writing,
software distributed under the Apache License Version 2.0 is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
*/
package org.sonatype.plexus.build.incremental.test;
import java.util.Map;
import org.sonatype.plexus.build.incremental.DefaultBuildContext;
public class TestFullBuildContext extends DefaultBuildContext {
private final Map context;
public TestFullBuildContext(Map context) {
this.context = context;
}
public void setValue(String key, Object value) {
context.put(key, value);
}
}
plexus-build-api-0.0.4/src/main/ 0000755 0001750 0001750 00000000000 11225167603 016353 5 ustar twerner twerner plexus-build-api-0.0.4/src/main/java/ 0000755 0001750 0001750 00000000000 11225167603 017274 5 ustar twerner twerner plexus-build-api-0.0.4/src/main/java/org/ 0000755 0001750 0001750 00000000000 11225167603 020063 5 ustar twerner twerner plexus-build-api-0.0.4/src/main/java/org/sonatype/ 0000755 0001750 0001750 00000000000 11225167603 021725 5 ustar twerner twerner plexus-build-api-0.0.4/src/main/java/org/sonatype/plexus/ 0000755 0001750 0001750 00000000000 11225167603 023245 5 ustar twerner twerner plexus-build-api-0.0.4/src/main/java/org/sonatype/plexus/build/ 0000755 0001750 0001750 00000000000 11225167603 024344 5 ustar twerner twerner plexus-build-api-0.0.4/src/main/java/org/sonatype/plexus/build/incremental/ 0000755 0001750 0001750 00000000000 11225167603 026645 5 ustar twerner twerner plexus-build-api-0.0.4/src/main/java/org/sonatype/plexus/build/incremental/BuildContext.java 0000644 0001750 0001750 00000010712 11145307432 032112 0 ustar twerner twerner /*
Copyright (c) 2008 Sonatype, Inc. All rights reserved.
This program is licensed to you under the Apache License Version 2.0,
and you may not use this file except in compliance with the Apache License Version 2.0.
You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
Unless required by applicable law or agreed to in writing,
software distributed under the Apache License Version 2.0 is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
*/
package org.sonatype.plexus.build.incremental;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import org.codehaus.plexus.util.Scanner;
// TODO should it be BuildWorkspace or something like that?
public interface BuildContext {
// TODO should we add File getBasedir()?
/**
* Returns true if file or folder identified by relpath has
* changed since last build.
*
* @param relpath is path relative to build context basedir
*/
boolean hasDelta(String relpath);
/**
* Returns true if any file or folder identified by relpaths has
* changed since last build.
*
* @param relpaths List are paths relative to build context basedir
*/
boolean hasDelta(List relpaths);
/**
* Indicates that the file or folder content has been modified during the build.
*
* @see #newFileOutputStream(File)
*/
void refresh(File file);
/**
* Returns new OutputStream that writes to the file.
*
* Files changed using OutputStream returned by this method do not need to be
* explicitly refreshed using {@link #refresh(File)}.
*
* As an optional optimisation, OutputStreams created by incremental build
* context will attempt to avoid writing to the file if file content
* has not changed.
*/
OutputStream newFileOutputStream(File file) throws IOException;
/**
* Convenience method, fully equal to newScanner(basedir, false)
*/
Scanner newScanner(File basedir);
/**
* Returned Scanner scans basedir for files and directories
* deleted since last build. Returns empty Scanner if basedir
* is not under this build context basedir.
*/
Scanner newDeleteScanner(File basedir);
/**
* Returned Scanner scans files and folders under basedir.
*
* If this is an incremental build context and ignoreDelta
* is false, the scanner will only "see" files and folders with
* content changes since last build.
*
* If ignoreDelta is true, the scanner will "see" all
* files and folders.
*
* Returns empty Scanner if basedir is not under this build context basedir.
*/
Scanner newScanner(File basedir, boolean ignoreDelta);
/**
* Returns true if this build context is incremental.
*
* Scanners created by {@link #newScanner(File)} of an incremental build context
* will ignore files and folders that were not changed since last build.
* Additionally, {@link #newDeleteScanner(File)} will scan files and directories
* deleted since last build.
*/
boolean isIncremental();
/**
* Associate specified key with specified value
* in the build context.
*
* Primary (and the only) purpose of this method is to allow preservation of
* state needed for proper incremental behaviour between consecutive executions
* of the same mojo needed to.
*
* For example, maven-plugin-plugin:descriptor mojo
* can store collection of extracted MojoDescritpor during first invocation. Then
* on each consecutive execution maven-plugin-plugin:descriptor will only need
* to extract MojoDescriptors for changed files.
*
* @see #getValue(String)
*/
public void setValue(String key, Object value);
/**
* Returns value associated with key during previous mojo execution.
*
* This method always returns null for non-incremental builds
* (i.e., {@link #isIncremental()} returns false) and mojos are
* expected to fall back to full, non-incremental behaviour.
*
* @see #setValue(String, Object)
* @see #isIncremental()
*/
public Object getValue(String key);
}
plexus-build-api-0.0.4/src/main/java/org/sonatype/plexus/build/incremental/DefaultBuildContext.java 0000644 0001750 0001750 00000004473 11145315247 033431 0 ustar twerner twerner /*
Copyright (c) 2008 Sonatype, Inc. All rights reserved.
This program is licensed to you under the Apache License Version 2.0,
and you may not use this file except in compliance with the Apache License Version 2.0.
You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
Unless required by applicable law or agreed to in writing,
software distributed under the Apache License Version 2.0 is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
*/
package org.sonatype.plexus.build.incremental;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.Scanner;
/**
* Filesystem based non-incremental build context implementation which behaves as if all files
* were just created. More specifically,
*
* hasDelta returns true for all paths
* newScanner returns Scanner that scanns all files under provided basedir
* newDeletedScanner always returns empty scanner.
* isIncremental returns falsenull
*
* @plexus.component role="org.sonatype.plexus.build.incremental.BuildContext"
* role-hint="default"
*/
public class DefaultBuildContext implements BuildContext {
public boolean hasDelta(String relpath) {
return true;
}
public boolean hasDelta(List relpaths) {
return true;
}
public OutputStream newFileOutputStream(File file) throws IOException {
return new FileOutputStream(file);
}
public Scanner newScanner(File basedir) {
DirectoryScanner ds = new DirectoryScanner();
ds.setBasedir(basedir);
return ds;
}
public void refresh(File file) {
// do nothing
}
public Scanner newDeleteScanner(File basedir) {
return new EmptyScanner(basedir);
}
public Scanner newScanner(File basedir, boolean ignoreDelta) {
return newScanner(basedir);
}
public boolean isIncremental() {
return false;
}
public Object getValue(String key) {
return null;
}
public void setValue(String key, Object value) {
}
}
plexus-build-api-0.0.4/src/main/java/org/sonatype/plexus/build/incremental/ThreadBuildContext.java 0000644 0001750 0001750 00000005561 11145353344 033253 0 ustar twerner twerner /*
Copyright (c) 2008 Sonatype, Inc. All rights reserved.
This program is licensed to you under the Apache License Version 2.0,
and you may not use this file except in compliance with the Apache License Version 2.0.
You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
Unless required by applicable law or agreed to in writing,
software distributed under the Apache License Version 2.0 is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
*/
package org.sonatype.plexus.build.incremental;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import org.sonatype.plexus.build.incremental.BuildContext;
import org.sonatype.plexus.build.incremental.DefaultBuildContext;
import org.codehaus.plexus.util.Scanner;
/**
* BuildContext implementation that delegates actual work to thread-local
* build context set using {@link #setThreadBuildContext(BuildContext)}.
* {@link DefaultBuildContext} is used if no thread local build context was set.
*
* Note that plexus component metadata is not generated for this implementation.
* Apparently, older version of plexus used by maven-filtering and likely
* other projects, does not honour "default" role-hint.
*/
public class ThreadBuildContext implements BuildContext {
private static final ThreadLocal threadContext = new ThreadLocal();
private static final DefaultBuildContext defaultContext = new DefaultBuildContext();
public static BuildContext getContext() {
BuildContext context = (BuildContext) threadContext.get();
if(context == null) {
context = defaultContext;
}
return context;
}
public static void setThreadBuildContext(BuildContext context) {
threadContext.set(context);
}
public boolean hasDelta(String relPath) {
return getContext().hasDelta(relPath);
}
public boolean hasDelta(List relPaths) {
return getContext().hasDelta(relPaths);
}
public Scanner newDeleteScanner(File basedir) {
return getContext().newDeleteScanner(basedir);
}
public OutputStream newFileOutputStream(File file) throws IOException {
return getContext().newFileOutputStream(file);
}
public Scanner newScanner(File basedir) {
return getContext().newScanner(basedir);
}
public Scanner newScanner(File basedir, boolean ignoreDelta) {
return getContext().newScanner(basedir, ignoreDelta);
}
public void refresh(File file) {
getContext().refresh(file);
}
public Object getValue(String key) {
return getContext().getValue(key);
}
public boolean isIncremental() {
return getContext().isIncremental();
}
public void setValue(String key, Object value) {
getContext().setValue(key, value);
}
}
plexus-build-api-0.0.4/src/main/java/org/sonatype/plexus/build/incremental/EmptyScanner.java 0000644 0001750 0001750 00000002664 11145307432 032125 0 ustar twerner twerner /*
Copyright (c) 2008 Sonatype, Inc. All rights reserved.
This program is licensed to you under the Apache License Version 2.0,
and you may not use this file except in compliance with the Apache License Version 2.0.
You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
Unless required by applicable law or agreed to in writing,
software distributed under the Apache License Version 2.0 is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
*/
package org.sonatype.plexus.build.incremental;
import java.io.File;
import org.codehaus.plexus.util.Scanner;
/**
* Scanner implementation never finds any files/directories.
*/
public class EmptyScanner implements Scanner {
private static final String[] EMPTY_STRING_ARRAY = new String[0];
private final File basedir;
public EmptyScanner(File basedir) {
this.basedir = basedir;
}
public void addDefaultExcludes() {
}
public String[] getIncludedDirectories() {
return EMPTY_STRING_ARRAY;
}
public String[] getIncludedFiles() {
return EMPTY_STRING_ARRAY;
}
public void scan() {
}
public void setExcludes(String[] excludes) {
}
public void setIncludes(String[] includes) {
}
public File getBasedir() {
return basedir;
}
}
plexus-build-api-0.0.4/pom.xml 0000644 0001750 0001750 00000005457 11145364612 016170 0 ustar twerner twerner
4.0.0org.sonatype.spicespice-parent10org.sonatype.plexusplexus-build-api0.0.4org.codehaus.plexusplexus-utils1.5.8org.codehaus.plexusplexus-maven-plugin1.3.4descriptororg.apache.maven.pluginsmaven-compiler-plugin1.41.4org.apache.maven.pluginsmaven-surefire-plugin2.4.2trueorg.apache.maven.pluginsmaven-jar-plugintest-jarscm:svn:http://svn.sonatype.org/spice/tags/plexus-build-api-0.0.4scm:svn:https://svn.sonatype.org/spice/tags/plexus-build-api-0.0.4http://svn.sonatype.org/spice/tags/plexus-build-api-0.0.4