当前位置: 首页>>代码示例>>Java>>正文


Java FileSet.getIncludes方法代码示例

本文整理汇总了Java中org.apache.maven.model.FileSet.getIncludes方法的典型用法代码示例。如果您正苦于以下问题:Java FileSet.getIncludes方法的具体用法?Java FileSet.getIncludes怎么用?Java FileSet.getIncludes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.maven.model.FileSet的用法示例。


在下文中一共展示了FileSet.getIncludes方法的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;
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:27,代码来源:ExecMojo.java

示例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();
}
 
开发者ID:mojohaus,项目名称:xml-maven-plugin,代码行数:35,代码来源:CheckFormatMojo.java

示例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));
	}
}
 
开发者ID:highsource,项目名称:maven-jaxb2-plugin,代码行数:54,代码来源:AbstractXJC2Mojo.java


注:本文中的org.apache.maven.model.FileSet.getIncludes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。