org.codehaus.plexus.util.FileUtils.getFiles()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(168)

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

FileUtils.getFiles介绍

[英]Return the files contained in the directory, using inclusion and exclusion Ant patterns, including the directory name in each of the files
[中]使用包含和排除Ant模式返回目录中包含的文件,包括每个文件中的目录名

代码示例

代码示例来源:origin: org.codehaus.plexus/plexus-utils

/**
 * Return the files contained in the directory, using inclusion and exclusion Ant patterns, including the directory
 * name in each of the files
 *
 * @param directory the directory to scan
 * @param includes the includes pattern, comma separated
 * @param excludes the excludes pattern, comma separated
 * @return a list of File objects
 * @throws IOException
 * @see #getFileNames(File, String, String, boolean)
 */
public static List<File> getFiles( File directory, String includes, String excludes )
  throws IOException
{
  return getFiles( directory, includes, excludes, true );
}

代码示例来源:origin: org.codehaus.plexus/plexus-utils

/**
 * Copy a directory to an other one.
 *
 * @param sourceDirectory the source dir
 * @param destinationDirectory the target dir
 * @param includes include pattern
 * @param excludes exclude pattern
 * @throws IOException if any
 * @see #getFiles(File, String, String)
 */
public static void copyDirectory( File sourceDirectory, File destinationDirectory, String includes,
                 String excludes )
  throws IOException
{
  if ( !sourceDirectory.exists() )
  {
    return;
  }
  List<File> files = getFiles( sourceDirectory, includes, excludes );
  for ( File file : files )
  {
    copyFileToDirectory( file, destinationDirectory );
  }
}

代码示例来源:origin: apache/storm

@SuppressWarnings("unchecked")
public static List<File> convertFileSetToFiles(FileSet source)
  throws IOException {
  String includes = getCommaSeparatedList(source.getIncludes());
  String excludes = getCommaSeparatedList(source.getExcludes());
  return FileUtils.getFiles(new File(source.getDirectory()), includes,
               excludes);
}

代码示例来源:origin: hcoles/pitest

private List<File> getProjectFilesByFilter(final File projectBaseDir,
                      final String filter) throws IOException {
 File reportsDir = projectBaseDir.toPath().resolve(REPORT_DIR_RELATIVE_TO_PROJECT).toFile();
 if (!reportsDir.exists()) {
  return new ArrayList<>();
 }
 File latestReportDir = reportSourceLocator.locate(reportsDir, getLog());
 final List<File> files = FileUtils.getFiles(latestReportDir, filter, "");
 return files == null ? new ArrayList<>() : files;
}

代码示例来源:origin: diffplug/spotless

private List<File> collectFiles(FormatterFactory formatterFactory) throws MojoExecutionException {
  Set<String> configuredIncludes = formatterFactory.includes();
  Set<String> configuredExcludes = formatterFactory.excludes();
  Set<String> includes = configuredIncludes.isEmpty() ? formatterFactory.defaultIncludes() : configuredIncludes;
  Set<String> excludes = new HashSet<>(FileUtils.getDefaultExcludesAsList());
  excludes.add(withTrailingSeparator(targetDir.toString()));
  excludes.addAll(configuredExcludes);
  String includesString = String.join(",", includes);
  String excludesString = String.join(",", excludes);
  try {
    return FileUtils.getFiles(baseDir, includesString, excludesString);
  } catch (IOException e) {
    throw new MojoExecutionException("Unable to scan file tree rooted at " + baseDir, e);
  }
}

代码示例来源:origin: org.codehaus.plexus/plexus-archiver

try
  List dotFiles = FileUtils.getFiles( dotFileDirectory, dotFilePrefix + "*", null );

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

ImmutableSet<File> findGeneratedFilesInDirectory(File directory) throws IOException {
  if (directory == null || !directory.isDirectory())
    return ImmutableSet.of();
  // TODO(gak): plexus-utils needs generics
  @SuppressWarnings("unchecked")
  List<File> javaFilesInDirectory = getFiles(directory, "**/*.java", null);
  return ImmutableSet.copyOf(javaFilesInDirectory);
}

代码示例来源:origin: timurstrekalov/saga

@Override
public List<URI> fetch(final URI baseUri, final String includes, final String excludes) throws IOException {
  final File baseDir = new File(baseUri);
  Preconditions.checkState(baseDir.exists(), "baseDir doesn't exist");
  final List<File> tests = FileUtils.getFiles(baseDir, includes, excludes);
  return ImmutableList.copyOf(Lists.transform(tests, new Function<File, URI>() {
    @Override
    public URI apply(final File input) {
      return input.toURI();
    }
  }));
}

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

ImmutableSet<File> findThriftFilesInDirectory(File directory) throws IOException {
  checkNotNull(directory);
  checkArgument(directory.isDirectory(), "%s is not a directory", directory);
  final Joiner joiner = Joiner.on(',');
  // TODO(gak): plexus-utils needs generics
  @SuppressWarnings("unchecked")
  List<File> thriftFilesInDirectory = getFiles(directory, joiner.join(includes), joiner.join(excludes));
  return ImmutableSet.copyOf(thriftFilesInDirectory);
}

代码示例来源:origin: diffplug/spotless

