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

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

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

FileUtils.getFileNames介绍

[英]Return a list of files as String depending options. This method use case sensitive file name.
[中]根据选项以字符串形式返回文件列表。此方法使用区分大小写的文件名。

代码示例

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

/**
 * Return a list of files as String depending options. This method use case sensitive file name.
 *
 * @param directory the directory to scan
 * @param includes the includes pattern, comma separated
 * @param excludes the excludes pattern, comma separated
 * @param includeBasedir true to include the base dir in each String of file
 * @return a list of files as String
 * @throws IOException
 */
public static List<String> getFileNames( File directory, String includes, String excludes, boolean includeBasedir )
  throws IOException
{
  return getFileNames( directory, includes, excludes, includeBasedir, true );
}

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

/**
 * Return the files contained in the directory, using inclusion and exclusion Ant patterns
 *
 * @param directory the directory to scan
 * @param includes the includes pattern, comma separated
 * @param excludes the excludes pattern, comma separated
 * @param includeBasedir true to include the base dir in each file
 * @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, boolean includeBasedir )
  throws IOException
{
  List<String> fileNames = getFileNames( directory, includes, excludes, includeBasedir );
  List<File> files = new ArrayList<File>();
  for ( String filename : fileNames )
  {
    files.add( new File( filename ) );
  }
  return files;
}

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

FileUtils.getFileNames( targetFolderFile, artifact.getArtifactId() + "-*.jar", null, false );

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

excludes = resource.getExcludes().toString().replace( "[", "" ).replace( "]", "" ).replace( " ", "" );
List<String> resFiles = FileUtils.getFileNames( baseDir, includes, excludes, true, true );
for( String resFile: resFiles ) {
  File resourceFile = new File( resFile );

代码示例来源:origin: javaee/glassfish

options.add(getBuildClasspath());
List<String> classNames = new ArrayList<String>();
classNames.addAll(FileUtils.getFileNames(getSourceDirectory(), includes, excludes,true));

代码示例来源:origin: org.apache.servicemix.kernel.gshell/org.apache.servicemix.kernel.gshell.core

/**
 * Return a list of files as String depending options.
 * This method use case sensitive file name.
 *
 * @param directory      the directory to scan
 * @param includes       the includes pattern, comma separated
 * @param excludes       the excludes pattern, comma separated
 * @param includeBasedir true to include the base dir in each String of file
 * @return a list of files as String
 * @throws IOException
 */
public static List getFileNames( File directory, String includes, String excludes, boolean includeBasedir )
  throws IOException
{
  return getFileNames( directory, includes, excludes, includeBasedir, true );
}

代码示例来源:origin: io.provis/provisio-core

public void execute(ProvisioningContext context) {
 try {
  List<String> files = FileUtils.getFileNames(runtimeDirectory, includes, excludes, true);
  for (String file : files) {
   System.out.println(file);
  }
 } catch (IOException e) {
 }
}

代码示例来源:origin: org.kathrynhuxtable.maven.plugins/htmlfilter-site-maven-plugin

/**
 * Get the list of filenames to merge.
 *
 * @return a list of filenames to merge.
 */
@SuppressWarnings("unchecked")
private List<String> getFileList() {
  List<String> fileList = null;
  try {
    fileList = FileUtils.getFileNames(sourceDirectory, filePattern, "", false, true);
  } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
  return fileList;
}

代码示例来源:origin: org.kathrynhuxtable.maven.plugins/htmlfilter-site-maven-plugin

/**
 * DOCUMENT ME!
 *
 * @return
 */
@SuppressWarnings("unchecked")
private List<String> getFileList() {
  List<String> fileList = null;
  try {
    fileList = FileUtils.getFileNames(tidySourceDirectory, tidyFilePattern, "", false, true);
  } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
  return fileList;
}

代码示例来源:origin: io.provis/provisio-core

public void execute(ProvisioningContext context) throws Exception {
 if (fileSetDirectory.exists()) {
  try {
   List<String> filePaths = FileUtils.getFileNames(fileSetDirectory, includes, excludes, true);
   for (String filePath : filePaths) {
    File file = new File(filePath);
    file.setExecutable(true);
   }
  } catch (IOException e) {
   throw new RuntimeException(e);
  }
 }
}

代码示例来源:origin: gradle.plugin.org.gosu-lang.gosu/gradle-gosu-plugin

/**
 * Get all JARs from the lib directory of the System's java.home property
 * @return List of absolute paths to all JRE libraries
 */
@SuppressWarnings("unchecked")
private List<String> getJreJars() {
 File javaHome = new File(System.getProperty("java.home"));
 File libsDir = new File(javaHome + "/lib");
 List<String> classes = new ArrayList<>();
 try {
  classes = FileUtils.getFileNames(libsDir, "**/*.jar", null, true); //gradleApi is using an older version of plexus-utils which does not support generics
 } catch (IOException e) {
  e.printStackTrace();
 }
 return classes;
}

代码示例来源:origin: zolyfarkas/spf4j

public static Set<String> getPackages(final Collection<File> compileSourceRoots) throws IOException {
  Set<String> packages = new HashSet<String>(64);
  for (File compileRoot : compileSourceRoots) {
   @SuppressWarnings("unchecked")
   List<String> files
       = FileUtils.getFileNames(compileRoot, "**/*.java", null, false);
   for (String file : files) {
    packages.add(FileUtils.dirname(file).replace(File.separatorChar, '.'));
   }
  }
  return packages;
 }
}

