本文整理汇总了Java中org.codehaus.plexus.util.FileUtils.getFiles方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.getFiles方法的具体用法?Java FileUtils.getFiles怎么用?Java FileUtils.getFiles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.plexus.util.FileUtils
的用法示例。
在下文中一共展示了FileUtils.getFiles方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
* Called by the project to let the task do its work.
* This will invoke PatternGenerator for each file in the nested FileSet(s).
*
* @throws MojoExecutionException if something goes wrong.
*/
public void execute() throws MojoExecutionException {
PatternGenerator pg = null;
try {
File directory = new File(fileSet.getDirectory());
String includes = StringUtils.join(fileSet.getIncludes(), ",");
String excludes = StringUtils.join(fileSet.getExcludes(), ",");
List<File> fileList = FileUtils.getFiles(directory, includes, excludes);
for (File file : fileList) {
pg = new PatternGenerator(file.toURI().toURL());
pg.setData(fileList);
pg.processPattern();
pg.destroy();
pg = null;
}
} catch (Exception e) {
e.printStackTrace();
throw new MojoExecutionException("Error in executing PatternGeneratorMojo: " + e.getMessage(), e);
} finally {
if (pg != null) {
pg.destroy();
}
}
}
示例2: toFileList
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
public List<File> toFileList( FileSet fs ) throws MojoExecutionException
{
try
{
if ( fs.getDirectory() != null )
{
File directory = new File( fs.getDirectory() );
String includes = toString( fs.getIncludes() );
String excludes = toString( fs.getExcludes() );
return FileUtils.getFiles( directory, includes, excludes );
}
else
{
getLog().warn( String.format( "Fileset [%s] directory empty", fs.toString() ) );
return new ArrayList<>();
}
}
catch ( IOException e )
{
throw new MojoExecutionException( String.format( "Unable to get paths to fileset [%s]", fs.toString() ),
e );
}
}
示例3: getTargetPropertiesFiles
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
* gets a list of all property files in the iib and iib-test directories. A copy of the default
* properties file will be copied into the iib-overrides directory if both iib directories are empty.
*
* @return
* @throws MojoFailureException
*/
@SuppressWarnings("unchecked")
private List<File> getTargetPropertiesFiles() throws MojoFailureException {
List<File> propFiles = null;
File targetIibDirectory = new File(project.getBuild().getDirectory(), "iib-overrides");
try {
// see also PrepareIibBarPackagingMojo.java
// String excludedDefaultPropertyFileName = defaultPropertiesFile.getName();
propFiles = FileUtils.getFiles(targetIibDirectory, "*.properties", null);// excludedDefaultPropertyFileName);
} catch (IOException e) {
// TODO handle exception
throw new MojoFailureException("Error searching for properties files under " + targetIibDirectory, e);
}
return propFiles;
}
示例4: findPropertiesForPatterns
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private Set<File> findPropertiesForPatterns(final File basedir, final List<String> patterns) throws IOException {
final Set<File> propertiesFiles = new TreeSet<File>();
for (final String pattern : patterns) {
@SuppressWarnings("unchecked")
final List<File> files = FileUtils.getFiles(basedir, pattern, null);
propertiesFiles.addAll(files);
}
return propertiesFiles;
}
示例5: toFileList
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private static List<File> toFileList(FileSet fileSet)
throws IOException {
File directory = new File(fileSet.getDirectory());
if (directory.exists()) {
String includes = toString(fileSet.getIncludes());
String excludes = toString(fileSet.getExcludes());
return FileUtils.getFiles(directory, includes, excludes);
}
return Collections.<File>emptyList();
}
示例6: getTmlFiles
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private Set<String> getTmlFiles() throws IOException {
Set<String> files = new HashSet<>();
for (FileSet fileSet : tmls) {
File directory = (fileSet.getDirectory() == null) ?
this.project.getBasedir() : new File(fileSet.getDirectory());
String includes = StringUtils.join(fileSet.getIncludes(), ',');
String excludes = StringUtils.join(fileSet.getExcludes(), ',');
for (File file : FileUtils.getFiles(directory, includes, excludes)) {
files.add(file.getAbsolutePath());
}
}
return files;
}
示例7: getFiles
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private List<File> getFiles() throws IOException {
final String includesString = (getIncludes() == null || getIncludes().length == 0) ? "**/*.java"
: StringUtils.join(getIncludes(), ",");
final String excludesString = (getExcludes() == null || getExcludes().length == 0) ? null
: StringUtils.join(getExcludes(), ",");
return FileUtils.getFiles(getSourceDirectory(), includesString, excludesString);
}
示例8: cqlFiles
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
public static List<File> cqlFiles(FileSet fileSet) throws IOException {
File directory = new File(fileSet.getDirectory());
String includes = fileSet.getIncludes().stream().collect(joining(", "));
String excludes = fileSet.getExcludes().stream().collect(joining(", "));
@SuppressWarnings("unchecked")
List<File> files = FileUtils.getFiles(directory, includes, excludes);
Collections.sort(files);
return files;
}
示例9: getAllFiles
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
public Set<File> getAllFiles(String includes, String excludes, boolean includeResources) throws IOException
{
Set<File> sourceDirs = new HashSet<File>();
final java.util.List<String> sourceRoots = getProject().getCompileSourceRoots();
if (sourceRoots != null)
{
for (String s : sourceRoots)
{
sourceDirs.add(new File(s));
}
}
if(includeResources)
{
List<Resource> resources = getProject().getResources();
if (resources != null)
{
for (Resource resource : resources)
{
sourceDirs.add(new File(resource.getDirectory()));
}
}
}
Set<File> files = new HashSet<File>();
for (File sourceRoot : sourceDirs)
{
if (getLog().isDebugEnabled())
{
getLog().debug("Scanning source folder: " + sourceRoot.getCanonicalPath());
}
@SuppressWarnings("unchecked")
List<File> dirFiles = FileUtils.getFiles(sourceRoot, includes, excludes);
if (dirFiles != null)
{
files.addAll(dirFiles);
}
}
return files;
}
示例10: copyJnlpFiles
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private void copyJnlpFiles()
throws MavenReportException
{
if ( !jnlpSourceDirectory.exists() )
{
throw new MavenReportException( "jnlpSourceDirectory does not exist" );
}
try
{
File destinationDirectory = new File( outputDirectory, siteJnlpDirectory );
List<File> files = FileUtils.getFiles( jnlpSourceDirectory, "**/*", "" );
for ( File file : files )
{
getLog().debug( "Copying " + file + " to " + destinationDirectory );
String path = file.getAbsolutePath().substring( jnlpSourceDirectory.getAbsolutePath().length() + 1 );
File destDir = new File( destinationDirectory, path );
getLog().debug( "Copying " + file + " to " + destDir );
if ( file.isDirectory() )
{
destDir.mkdirs();
}
else
{
FileUtils.copyFileToDirectory( file, destDir.getParentFile() );
}
}
}
catch ( IOException e )
{
throw new MavenReportException( "Failed to copy jnlp files", e );
}
}
示例11: existsCoverageTest
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
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;
}
示例12: addModelPullerScanner
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
* Adds a scanner if a "META-INF/switchyard.xml" file is found in the folder specified by baseDir.
*
* @param baseDir the directory to search.
* @param includes file includes.
* @param excludes file excludes.
* @param scanners the scanners list
* @throws IOException if an error occurs.
*/
private void addModelPullerScanner(final File baseDir, final String includes, final String excludes, final List<Scanner<M>> scanners) throws IOException {
final File switchYardFile = new File(baseDir, DEFAULT_SWITCHYARD_XML_FILE_PATH).getCanonicalFile();
for (File file : (List<File>)FileUtils.getFiles(baseDir, includes, excludes)) {
file = file.getCanonicalFile();
if (switchYardFile.equals(file)) {
// found a match, add a scanner
scanners.add(new ModelPullerScanner<M>(file) {
@Override
public ScannerOutput<M> scan(ScannerInput<M> input) throws IOException {
ScannerOutput<M> output = super.scan(input);
M model = output.getModel();
if (model != null) {
Model root = model.getModelRoot();
if (root instanceof SwitchYardModel) {
if (!input.isSwitchyardNamespaceSet()) {
String uri = root.getModelRootNamespace();
SwitchYardNamespace ns = SwitchYardNamespace.fromUri(uri);
input.setSwitchyardNamespace(ns);
}
}
}
return output;
}
});
// one file per folder
return;
}
}
}
示例13: setUp
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Before
@Override
public void setUp()
throws Exception
{
super.setUp();
File sourceRepoDir = new File( "./src/test/repositories/default-repository" );
repoDir = new File( "./target/default-repository" );
FileUtils.deleteDirectory( repoDir );
assertFalse( "Default Test Repository should not exist.", repoDir.exists() );
repoDir.mkdir();
FileUtils.copyDirectoryStructure( sourceRepoDir, repoDir );
// set the timestamps to a time well in the past
Calendar cal = Calendar.getInstance();
cal.add( Calendar.YEAR, -1 );
for ( File f : (List<File>) FileUtils.getFiles( repoDir, "**", null ) )
{
f.setLastModified( cal.getTimeInMillis() );
}
// TODO: test they are excluded instead
for ( String dir : (List<String>) FileUtils.getDirectoryNames( repoDir, "**/.svn", null, false ) )
{
FileUtils.deleteDirectory( new File( repoDir, dir ) );
}
assertTrue( "Default Test Repository should exist.", repoDir.exists() && repoDir.isDirectory() );
assertNotNull( archivaConfig );
// Create it
ManagedRepositoryConfiguration repositoryConfiguration = new ManagedRepositoryConfiguration();
repositoryConfiguration.setId( TEST_REPO_ID );
repositoryConfiguration.setName( "Test Repository" );
repositoryConfiguration.setLocation( repoDir.getAbsolutePath() );
archivaConfig.getConfiguration().getManagedRepositories().clear();
archivaConfig.getConfiguration().addManagedRepository( repositoryConfiguration );
metadataRepository = mock( MetadataRepository.class );
factory.setRepository( metadataRepository );
}
开发者ID:ruikom,项目名称:apache-archiva,代码行数:46,代码来源:ArchivaRepositoryScanningTaskExecutorAbstractTest.java
示例14: attemptToDelete
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private void attemptToDelete(String expression)
{
try
{
boolean isExpression = expression.indexOf("*") != -1;
if (isExpression)
{
@SuppressWarnings("unchecked")
List<File> files = FileUtils.getFiles(project.getBasedir(), expression, null, false);
for (File file : files)
{
file.delete();
}
return;
}
// / try to delete absolute name
boolean result = delete(expression);
if (result == true) {
return;
}
// / attempt to append path to project base directory
File baseDir = project.getBasedir();
String newPath = baseDir + File.separator + expression;
// newPath = newPath.replaceAll(File.separator + File.separator, File.separator);
result = delete(newPath);
if (result == true) {
return;
}
// / attempt to append path to workspace directory
newPath = workspace.getAbsolutePath() + File.separator + expression;
// newPath = newPath.replaceAll(File.separator + File.separator, File.separator);
result = delete(newPath);
if (result == true) {
return;
}
} catch (Exception e)
{
getLog().info("unable to delete file " + expression + " for following reason: " + e);
}
}
示例15: toFileList
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
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);
}