pax_global_header 0000666 0000000 0000000 00000000064 11525262654 0014522 g ustar 00root root 0000000 0000000 52 comment=883ea674097b2d147b8efd21ed19f3962b14fd2f
sisu-build-api-plexus-build-api-0.0.7/ 0000775 0000000 0000000 00000000000 11525262654 0017537 5 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/pom.xml 0000664 0000000 0000000 00000006204 11525262654 0021056 0 ustar 00root root 0000000 0000000
4.0.0org.sonatype.spicespice-parent15org.sonatype.plexusplexus-build-api0.0.7org.codehaus.plexusplexus-utils1.5.8org.codehaus.plexusplexus-container-default1.0-alpha-9providedsrc/main/resourcestrueorg.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.7scm:svn:https://svn.sonatype.org/spice/tags/plexus-build-api-0.0.7http://svn.sonatype.org/spice/tags/plexus-build-api-0.0.7
sisu-build-api-plexus-build-api-0.0.7/src/ 0000775 0000000 0000000 00000000000 11525262654 0020326 5 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/main/ 0000775 0000000 0000000 00000000000 11525262654 0021252 5 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/main/java/ 0000775 0000000 0000000 00000000000 11525262654 0022173 5 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/main/java/org/ 0000775 0000000 0000000 00000000000 11525262654 0022762 5 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/main/java/org/sonatype/ 0000775 0000000 0000000 00000000000 11525262654 0024624 5 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/main/java/org/sonatype/plexus/ 0000775 0000000 0000000 00000000000 11525262654 0026144 5 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/main/java/org/sonatype/plexus/build/ 0000775 0000000 0000000 00000000000 11525262654 0027243 5 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/main/java/org/sonatype/plexus/build/incremental/ 0000775 0000000 0000000 00000000000 11525262654 0031544 5 ustar 00root root 0000000 0000000 BuildContext.java 0000664 0000000 0000000 00000016112 11525262654 0034735 0 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/main/java/org/sonatype/plexus/build/incremental /*
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 {
public static final int SEVERITY_WARNING = 1;
public static final int SEVERITY_ERROR = 2;
// 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 the file has changed since last build or is not
* under basedir.
*
* @since 0.0.5
*/
boolean hasDelta(File file);
/**
* 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.
*
* Please beware that ignoreDelta=false does NOT work reliably for operations
* that copy resources from source to target locations. Returned Scanner
* only scans changed source resources and it does not consider changed or deleted
* target resources. This results in missing or stale target resources.
* Starting with 0.5.0, recommended way to process resources is to use
* #newScanner(basedir,true) to locate all source resources and {@link #isUptodate(File, File)}
* to optimized processing of uptodate target resources.
*
* Returns empty Scanner if basedir is not under this build context basedir.
*
* @see http://jira.codehaus.org/browse/MSHARED-125
*/
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)
*/
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()
*/
Object getValue(String key);
/**
* @deprecated Use addMessage with severity=SEVERITY_ERROR instead
* @since 0.0.5
*/
void addWarning(File file, int line, int column, String message, Throwable cause);
/**
* @deprecated Use addMessage with severity=SEVERITY_WARNING instead
* @since 0.0.5
*/
void addError(File file, int line, int column, String message, Throwable cause);
/**
* Adds a message to the build context. The message is associated with a file and a location inside that file.
*
* @param file The file or folder with which the message is associated. Should not be null and it is recommended to be
* an absolute path.
* @param line The line number inside the file. Use 1 (not 0) for the first line. Use 0 for unknown/unspecified.
* @param column The column number inside the file. Use 1 (not 0) for the first column. Use 0 for unknown/unspecified.
* @param severity The severity of the message: SEVERITY_WARNING or SEVERITY_ERROR.
* @param cause A Throwable object associated with the message. Can be null.
* @since 0.0.7
*/
void addMessage(File file, int line, int column, String message, int severity, Throwable cause);
/**
* Removes all messages associated with a file or folder during a previous build. It does not affect the messages
* added during the current build.
*
* @since 0.0.7
*/
void removeMessages(File file);
/**
* Returns true, if the target file exists and is uptodate compared to the source file.
*
* More specifically, this method returns true when both target and source files exist,
* do not have changes since last incremental build and the target file was last modified
* later than the source file. Returns false in all other cases.
*
* @since 0.0.5
*/
boolean isUptodate(File target, File source);
}
DefaultBuildContext.java 0000664 0000000 0000000 00000007637 11525262654 0036256 0 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/main/java/org/sonatype/plexus/build/incremental /*
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.logging.AbstractLogEnabled;
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 scans 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 extends AbstractLogEnabled implements BuildContext {
public boolean hasDelta(String relpath) {
return true;
}
public boolean hasDelta(File file) {
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) {
}
private String getMessage(File file, int line, int column, String message) {
StringBuffer sb = new StringBuffer();
sb.append(file.getAbsolutePath()).append(" [").append(line).append(':').append(column).append("]: ");
sb.append(message);
return sb.toString();
}
/**
* @deprecated Use addMessage with severity=SEVERITY_ERROR instead
*/
public void addError(File file, int line, int column, String message, Throwable cause) {
addMessage(file, line, column, message, SEVERITY_ERROR, cause);
}
/**
* @deprecated Use addMessage with severity=SEVERITY_WARNING instead
*/
public void addWarning(File file, int line, int column, String message, Throwable cause) {
addMessage(file, line, column, message, SEVERITY_WARNING, cause);
}
public void addMessage(File file, int line, int column, String message, int severity, Throwable cause) {
switch(severity) {
case BuildContext.SEVERITY_ERROR:
getLogger().error(getMessage(file, line, column, message), cause);
return;
case BuildContext.SEVERITY_WARNING:
getLogger().warn(getMessage(file, line, column, message), cause);
return;
}
throw new IllegalArgumentException("severity=" + severity);
}
public void removeMessages(File file) {
}
public boolean isUptodate(File target, File source) {
return target != null && target.exists() && source != null && source.exists()
&& target.lastModified() > source.lastModified();
}
}
EmptyScanner.java 0000664 0000000 0000000 00000002664 11525262654 0034750 0 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/main/java/org/sonatype/plexus/build/incremental /*
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;
}
}
ThreadBuildContext.java 0000664 0000000 0000000 00000007323 11525262654 0036071 0 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/main/java/org/sonatype/plexus/build/incremental /*
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;
/**
* 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(File file) {
return getContext().hasDelta(file);
}
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);
}
public void addMessage(File file, int line, int column, String message, int severity, Throwable cause) {
getContext().addMessage(file, line, column, message, severity, cause);
}
public void removeMessages(File file) {
getContext().removeMessages(file);
}
/**
* @deprecated Use addMessage with severity=SEVERITY_WARNING instead
*/
public void addWarning(File file, int line, int column, String message, Throwable cause) {
addMessage(file, line, column, message, BuildContext.SEVERITY_WARNING, cause);
}
/**
* @deprecated Use addMessage with severity=SEVERITY_ERROR instead
*/
public void addError(File file, int line, int column, String message, Throwable cause) {
addMessage(file, line, column, message, BuildContext.SEVERITY_ERROR, cause);
}
public boolean isUptodate(File target, File source) {
return getContext().isUptodate(target, source);
}
}
sisu-build-api-plexus-build-api-0.0.7/src/main/resources/ 0000775 0000000 0000000 00000000000 11525262654 0023264 5 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/main/resources/org/ 0000775 0000000 0000000 00000000000 11525262654 0024053 5 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/main/resources/org/sonatype/ 0000775 0000000 0000000 00000000000 11525262654 0025715 5 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/main/resources/org/sonatype/plexus/ 0000775 0000000 0000000 00000000000 11525262654 0027235 5 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/main/resources/org/sonatype/plexus/build/ 0000775 0000000 0000000 00000000000 11525262654 0030334 5 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/main/resources/org/sonatype/plexus/build/incremental/ 0000775 0000000 0000000 00000000000 11525262654 0032635 5 ustar 00root root 0000000 0000000 version.properties 0000664 0000000 0000000 00000000174 11525262654 0036363 0 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/main/resources/org/sonatype/plexus/build/incremental # Used by M2E to determine API version from class path before injecting into plugin realms
api.version = ${project.version}
sisu-build-api-plexus-build-api-0.0.7/src/test/ 0000775 0000000 0000000 00000000000 11525262654 0021305 5 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/test/java/ 0000775 0000000 0000000 00000000000 11525262654 0022226 5 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/test/java/org/ 0000775 0000000 0000000 00000000000 11525262654 0023015 5 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/test/java/org/sonatype/ 0000775 0000000 0000000 00000000000 11525262654 0024657 5 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/test/java/org/sonatype/plexus/ 0000775 0000000 0000000 00000000000 11525262654 0026177 5 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/test/java/org/sonatype/plexus/build/ 0000775 0000000 0000000 00000000000 11525262654 0027276 5 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/test/java/org/sonatype/plexus/build/incremental/ 0000775 0000000 0000000 00000000000 11525262654 0031577 5 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/test/java/org/sonatype/plexus/build/incremental/test/ 0000775 0000000 0000000 00000000000 11525262654 0032556 5 ustar 00root root 0000000 0000000 TestFullBuildContext.java 0000664 0000000 0000000 00000002060 11525262654 0037427 0 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/test/java/org/sonatype/plexus/build/incremental/test /*
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);
}
}
TestIncrementalBuildContext.java 0000664 0000000 0000000 00000012547 11525262654 0041001 0 ustar 00root root 0000000 0000000 sisu-build-api-plexus-build-api-0.0.7/src/test/java/org/sonatype/plexus/build/incremental/test /*
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.ArrayList;
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;
private final List warnings;
private final List errors;
public TestIncrementalBuildContext(File basedir, Set changedFiles, Map context) {
this(basedir, changedFiles, new HashSet(), context);
}
public TestIncrementalBuildContext(File basedir, Set changedFiles, Set deletedFiles, Map context) {
this(basedir, changedFiles, new HashSet(), context, new ArrayList(), new ArrayList());
}
public TestIncrementalBuildContext(File basedir, Set changedFiles, Set deletedFiles, Map context, List warnings, List errors) {
this.basedir = basedir;
this.changedFiles = changedFiles;
this.deletedFiles = deletedFiles;
this.context = context;
this.warnings = warnings;
this.errors = errors;
}
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 hasDelta(File file) {
String relpath = getRelpath(file);
return relpath == null || hasDelta(relpath);
}
private String getRelpath(File file) {
try {
String path = file.getCanonicalPath();
String basepath = basedir.getCanonicalPath();
if (path.startsWith(basepath) && !path.equals(basepath)) {
return path.substring(basepath.length());
} else {
return null;
}
} catch (IOException e) {
// this is a test implementation, we can be little loose here
throw new IllegalArgumentException(e);
}
}
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;
}
public void addError(File file, int line, int column, String message, Throwable cause) {
}
public void addWarning(File file, int line, int column, String message, Throwable cause) {
}
public void addMessage(File file, int line, int column, String message, int severity, Throwable cause) {
}
public void removeMessages(File file) {
}
public boolean isUptodate(File target, File source) {
return target != null && target.exists() && !hasDelta(target)
&& source != null && source.exists() && !hasDelta(source)
&& target.lastModified() > source.lastModified();
}
}