Skip to content

Commit 33ee562

Browse files
author
Igor Fedorenko
committed
Share project "plexus-build-api" into "https://svn.sonatype.org/spice"
git-svn-id: file:///opt/svn/repositories/sonatype.org/spice/trunk/plexus-build-api@846 5751e0cb-dcb7-432f-92e2-260806df54be
1 parent 7876771 commit 33ee562

File tree

4 files changed

+193
-0
lines changed

4 files changed

+193
-0
lines changed

pom.xml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>org.codehaus.plexus</groupId>
5+
<artifactId>plexus-build-api</artifactId>
6+
<version>0.0.1-SNAPSHOT</version>
7+
8+
<dependencies>
9+
<dependency>
10+
<groupId>org.codehaus.plexus</groupId>
11+
<artifactId>plexus-utils</artifactId>
12+
<version>1.5.8-SNAPSHOT</version>
13+
</dependency>
14+
</dependencies>
15+
16+
<build>
17+
<plugins>
18+
<plugin>
19+
<groupId>org.codehaus.plexus</groupId>
20+
<artifactId>plexus-maven-plugin</artifactId>
21+
<version>1.3.4</version>
22+
<executions>
23+
<execution>
24+
<goals>
25+
<goal>descriptor</goal>
26+
</goals>
27+
</execution>
28+
</executions>
29+
</plugin>
30+
</plugins>
31+
</build>
32+
33+
</project>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
package org.codehaus.plexus.build.incremental;
3+
4+
import java.io.File;
5+
import java.io.IOException;
6+
import java.io.OutputStream;
7+
import java.util.List;
8+
9+
import org.codehaus.plexus.util.Scanner;
10+
11+
12+
// TODO should it be BuildWorkspace or something like that?
13+
public interface BuildContext {
14+
15+
// TODO should we add File getBasedir()?
16+
17+
/**
18+
* Returns <code>true</code> if file or folder identified by <code>relpath</code> has
19+
* changed since last build.
20+
*
21+
* @param relpath is path relative to build context basedir
22+
*/
23+
boolean hasDelta(String relpath);
24+
25+
/**
26+
* Returns <code>true</code> if any file or folder identified by <code>relpaths</code> has
27+
* changed since last build.
28+
*
29+
* @param relpaths List<String> are paths relative to build context basedir
30+
*/
31+
boolean hasDelta(List relpaths);
32+
33+
/**
34+
* Indicates that the file content has been modified during the build.
35+
*
36+
* @see #newFileOutputStream(File)
37+
*/
38+
void refresh(File file);
39+
40+
/**
41+
* Returns new OutputStream that writes to the <code>file</code>.
42+
*
43+
* Files changed using OutputStream returned by this method do not need to be
44+
* explicitly refreshed using {@link #refresh(File)}.
45+
*/
46+
OutputStream newFileOutputStream(File file) throws IOException;
47+
48+
/**
49+
* Convenience method, fully equal to newScanner(basedir, false)
50+
*/
51+
Scanner newScanner(File basedir);
52+
53+
/**
54+
* Returned Scanner scans <code>basedir</code> for files and directories
55+
* deleted since last build. Returns empty Scanner if <code>basedir</code>
56+
* is not under this build context basedir.
57+
*/
58+
Scanner newDeleteScanner(File basedir);
59+
60+
/**
61+
* Returned Scanner scans files and folders under <code>basedir</code>.
62+
* If <code>ignoreDelta</code> is <code>false</code>, the scanner will only
63+
* "see" files and folders with content changes since last build. If
64+
* <code>ignoreDelta</code> is <code>true</code>, the scanner will "see" all
65+
* files and folders. Returns empty Scanner if <code>basedir</code>
66+
* is not under this build context basedir.
67+
*/
68+
Scanner newScanner(File basedir, boolean ignoreDelta);
69+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
package org.codehaus.plexus.build.incremental;
3+
4+
import java.io.File;
5+
import java.io.FileOutputStream;
6+
import java.io.IOException;
7+
import java.io.OutputStream;
8+
import java.util.List;
9+
10+
import org.codehaus.plexus.util.DirectoryScanner;
11+
import org.codehaus.plexus.util.Scanner;
12+
13+
/**
14+
* Filesystem based build context implementation which behaves as if all files
15+
* were just created. More specifically,
16+
*
17+
* hasDelta returns <code>true</code> for all paths
18+
* newScanner returns Scanner that scanns all files under provided basedir
19+
* newDeletedScanner always returns empty scanner.
20+
*
21+
* @plexus.component role="org.codehaus.plexus.build.incremental.BuildContext"
22+
* role-hint="default"
23+
*/
24+
public class DefaultBuildContext implements BuildContext {
25+
26+
public boolean hasDelta(String relPath) {
27+
return true;
28+
}
29+
30+
public boolean hasDelta(List relPaths) {
31+
return true;
32+
}
33+
34+
public OutputStream newFileOutputStream(File file) throws IOException {
35+
return new FileOutputStream(file);
36+
}
37+
38+
public Scanner newScanner(File basedir) {
39+
DirectoryScanner ds = new DirectoryScanner();
40+
ds.setBasedir(basedir);
41+
return ds;
42+
}
43+
44+
public void refresh(File file) {
45+
// do nothing
46+
}
47+
48+
public Scanner newDeleteScanner(File basedir) {
49+
return EmptyScanner.INSTANCE;
50+
}
51+
52+
public Scanner newScanner(File basedir, boolean ignoreDelta) {
53+
return newScanner(basedir);
54+
}
55+
56+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
package org.codehaus.plexus.build.incremental;
3+
4+
import org.codehaus.plexus.util.Scanner;
5+
6+
/**
7+
* Scanner implementation never finds any files/directories.
8+
*/
9+
public class EmptyScanner implements Scanner {
10+
11+
public static final Scanner INSTANCE = new EmptyScanner();
12+
13+
private static final String[] EMPTY_STRING_ARRAY = new String[0];
14+
15+
public void addDefaultExcludes() {
16+
}
17+
18+
public String[] getIncludedDirectories() {
19+
return EMPTY_STRING_ARRAY;
20+
}
21+
22+
public String[] getIncludedFiles() {
23+
return EMPTY_STRING_ARRAY;
24+
}
25+
26+
public void scan() {
27+
}
28+
29+
public void setExcludes(String[] excludes) {
30+
}
31+
32+
public void setIncludes(String[] includes) {
33+
}
34+
35+
}

0 commit comments

Comments
 (0)