代码示例来源:origin: org.apache.maven.doxia/doxia-doc-renderer

private List<String> getModuleFileNames( ParserModule module, File moduleBasedir )
  throws IOException
{
  StringBuilder includes = new StringBuilder();
  for ( String extension: module.getExtensions() )
  {
    if ( includes.length() > 0 )
    {
      includes.append( ',' );
    }
    includes.append( "**/*." );
    includes.append( extension );
  }
  return FileUtils.getFileNames( moduleBasedir, includes.toString(), null, false );
}

代码示例来源:origin: io.provis/provisio-core

private void copyDirectoryStructure(File sourceDirectory, File targetDirectory, List<String> includes, List<String> excludes) throws IOException {
 String includesString = null;
 if (includes != null && !includes.isEmpty()) {
  includesString = joiner.join(includes);
 }
 String excludesString = null;
 if (excludes != null && !excludes.isEmpty()) {
  excludesString = joiner.join(excludes);
 }
 List<String> relativePaths = FileUtils.getFileNames(sourceDirectory, includesString, excludesString, false);
 for (String relativePath : relativePaths) {
  File source = new File(sourceDirectory, relativePath);
  File target = new File(targetDirectory, relativePath);
  copy(source, target);
 }
}

代码示例来源:origin: org.apache.maven.scm/maven-scm-provider-local

/**
 * Builds LocalScmMetadata based on contents of repository
 *
 * @param repository
 * @return
 * @throws IOException if any
 */
public LocalScmMetadata buildMetadata( File repository )
  throws IOException
{
  @SuppressWarnings( "unchecked" )
  List<String> repoFilenames = FileUtils.getFileNames( repository.getAbsoluteFile(), "**", null, false );
  LocalScmMetadata metadata = new LocalScmMetadata();
  metadata.setRepositoryFileNames( repoFilenames );
  return metadata;
}

代码示例来源:origin: apache/maven-scm

/**
 * Builds LocalScmMetadata based on contents of repository
 *
 * @param repository
 * @return
 * @throws IOException if any
 */
public LocalScmMetadata buildMetadata( File repository )
  throws IOException
{
  @SuppressWarnings( "unchecked" )
  List<String> repoFilenames = FileUtils.getFileNames( repository.getAbsoluteFile(), "**", null, false );
  LocalScmMetadata metadata = new LocalScmMetadata();
  metadata.setRepositoryFileNames( repoFilenames );
  return metadata;
}

代码示例来源:origin: org.jvnet.wagon-svn/wagon-svn

@Override
public void putDirectory(File sourceDirectory, String destinationDirectory) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException {
  try {
    List<String> files = FileUtils.getFileNames( sourceDirectory, "**/**", "", false );
    for (String file : files)
      put(new File(sourceDirectory,file),combine(destinationDirectory,file));
  } catch (IOException e) {
    throw new TransferFailedException("Failed to list up files in "+sourceDirectory,e);
  }
}

代码示例来源:origin: org.sonatype.maven.archetype/archetype-common

private List<String> resolveFileNames(final Model pom, final File basedir) throws IOException {
  log.debug("Resolving files for " + pom.getId() + " in " + basedir);
  String excludes = "pom.xml*,archetype.properties*,target/**,";
  for (String module : pom.getModules()) {
    excludes += "," + module + "/**";
  }
  for (String exclude : ListScanner.DEFAULT_EXCLUDES) {
    excludes += "," + exclude + "/**";
  }
  excludes = PathUtils.convertPathForOS(excludes);
  @SuppressWarnings({"unchecked"})
  List<String> fileNames = FileUtils.getFileNames(basedir, "**,.*,**/.*", excludes, false);
  log.debug("Resolved " + fileNames.size() + " files");
  log.debug("Resolved Files:" + fileNames);
  return fileNames;
}

代码示例来源:origin: christian-schlichtherle/truelicense

void processDirectory() throws Exception {
  final File templateDirectory = resolveWithBaseDirectory(templateDirectoryPath());
  final List<String> paths = FileUtils.getFileNames(templateDirectory,
      list2csv(templates.getIncludes()),
      list2csv(templates.getExcludes()),
      false);
  if (paths.isEmpty()) {
    getLog().warn(templates + " is empty.");
  } else {
    getLog().info("Template directory: " + templateDirectory);
    getLog().info("Merge directory: " + mergeDirectory());
    for (String path : paths) {
      processFile(path);
    }
    generateSourcesStrategy().updateProjectFrom(this);
  }
}

代码示例来源:origin: net.java.truelicense/truelicense-maven-plugin

@SuppressWarnings("unchecked")
void processDirectory() throws Exception {
  final File templateDirectory = resolveWithBaseDirectory(templateDirectoryPath());
  final List<String> paths = FileUtils.getFileNames(templateDirectory,
      list2csv(templates.getIncludes()),
      list2csv(templates.getExcludes()),
      false);
  if (paths.isEmpty()) {
    getLog().warn(templates + " is empty.");
  } else {
    getLog().info("Template directory: " + templateDirectory);
    getLog().info("Merge directory: " + mergeDirectory());
    for (String path : paths) processFile(path);
    generateSourcesStrategy().updateProjectFrom(this);
  }
}

相关文章