plexus-build-api-0.0.4/0000755000175000017500000000000011225167603014640 5ustar twernertwernerplexus-build-api-0.0.4/src/0000755000175000017500000000000011225167603015427 5ustar twernertwernerplexus-build-api-0.0.4/src/test/0000755000175000017500000000000011225167603016406 5ustar twernertwernerplexus-build-api-0.0.4/src/test/java/0000755000175000017500000000000011225167603017327 5ustar twernertwernerplexus-build-api-0.0.4/src/test/java/org/0000755000175000017500000000000011225167603020116 5ustar twernertwernerplexus-build-api-0.0.4/src/test/java/org/sonatype/0000755000175000017500000000000011225167603021760 5ustar twernertwernerplexus-build-api-0.0.4/src/test/java/org/sonatype/plexus/0000755000175000017500000000000011225167603023300 5ustar twernertwernerplexus-build-api-0.0.4/src/test/java/org/sonatype/plexus/build/0000755000175000017500000000000011225167603024377 5ustar twernertwernerplexus-build-api-0.0.4/src/test/java/org/sonatype/plexus/build/incremental/0000755000175000017500000000000011225167603026700 5ustar twernertwernerplexus-build-api-0.0.4/src/test/java/org/sonatype/plexus/build/incremental/test/0000755000175000017500000000000011225167603027657 5ustar twernertwerner././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootplexus-build-api-0.0.4/src/test/java/org/sonatype/plexus/build/incremental/test/TestIncrementalBuildContext.javaplexus-build-api-0.0.4/src/test/java/org/sonatype/plexus/build/incremental/test/TestIncrementalBuild0000644000175000017500000000750011145354227033666 0ustar twernertwerner/* 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; } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootplexus-build-api-0.0.4/src/test/java/org/sonatype/plexus/build/incremental/test/TestFullBuildContext.javaplexus-build-api-0.0.4/src/test/java/org/sonatype/plexus/build/incremental/test/TestFullBuildContext0000644000175000017500000000206011145353344033667 0ustar twernertwerner/* 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/0000755000175000017500000000000011225167603016353 5ustar twernertwernerplexus-build-api-0.0.4/src/main/java/0000755000175000017500000000000011225167603017274 5ustar twernertwernerplexus-build-api-0.0.4/src/main/java/org/0000755000175000017500000000000011225167603020063 5ustar twernertwernerplexus-build-api-0.0.4/src/main/java/org/sonatype/0000755000175000017500000000000011225167603021725 5ustar twernertwernerplexus-build-api-0.0.4/src/main/java/org/sonatype/plexus/0000755000175000017500000000000011225167603023245 5ustar twernertwernerplexus-build-api-0.0.4/src/main/java/org/sonatype/plexus/build/0000755000175000017500000000000011225167603024344 5ustar twernertwernerplexus-build-api-0.0.4/src/main/java/org/sonatype/plexus/build/incremental/0000755000175000017500000000000011225167603026645 5ustar twernertwernerplexus-build-api-0.0.4/src/main/java/org/sonatype/plexus/build/incremental/BuildContext.java0000644000175000017500000001071211145307432032112 0ustar twernertwerner/* 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.java0000644000175000017500000000447311145315247033431 0ustar twernertwerner/* 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.java0000644000175000017500000000556111145353344033253 0ustar twernertwerner/* 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.java0000644000175000017500000000266411145307432032125 0ustar twernertwerner/* 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.xml0000644000175000017500000000545711145364612016170 0ustar twernertwerner 4.0.0 org.sonatype.spice spice-parent 10 org.sonatype.plexus plexus-build-api 0.0.4 org.codehaus.plexus plexus-utils 1.5.8 org.codehaus.plexus plexus-maven-plugin 1.3.4 descriptor org.apache.maven.plugins maven-compiler-plugin 1.4 1.4 org.apache.maven.plugins maven-surefire-plugin 2.4.2 true org.apache.maven.plugins maven-jar-plugin test-jar scm:svn:http://svn.sonatype.org/spice/tags/plexus-build-api-0.0.4 scm:svn:https://svn.sonatype.org/spice/tags/plexus-build-api-0.0.4 http://svn.sonatype.org/spice/tags/plexus-build-api-0.0.4