hudson.Util.createFileSet()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(171)

本文整理了Java中hudson.Util.createFileSet()方法的一些代码示例,展示了Util.createFileSet()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.createFileSet()方法的具体详情如下:
包路径:hudson.Util
类名称:Util
方法名:createFileSet

Util.createFileSet介绍

[英]Creates Ant FileSet with the base dir and include pattern.

The difference with this and using FileSet#setIncludes(String)is that this method doesn't treat whitespace as a pattern separator, which makes it impossible to use space in the file path.
[中]使用base dir和include模式创建Ant文件集。
这与使用FileSet#setIncludes(String)的区别在于,该方法不将空白作为模式分隔符,这使得无法使用文件路径中的空间。

代码示例

代码示例来源:origin: jenkinsci/jenkins

@Nonnull
public static FileSet createFileSet(@Nonnull File baseDir, @Nonnull String includes) {
  return createFileSet(baseDir,includes,null);
}

代码示例来源:origin: jenkinsci/jenkins

@Override public Map<String,String> invoke(File basedir, VirtualChannel channel) throws IOException, InterruptedException {
    Map<String,String> r = new HashMap<String,String>();
    FileSet fileSet = Util.createFileSet(basedir, includes, excludes);
    fileSet.setDefaultexcludes(defaultExcludes);
    fileSet.setCaseSensitive(caseSensitive);
    for (String f : fileSet.getDirectoryScanner().getIncludedFiles()) {
      f = f.replace(File.separatorChar, '/');
      r.put(f, f);
    }
    return r;
  }
}

代码示例来源:origin: jenkinsci/jenkins