@Test
  public void testDefaultIncludes() throws Exception {
    Cpp cpp = new Cpp();
    cpp.defaultIncludes();

    String includesString = String.join(",", cpp.defaultIncludes());
    setFile("src/main/cpp/file.c++").toContent("");
    setFile("src/file.c++").toContent("");
    setFile("src/main/cpp/file.dummy").toContent("");
    setFile("src/test/cpp/file.h").toContent("");
    setFile("src/test/cpp/file.dummy").toContent("");

    assertEquals(2, FileUtils.getFiles(rootFolder(), includesString, "").size());

  }
}

代码示例来源:origin: org.pitest/pitest-maven

private List<File> getProjectFilesByFilter(final File projectBaseDir,
                      final String filter) throws IOException {
 File reportsDir = projectBaseDir.toPath().resolve(REPORT_DIR_RELATIVE_TO_PROJECT).toFile();
 if (!reportsDir.exists()) {
  return new ArrayList<>();
 }
 File latestReportDir = reportSourceLocator.locate(reportsDir, getLog());
 final List<File> files = FileUtils.getFiles(latestReportDir, filter, "");
 return files == null ? new ArrayList<>() : files;
}

代码示例来源:origin: com.googlecode.jslint4java/jslint4java-maven-plugin

public List<File> files() throws IOException {
  if (!sourceDirectory.exists()) {
    return ImmutableList.of();
  }
  String includesStr = StringUtils.join(includes.iterator(), ",");
  String excludesStr = StringUtils.join(excludes.iterator(), ",");
  return FileUtils.getFiles(sourceDirectory, includesStr, excludesStr);
}

代码示例来源:origin: nidi3/code-assert

private boolean existsCoverageTest() throws IOException {
    final File testDir = new File(mavenProject.getBuild().getTestOutputDirectory());
    final List<File> testFiles = FileUtils.getFiles(testDir, "**/" + testClass + ".class", "");
    if (testFiles.isEmpty()) {
      getLog().warn("Code coverage test not found: '" + testClass + ".java'.");
      return false;
    }
    return true;
  }
}

代码示例来源:origin: org.codehaus.mojo.natives/maven-native-api

public FileSet( File basedir, String includes, String excludes )
  throws IOException
{
  this.basedir = basedir;
  excludes = this.trimCommaSeparateString( excludes );
  includes = this.trimCommaSeparateString( includes );
  files = (File[]) FileUtils.getFiles( basedir, includes, excludes ).toArray( EMPTY_FILE_ARRAY );
}

代码示例来源:origin: jutzig/github-release-plugin

private void uploadAssets(GHRelease release, FileSet fileset) throws IOException {
  List<File> assets = FileUtils.getFiles(
      new File(fileset.getDirectory()),
      StringUtils.join(fileset.getIncludes(), ','),
      StringUtils.join(fileset.getExcludes(), ',')
  );
  for (File asset : assets)
    uploadAsset(release, asset);
}

代码示例来源:origin: org.fornax.toolsupport/fornax-oaw-m2-plugin

@SuppressWarnings("unchecked")
private List<File> toFileList(FileSet fileSet) throws IOException {
  File directory = new File(fileSet.getDirectory());
  String includes = toString(fileSet.getIncludes());
  String excludes = toString(fileSet.getExcludes());
  try {
    return FileUtils.getFiles(directory, includes, excludes);
  } catch (IllegalStateException e) {
    getLog().warn(e.getMessage() + ". Ignoring fileset.");
    return Collections.emptyList();
  }
}

代码示例来源:origin: io.teecube.t3/t3-common

public static List<File> toFileList(FileSet fileSet) throws IOException {
  File directory = new File(fileSet.getDirectory());
  String includes = toCommaSeparatedString(fileSet.getIncludes());
  String excludes = toCommaSeparatedString(fileSet.getExcludes());
  return FileUtils.getFiles(directory, includes, excludes);
}

代码示例来源:origin: io.teecube.t3/t3-site-enhancer

protected static List<File> toFileList(FileSet fileSet) throws IOException {
  File directory = new File(fileSet.getDirectory());
  String includes = toCommaSeparatedString(fileSet.getIncludes());
  String excludes = toCommaSeparatedString(fileSet.getExcludes());
  return org.codehaus.plexus.util.FileUtils.getFiles(directory, includes, excludes);
}

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

private static List<File> toFileList(FileSet fileSet)
    throws IOException {
  File directory = new File(fileSet.getDirectory());
  String includes = toString(fileSet.getIncludes());
  String excludes = toString(fileSet.getExcludes());
  return FileUtils.getFiles(directory, includes, excludes);
}

代码示例来源:origin: apache/tajo

/**
  * Converts a Maven FileSet to a list of File objects.
  * 
  * @param source FileSet to convert
  * @return List<File> containing every element of the FileSet as a File
  * @throws IOException if an I/O error occurs while trying to find the files
  */
 @SuppressWarnings("unchecked")
 public static List<File> convertFileSetToFiles(FileSet source) throws IOException {
  String includes = getCommaSeparatedList(source.getIncludes());
  String excludes = getCommaSeparatedList(source.getExcludes());
  return FileUtils.getFiles(new File(source.getDirectory()), includes, excludes);
 }
}

相关文章