use the utility method to avoid using whitespace as the pattern separator (#1175)

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@6664 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2008-01-15 05:26:38 +00:00
1 parent 71a88ce3a1
commit f80b714f17
5 files changed
+16 -40

No files matched your search

+4 -17
View File
@@ -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());
@@ -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
@@ -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<List<Path>> 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) {
@@ -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<Record> invoke(File baseDir, VirtualChannel channel) throws IOException {
List<Record> results = new ArrayList<Record>();
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);
@@ -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<TestResult>() {
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) {