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

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

本文整理了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

  1. @Nonnull
  2. public static FileSet createFileSet(@Nonnull File baseDir, @Nonnull String includes) {
  3. return createFileSet(baseDir,includes,null);
  4. }

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

  1. @Override public Map<String,String> invoke(File basedir, VirtualChannel channel) throws IOException, InterruptedException {
  2. Map<String,String> r = new HashMap<String,String>();
  3. FileSet fileSet = Util.createFileSet(basedir, includes, excludes);
  4. fileSet.setDefaultexcludes(defaultExcludes);
  5. fileSet.setCaseSensitive(caseSensitive);
  6. for (String f : fileSet.getDirectoryScanner().getIncludedFiles()) {
  7. f = f.replace(File.separatorChar, '/');
  8. r.put(f, f);
  9. }
  10. return r;
  11. }
  12. }

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

  1. private void scan(String pattern) {
  2. LOGGER.fine("Scanning "+pattern+" for hs_err_pid files");
  3. pattern = pattern.replace("%p","*").replace("%%","%");
  4. File f = new File(pattern).getAbsoluteFile();
  5. if (!pattern.contains("*"))
  6. scanFile(f);
  7. else {// GLOB
  8. File commonParent = f;
  9. while (commonParent!=null && commonParent.getPath().contains("*")) {
  10. commonParent = commonParent.getParentFile();
  11. }
  12. if (commonParent==null) {
  13. LOGGER.warning("Failed to process "+f);
  14. return; // huh?
  15. }
  16. FileSet fs = Util.createFileSet(commonParent, f.getPath().substring(commonParent.getPath().length()+1), null);
  17. DirectoryScanner ds = fs.getDirectoryScanner(new Project());
  18. for (String child : ds.getIncludedFiles()) {
  19. scanFile(new File(commonParent,child));
  20. }
  21. }
  22. }

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

  1. /**
  2. * Runs Ant glob expansion.
  3. *
  4. * @return
  5. * A set of relative file names from the base directory.
  6. */
  7. @Nonnull
  8. private static String[] glob(File dir, String includes, String excludes, boolean defaultExcludes) throws IOException {
  9. if(isAbsolute(includes))
  10. throw new IOException("Expecting Ant GLOB pattern, but saw '"+includes+"'. See http://ant.apache.org/manual/Types/fileset.html for syntax");
  11. FileSet fs = Util.createFileSet(dir,includes,excludes);
  12. fs.setDefaultexcludes(defaultExcludes);
  13. DirectoryScanner ds;
  14. try {
  15. ds = fs.getDirectoryScanner(new Project());
  16. } catch (BuildException x) {
  17. throw new IOException(x.getMessage());
  18. }
  19. String[] files = ds.getIncludedFiles();
  20. return files;
  21. }

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

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

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

  1. public void scan(File dir, FileVisitor visitor) throws IOException {
  2. if(fixEmpty(includes)==null && excludes==null) {
  3. // optimization
  4. new Full().scan(dir,visitor);
  5. return;
  6. }
  7. FileSet fs = Util.createFileSet(dir,includes,excludes);
  8. fs.setDefaultexcludes(useDefaultExcludes);
  9. if(dir.exists()) {
  10. DirectoryScanner ds = fs.getDirectoryScanner(new org.apache.tools.ant.Project());
  11. for( String f : ds.getIncludedFiles()) {
  12. File file = new File(dir, f);
  13. scanSingle(file, f, visitor);
  14. }
  15. }
  16. }

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

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

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

  1. /**
  2. * Returns the appropriate FileSet for the selected baseDir
  3. * @param baseDir
  4. * @return
  5. */
  6. private FileSet getFileSet(File baseDir) {
  7. return Util.createFileSet(baseDir, "*.xml","testng-results.xml,testng-failed.xml");
  8. }

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

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

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

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

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

  1. @Nonnull
  2. public static FileSet createFileSet(@Nonnull File baseDir, @Nonnull String includes) {
  3. return createFileSet(baseDir,includes,null);
  4. }

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

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

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

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

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

  1. @Override public Map<String,String> invoke(File basedir, VirtualChannel channel) throws IOException, InterruptedException {
  2. Map<String,String> r = new HashMap<String,String>();
  3. FileSet fileSet = Util.createFileSet(basedir, includes, excludes);
  4. fileSet.setDefaultexcludes(defaultExcludes);
  5. fileSet.setCaseSensitive(caseSensitive);
  6. for (String f : fileSet.getDirectoryScanner().getIncludedFiles()) {
  7. f = f.replace(File.separatorChar, '/');
  8. r.put(f, f);
  9. }
  10. return r;
  11. }
  12. }

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

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

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

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

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

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

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

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

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

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

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

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

相关文章