diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index e82997b979..d8305a75f2 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -577,10 +577,7 @@ public final class FilePath implements Serializable { * Runs Ant glob expansion. */ private static String[] glob(File dir, String includes) { - FileSet fs = new FileSet(); - fs.setDir(dir); - fs.setIncludes(includes); - + FileSet fs = Util.createFileSet(dir,includes); DirectoryScanner ds = fs.getDirectoryScanner(new Project()); String[] files = ds.getIncludedFiles(); return files; @@ -751,11 +748,7 @@ public final class FilePath implements Serializable { CopyImpl copyTask = new CopyImpl(); copyTask.setTodir(new File(target.remote)); - FileSet src = new FileSet(); - src.setDir(base); - src.setIncludes(fileMask); - src.setExcludes(excludes); - copyTask.addFileset(src); + copyTask.addFileset(Util.createFileSet(base,fileMask,excludes)); copyTask.execute(); return copyTask.getNumCopied(); @@ -830,11 +823,7 @@ public final class FilePath implements Serializable { * number of files/directories that are written. */ private Integer writeToTar(File baseDir, String fileMask, String excludes, Pipe pipe) throws IOException { - FileSet fs = new FileSet(); - fs.setDir(baseDir); - fs.setIncludes(fileMask); - if(excludes!=null) - fs.setExcludes(excludes); + FileSet fs = Util.createFileSet(baseDir,fileMask,excludes); byte[] buf = new byte[8192]; @@ -922,9 +911,7 @@ public final class FilePath implements Serializable { String pattern = fileMask; while(true) { - FileSet fs = new FileSet(); - fs.setDir(dir); - fs.setIncludes(pattern); + FileSet fs = Util.createFileSet(dir,pattern); DirectoryScanner ds = fs.getDirectoryScanner(new org.apache.tools.ant.Project()); diff --git a/core/src/main/java/hudson/maven/reporters/SurefireArchiver.java b/core/src/main/java/hudson/maven/reporters/SurefireArchiver.java index aadaa94e4b..a5c67a1222 100644 --- a/core/src/main/java/hudson/maven/reporters/SurefireArchiver.java +++ b/core/src/main/java/hudson/maven/reporters/SurefireArchiver.java @@ -1,5 +1,6 @@ package hudson.maven.reporters; +import hudson.Util; import hudson.maven.MavenBuild; import hudson.maven.MavenBuildProxy; import hudson.maven.MavenBuildProxy.BuildCallable; @@ -16,7 +17,6 @@ import hudson.tasks.test.TestResultProjectAction; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.project.MavenProject; import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.Project; import org.apache.tools.ant.types.FileSet; import org.codehaus.plexus.component.configurator.ComponentConfigurationException; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; @@ -60,12 +60,8 @@ public class SurefireArchiver extends MavenReporter { if(reportsDir.exists()) { // surefire:test just skips itself when the current project is not a java project - FileSet fs = new FileSet(); - Project p = new Project(); - fs.setProject(p); - fs.setDir(reportsDir); - fs.setIncludes("*.xml"); - DirectoryScanner ds = fs.getDirectoryScanner(p); + FileSet fs = Util.createFileSet(reportsDir,"*.xml"); + DirectoryScanner ds = fs.getDirectoryScanner(); if(ds.getIncludedFiles().length==0) // no test in this module diff --git a/core/src/main/java/hudson/model/DirectoryBrowserSupport.java b/core/src/main/java/hudson/model/DirectoryBrowserSupport.java index b89e838716..5db5135889 100644 --- a/core/src/main/java/hudson/model/DirectoryBrowserSupport.java +++ b/core/src/main/java/hudson/model/DirectoryBrowserSupport.java @@ -1,6 +1,7 @@ package hudson.model; import hudson.FilePath; +import hudson.Util; import hudson.FilePath.FileCallable; import hudson.remoting.VirtualChannel; import org.kohsuke.stapler.StaplerRequest; @@ -365,11 +366,8 @@ public final class DirectoryBrowserSupport { } public List> invoke(File baseDir, VirtualChannel channel) throws IOException { - FileSet fs = new FileSet(); - fs.setDir(baseDir); - fs.setIncludes(pattern); - - DirectoryScanner ds = fs.getDirectoryScanner(new org.apache.tools.ant.Project()); + FileSet fs = Util.createFileSet(baseDir,pattern); + DirectoryScanner ds = fs.getDirectoryScanner(); String[] files = ds.getIncludedFiles(); if (files.length > 0) { diff --git a/core/src/main/java/hudson/tasks/Fingerprinter.java b/core/src/main/java/hudson/tasks/Fingerprinter.java index b0966983bb..473fb3f1ef 100644 --- a/core/src/main/java/hudson/tasks/Fingerprinter.java +++ b/core/src/main/java/hudson/tasks/Fingerprinter.java @@ -3,6 +3,7 @@ package hudson.tasks; import hudson.FilePath; import hudson.FilePath.FileCallable; import hudson.Launcher; +import hudson.Util; import hudson.model.AbstractBuild; import hudson.model.AbstractProject; import hudson.model.Action; @@ -135,11 +136,9 @@ public class Fingerprinter extends Publisher implements Serializable { public List invoke(File baseDir, VirtualChannel channel) throws IOException { List results = new ArrayList(); - FileSet src = new FileSet(); - src.setDir(baseDir); - src.setIncludes(targets); + FileSet src = Util.createFileSet(baseDir,targets); - DirectoryScanner ds = src.getDirectoryScanner(new org.apache.tools.ant.Project()); + DirectoryScanner ds = src.getDirectoryScanner(); for( String f : ds.getIncludedFiles() ) { File file = new File(baseDir,f); diff --git a/core/src/main/java/hudson/tasks/junit/JUnitResultArchiver.java b/core/src/main/java/hudson/tasks/junit/JUnitResultArchiver.java index 361b9f60cd..b9b4bf5966 100644 --- a/core/src/main/java/hudson/tasks/junit/JUnitResultArchiver.java +++ b/core/src/main/java/hudson/tasks/junit/JUnitResultArchiver.java @@ -2,6 +2,7 @@ package hudson.tasks.junit; import hudson.FilePath.FileCallable; import hudson.Launcher; +import hudson.Util; import hudson.matrix.MatrixAggregatable; import hudson.matrix.MatrixAggregator; import hudson.matrix.MatrixBuild; @@ -16,7 +17,6 @@ import hudson.tasks.test.TestResultAggregator; import hudson.tasks.test.TestResultProjectAction; import hudson.util.FormFieldValidator; import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.Project; import org.apache.tools.ant.types.FileSet; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; @@ -51,12 +51,8 @@ public class JUnitResultArchiver extends Publisher implements Serializable, Matr TestResult result = build.getProject().getWorkspace().act(new FileCallable() { public TestResult invoke(File ws, VirtualChannel channel) throws IOException { - FileSet fs = new FileSet(); - Project p = new Project(); - fs.setProject(p); - fs.setDir(ws); - fs.setIncludes(testResults); - DirectoryScanner ds = fs.getDirectoryScanner(p); + FileSet fs = Util.createFileSet(ws,testResults); + DirectoryScanner ds = fs.getDirectoryScanner(); String[] files = ds.getIncludedFiles(); if(files.length==0) {