@@ -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