|
27 | 27 | import org.codehaus.plexus.util.DirectoryScanner;
|
28 | 28 | import org.codehaus.plexus.util.Scanner;
|
29 | 29 | import org.sonatype.plexus.build.incremental.BuildContext;
|
30 |
| -import org.sonatype.plexus.build.incremental.BuildContext2; |
31 | 30 |
|
32 |
| - |
33 |
| -public class TestIncrementalBuildContext implements BuildContext, BuildContext2 { |
| 31 | +public class TestIncrementalBuildContext implements BuildContext { |
34 | 32 |
|
35 | 33 | private final File basedir;
|
36 | 34 |
|
@@ -117,7 +115,27 @@ public boolean hasDelta(List relpaths) {
|
117 | 115 | return false;
|
118 | 116 | }
|
119 | 117 |
|
120 |
| - public boolean isIncremental() { |
| 118 | + public boolean hasDelta(File file) { |
| 119 | + String relpath = getRelpath(file); |
| 120 | + return relpath == null || hasDelta(relpath); |
| 121 | + } |
| 122 | + |
| 123 | + private String getRelpath(File file) { |
| 124 | + try { |
| 125 | + String path = file.getCanonicalPath(); |
| 126 | + String basepath = basedir.getCanonicalPath(); |
| 127 | + if (path.startsWith(basepath) && !path.equals(basepath)) { |
| 128 | + return path.substring(basepath.length()); |
| 129 | + } else { |
| 130 | + return null; |
| 131 | + } |
| 132 | + } catch (IOException e) { |
| 133 | + // this is a test implementation, we can be little loose here |
| 134 | + throw new IllegalArgumentException(e); |
| 135 | + } |
| 136 | + } |
| 137 | + |
| 138 | +public boolean isIncremental() { |
121 | 139 | return true;
|
122 | 140 | }
|
123 | 141 |
|
@@ -165,4 +183,10 @@ public void addError(File file, int line, int column, String message, Throwable
|
165 | 183 |
|
166 | 184 | public void addWarning(File file, int line, int column, String message, Throwable cause) {
|
167 | 185 | }
|
| 186 | + |
| 187 | + public boolean isUptodate(File target, File source) { |
| 188 | + return target != null && target.exists() && !hasDelta(target) |
| 189 | + && source != null && source.exists() && !hasDelta(source) |
| 190 | + && target.lastModified() > source.lastModified(); |
| 191 | + } |
168 | 192 | }
|
0 commit comments