private void scan(String pattern) {
  LOGGER.fine("Scanning "+pattern+" for hs_err_pid files");
  pattern = pattern.replace("%p","*").replace("%%","%");
  File f = new File(pattern).getAbsoluteFile();
  if (!pattern.contains("*"))
    scanFile(f);
  else {// GLOB
    File commonParent = f;
    while (commonParent!=null && commonParent.getPath().contains("*")) {
      commonParent = commonParent.getParentFile();
    }
    if (commonParent==null) {
      LOGGER.warning("Failed to process "+f);
      return; // huh?
    }
    FileSet fs = Util.createFileSet(commonParent, f.getPath().substring(commonParent.getPath().length()+1), null);
    DirectoryScanner ds = fs.getDirectoryScanner(new Project());
    for (String child : ds.getIncludedFiles()) {
      scanFile(new File(commonParent,child));
    }
  }
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Runs Ant glob expansion.
 *
 * @return
 *      A set of relative file names from the base directory.
 */
@Nonnull
private static String[] glob(File dir, String includes, String excludes, boolean defaultExcludes) throws IOException {
  if(isAbsolute(includes))
    throw new IOException("Expecting Ant GLOB pattern, but saw '"+includes+"'. See http://ant.apache.org/manual/Types/fileset.html for syntax");
  FileSet fs = Util.createFileSet(dir,includes,excludes);
  fs.setDefaultexcludes(defaultExcludes);
  DirectoryScanner ds;
  try {
    ds = fs.getDirectoryScanner(new Project());
  } catch (BuildException x) {
    throw new IOException(x.getMessage());
  }
  String[] files = ds.getIncludedFiles();
  return files;
}

代码示例来源:origin: jenkinsci/jenkins

@Override
public List<Record> invoke(File baseDir, VirtualChannel channel) throws IOException {
  List<Record> results = new ArrayList<Record>();
  FileSet src = Util.createFileSet(baseDir,targets);
  DirectoryScanner ds = src.getDirectoryScanner();
  for( String f : ds.getIncludedFiles() ) {
    File file = new File(baseDir,f);
    // consider the file to be produced by this build only if the timestamp
    // is newer than when the build has started.
    // 2000ms is an error margin since since VFAT only retains timestamp at 2sec precision
    boolean produced = buildTimestamp <= file.lastModified()+2000;
    try {
      results.add(new Record(produced,f,file.getName(),new FilePath(file).digest()));
    } catch (IOException e) {
      throw new IOException(Messages.Fingerprinter_DigestFailed(file),e);
    } catch (InterruptedException e) {
      throw new IOException(Messages.Fingerprinter_Aborted(),e);
    }
  }
  return results;
}

代码示例来源:origin: jenkinsci/jenkins

public void scan(File dir, FileVisitor visitor) throws IOException {
  if(fixEmpty(includes)==null && excludes==null) {
    // optimization
    new Full().scan(dir,visitor);
    return;
  }
  FileSet fs = Util.createFileSet(dir,includes,excludes);
  fs.setDefaultexcludes(useDefaultExcludes);
  if(dir.exists()) {
    DirectoryScanner ds = fs.getDirectoryScanner(new org.apache.tools.ant.Project());
    for( String f : ds.getIncludedFiles()) {
      File file = new File(dir, f);
      scanSingle(file, f, visitor);
    }
  }
}

代码示例来源:origin: jenkinsci/jenkins

FileSet fs = Util.createFileSet(reading(dir),"**/"+fileMask);
fs.setCaseSensitive(caseSensitive);
DirectoryScanner ds = fs.getDirectoryScanner(new Project());

代码示例来源:origin: jenkinsci/maven-plugin

/**
 * Returns the appropriate FileSet for the selected baseDir
 * @param baseDir
 * @return
 */
private FileSet getFileSet(File baseDir) {
  return Util.createFileSet(baseDir, "*.xml","testng-results.xml,testng-failed.xml");
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

public static FileSet createFileSet(File baseDir, String includes) {
  return createFileSet(baseDir, includes, null);
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

public static FileSet createFileSet(File baseDir, String includes) {
  return createFileSet(baseDir, includes, null);
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

@Nonnull
public static FileSet createFileSet(@Nonnull File baseDir, @Nonnull String includes) {
  return createFileSet(baseDir,includes,null);
}

代码示例来源:origin: jenkinsci/parallel-test-executor-plugin

@Override
  public String[] call() throws Throwable {
    return Util.createFileSet(new File(baseDir), StringUtils.join(testFilesExpression,",")).getDirectoryScanner().getIncludedFiles();
  }
});

代码示例来源:origin: jenkinsci/workflow-basic-steps-plugin

@Override public Map<String,String> invoke(File basedir, VirtualChannel channel) throws IOException, InterruptedException {
    Map<String,String> r = new HashMap<>();
    for (String f : Util.createFileSet(basedir, includes, excludes).getDirectoryScanner().getIncludedFiles()) {
      f = f.replace(File.separatorChar, '/');
      r.put(f, f);
    }
    return r;
  }
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

@Override public Map<String,String> invoke(File basedir, VirtualChannel channel) throws IOException, InterruptedException {
    Map<String,String> r = new HashMap<String,String>();
    FileSet fileSet = Util.createFileSet(basedir, includes, excludes);
    fileSet.setDefaultexcludes(defaultExcludes);
    fileSet.setCaseSensitive(caseSensitive);
    for (String f : fileSet.getDirectoryScanner().getIncludedFiles()) {
      f = f.replace(File.separatorChar, '/');
      r.put(f, f);
    }
    return r;
  }
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
 * Runs Ant glob expansion.
 *
 * @return
 *      A set of relative file names from the base directory.
 */
private static String[] glob(File dir, String includes) throws IOException {
  if(isAbsolute(includes))
    throw new IOException("Expecting Ant GLOB pattern, but saw '"+includes+"'. See http://ant.apache.org/manual/Types/fileset.html for syntax");
  FileSet fs = Util.createFileSet(dir,includes);
  DirectoryScanner ds = fs.getDirectoryScanner(new Project());
  String[] files = ds.getIncludedFiles();
  return files;
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

/**
 * Runs Ant glob expansion.
 *
 * @return
 *      A set of relative file names from the base directory.
 */
private static String[] glob(File dir, String includes) throws IOException {
  if(isAbsolute(includes))
    throw new IOException("Expecting Ant GLOB pattern, but saw '"+includes+"'. See http://ant.apache.org/manual/Types/fileset.html for syntax");
  FileSet fs = Util.createFileSet(dir,includes);
  DirectoryScanner ds = fs.getDirectoryScanner(new Project());
  String[] files = ds.getIncludedFiles();
  return files;
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

private boolean hasMatch(File dir, String pattern) {
  FileSet fs = Util.createFileSet(dir,pattern);
  DirectoryScanner ds = fs.getDirectoryScanner(new Project());
  return ds.getIncludedFilesCount()!=0 || ds.getIncludedDirsCount()!=0;
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

private boolean hasMatch(File dir, String pattern) {
  FileSet fs = Util.createFileSet(dir, pattern);
  DirectoryScanner ds = fs.getDirectoryScanner(new Project());
  return ds.getIncludedFilesCount() != 0 || ds.getIncludedDirsCount() != 0;
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

private boolean hasMatch(File dir, String pattern) {
  FileSet fs = Util.createFileSet(dir,pattern);
  DirectoryScanner ds = fs.getDirectoryScanner(new Project());
  return ds.getIncludedFilesCount()!=0 || ds.getIncludedDirsCount()!=0;
}

代码示例来源:origin: hudson/hudson-2.x

private boolean hasMatch(File dir, String pattern) {
  FileSet fs = Util.createFileSet(dir,pattern);
  DirectoryScanner ds = fs.getDirectoryScanner(new Project());
  return ds.getIncludedFilesCount()!=0 || ds.getIncludedDirsCount()!=0;
}

相关文章

微信公众号

最新文章

更多