Skip to content

Commit 3501589

Browse files
committed
Bugfix - Input/exclude paths treated as absolute instead of relative
1 parent 666dc98 commit 3501589

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<modelVersion>4.0.0</modelVersion>
88
<groupId>com.codedx</groupId>
99
<artifactId>codedx-bamboo-plugin</artifactId>
10-
<version>2.0.0</version>
10+
<version>2.0.1-SNAPSHOT</version>
1111

1212
<organization>
1313
<name>Code Dx</name>

src/main/java/com/codedx/plugins/bamboo/utils/Archiver.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static File archive(File workspace, String paths, String excludePaths, St
2323

2424
_logger.info(String.format("archive(...) called. paths: %s || excludePaths: %s || prefix: %s", emptyIfNull(paths), emptyIfNull(excludePaths), emptyIfNull(prefix)));
2525

26-
List<File> files = getFiles(workspace, paths, excludePaths);
26+
List<File> files = getFiles(workspace, workspace, paths, excludePaths);
2727

2828
Path workspaceDir = Paths.get(workspace.getCanonicalPath());
2929
Path tempFile = Files.createTempFile(prefix, ".zip");
@@ -69,20 +69,20 @@ private static String[] splitFileWildcards(final String string) {
6969
return new String[0];
7070
}
7171

72-
private static List<File> getFiles(File workspace, String paths, String excludePaths) throws IOException {
72+
private static List<File> getFiles(File rootPath, File directory, String paths, String excludePaths) throws IOException {
7373
AntPathMatcher matcher = new AntPathMatcher();
7474

7575
List<File> collectedFiles = new ArrayList<>();
76-
File[] files = workspace.listFiles();
76+
File[] files = directory.listFiles();
7777
for (File file : files)
7878
{
79-
if (matches(matcher, paths, excludePaths, file.getCanonicalPath())) {
79+
if (matches(matcher, paths, excludePaths, file.getCanonicalPath().substring(rootPath.getCanonicalPath().length()))) {
8080
collectedFiles.add(file);
8181

8282
// recursively add subdirectories
8383
if(file.isDirectory())
8484
{
85-
collectedFiles.addAll(getFiles(file, paths, excludePaths));
85+
collectedFiles.addAll(getFiles(rootPath, file, paths, excludePaths));
8686
}
8787
}
8888
}

0 commit comments

Comments
 (0)