本文整理汇总了Java中org.apache.maven.model.FileSet.getExcludes方法的典型用法代码示例。如果您正苦于以下问题:Java FileSet.getExcludes方法的具体用法?Java FileSet.getExcludes怎么用?Java FileSet.getExcludes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.model.FileSet
的用法示例。
在下文中一共展示了FileSet.getExcludes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResourceFiles
import org.apache.maven.model.FileSet; //导入方法依赖的package包/类
private Collection<String> getResourceFiles(final FileSet fileSet, final boolean followLinks,
final boolean allowDuplicates, final boolean allowFiles, final boolean allowDirs)
throws MojoExecutionException {
final Path dirPath = Paths.get(Objects.requireNonNull(fileSet).getDirectory());
final FileSetPathMatcher matcher =
new FileSetPathMatcher(fileSet.getIncludes(), fileSet.getExcludes(), dirPath);
final EnumSet<FileVisitOption> options =
followLinks ? EnumSet.of(FileVisitOption.FOLLOW_LINKS) : EnumSet
.noneOf(FileVisitOption.class);
final Set<String> result = new LinkedHashSet<>();
try {
final ResourceVisitor resourceVisitor =
new ResourceVisitor(matcher, allowDuplicates, allowFiles, allowDirs, result, getLog());
Files.walkFileTree(dirPath, options, Integer.MAX_VALUE, resourceVisitor);
if (resourceVisitor.getErrorMessage() != null) {
throw new MojoExecutionException(resourceVisitor.getErrorMessage());
}
} catch (final IOException e) {
getLog().error("fileSet caused error", e);
throw new MojoExecutionException("fileSet caused error", e);
}
return result;
}
示例2: scan
import org.apache.maven.model.FileSet; //导入方法依赖的package包/类
/**
* A {@link DirectoryScanner} boiler plate.
*
* @param fileSet {@link FileSet} to scan
* @return the included paths
*/
private String[] scan( FileSet fileSet )
{
File basedir = new File( fileSet.getDirectory() );
if ( !basedir.exists() || !basedir.isDirectory() )
{
return null;
}
DirectoryScanner scanner = new DirectoryScanner();
List<String> includes = fileSet.getIncludes();
List<String> excludes = fileSet.getExcludes();
if ( includes != null && includes.size() > 0 )
{
scanner.setIncludes( includes.toArray( new String[0] ) );
}
if ( excludes != null && excludes.size() > 0 )
{
scanner.setExcludes( excludes.toArray( new String[0] ) );
}
scanner.setBasedir( basedir );
scanner.scan();
return scanner.getIncludedFiles();
}
示例3: createFileSetUris
import org.apache.maven.model.FileSet; //导入方法依赖的package包/类
private List<URI> createFileSetUris(final FileSet fileset,
String defaultDirectory, String[] defaultIncludes,
String defaultExcludes[]) throws MojoExecutionException {
final String draftDirectory = fileset.getDirectory();
final String directory = draftDirectory == null ? defaultDirectory
: draftDirectory;
final List<String> includes;
@SuppressWarnings("unchecked")
final List<String> draftIncludes = (List<String>) fileset.getIncludes();
if (draftIncludes == null || draftIncludes.isEmpty()) {
includes = defaultIncludes == null ? Collections
.<String> emptyList() : Arrays.asList(defaultIncludes);
} else {
includes = draftIncludes;
}
final List<String> excludes;
@SuppressWarnings("unchecked")
final List<String> draftExcludes = (List<String>) fileset.getExcludes();
if (draftExcludes == null || draftExcludes.isEmpty()) {
excludes = defaultExcludes == null ? Collections
.<String> emptyList() : Arrays.asList(defaultExcludes);
} else {
excludes = draftExcludes;
}
String[] includesArray = includes.toArray(new String[includes.size()]);
String[] excludesArray = excludes.toArray(new String[excludes.size()]);
try {
final List<File> files = IOUtils.scanDirectoryForFiles(
getBuildContext(), new File(directory), includesArray,
excludesArray, !getDisableDefaultExcludes());
final List<URI> uris = new ArrayList<URI>(files.size());
for (final File file : files) {
// try {
final URI uri = file.toURI();
uris.add(uri);
// } catch (MalformedURLException murlex) {
// throw new MojoExecutionException(
// MessageFormat.format(
// "Could not create an URL for the file [{0}].",
// file), murlex);
// }
}
return uris;
} catch (IOException ioex) {
throw new MojoExecutionException(
MessageFormat
.format("Could not scan directory [{0}] for files with inclusion [{1}] and exclusion [{2}].",
directory, includes, excludes));
}
}