Skip to content

Commit cc39689

Browse files
committed
Add moveFiles that uses a source glob for figuring out which source files should be copied.
1 parent b66d787 commit cc39689

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

src/main/java/gr/gousiosg/javacg/stat/support/RepoTool.java

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,27 @@ public static Optional<RepoTool> obtainTool(String folderName){
149149
return Optional.empty();
150150
}
151151

152-
private void moveJars() throws IOException{
153-
Path jar = Files.move(
154-
Paths.get(System.getProperty("user.dir") + "/" + this.name + "/target/" + this.name + "-1.0.6-SNAPSHOT.jar"),
155-
Paths.get(System.getProperty("user.dir") + "/artifacts/output/" + this.name + "-1.0.6-SNAPSHOT.jar"),
156-
StandardCopyOption.REPLACE_EXISTING);
157-
Path testJar = Files.move(
158-
Paths.get(System.getProperty("user.dir") + "/" + this.name + "/target/" + this.name + "-1.0.6-SNAPSHOT-tests.jar"),
159-
Paths.get(System.getProperty("user.dir") + "/artifacts/output/" + this.name + "-1.0.6-SNAPSHOT-tests.jar"),
160-
StandardCopyOption.REPLACE_EXISTING);
152+
private void moveJars() throws IOException {
153+
Path sourceDir = Paths.get(System.getProperty("user.dir"), getProjectDir(), "target");
154+
Path targetDir = Paths.get(System.getProperty("user.dir"), "artifacts", "output");
155+
156+
// @todo may want to be able to override this in the yaml file on a project basis...
157+
String depGlob = this.name + "*-with-dependencies.jar";
158+
String testGlob = this.name + "*-tests.jar";
159+
160+
moveFiles(sourceDir, targetDir, depGlob);
161+
moveFiles(sourceDir, targetDir, testGlob);
162+
}
163+
164+
private void moveFiles(Path sourceDir, Path targetDir, String glob) throws IOException {
165+
try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(sourceDir, glob)) {
166+
for (Path source: dirStream) {
167+
Files.move(
168+
source,
169+
targetDir.resolve(source.getFileName()),
170+
StandardCopyOption.REPLACE_EXISTING);
171+
}
172+
}
161173
}
162174

163175
private void moveJacoco(String property, long timeElapsed) throws IOException{

0 commit comments

Comments
 (0)