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


Java FileSet类代码示例

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


FileSet类属于org.apache.maven.model包,在下文中一共展示了FileSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toFileList

import org.apache.maven.model.FileSet; //导入依赖的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 );
    }
}
 
开发者ID:cjnygard,项目名称:rest-maven-plugin,代码行数:24,代码来源:Plugin.java

示例2: getFilesToProcess

import org.apache.maven.model.FileSet; //导入依赖的package包/类
protected List<File> getFilesToProcess() throws MojoExecutionException
{
    List<File> files = new ArrayList<>();
    if ( null != getFileset() )
    {
        if ( null == getFilesets() )
        {
            filesets = new ArrayList<>();
        }
        getFilesets().add( getFileset() );

    }
    if ( null != getFilesets() )
    {
        for ( FileSet fs : getFilesets() )
        {
            if ( (null != fs) && (null != fs.getDirectory()) )
            {
                FileSetTransformer fileMgr = new FileSetTransformer( fs );
                files.addAll( fileMgr.toFileList() );
            }
        }
    }
    return files;
}
 
开发者ID:cjnygard,项目名称:rest-maven-plugin,代码行数:26,代码来源:Plugin.java

示例3: createIvyArchive

import org.apache.maven.model.FileSet; //导入依赖的package包/类
private void createIvyArchive(File sourceDir, File targetIar) throws MojoExecutionException
{
  ZipArchiver archiver = new ZipArchiver();
  archiver.setDestFile(targetIar);
  archiver.addFileSet(getDefaultFileset(sourceDir));
  FileSetConverter fsConverter = new FileSetConverter(project.getBasedir());
  for(org.codehaus.plexus.archiver.FileSet fs : fsConverter.toPlexusFileSets(iarFileSets))
  {
    archiver.addFileSet(fs);
  }
  try
  {
    archiver.createArchive();
  }
  catch (ArchiverException | IOException ex)
  {
    throw new MojoExecutionException("Failed to create IAR: " + targetIar.getAbsolutePath(), ex);
  }
}
 
开发者ID:axonivy,项目名称:project-build-plugin,代码行数:20,代码来源:IarPackagingMojo.java

示例4: canDefineCustomInclusions

import org.apache.maven.model.FileSet; //导入依赖的package包/类
@Test
public void canDefineCustomInclusions() throws Exception
{
  IarPackagingMojo mojo = rule.getMojo();
  File outputDir = new File(mojo.project.getBasedir(), "target");
  File customPomXml = new File(outputDir, "myCustomPom.xml");
  FileUtils.write(customPomXml, "customPomContent");
  
  String relativeCustomIncludePath = "target/"+customPomXml.getName();
  FileSet fs = new FileSet();
  fs.setIncludes(Arrays.asList(relativeCustomIncludePath));
  mojo.iarFileSets = new FileSet[]{fs};
  
  mojo.execute();
  try(ZipFile archive = new ZipFile(mojo.project.getArtifact().getFile()))
  {
    assertThat(archive.getEntry(relativeCustomIncludePath)).as("Custom inclusions must be included").isNotNull();
  }
}
 
开发者ID:axonivy,项目名称:project-build-plugin,代码行数:20,代码来源:TestIarPackagingMojo.java

示例5: testEmptyXmlFileSets

import org.apache.maven.model.FileSet; //导入依赖的package包/类
@Test()
public void testEmptyXmlFileSets() throws Exception {

    final File testPom = new File("src/test/resources/net/trajano/mojo/cleanpom/cleaner-pom.xml");
    final File xml = new File("src/test/resources/net/trajano/mojo/cleanpom/dual-doctype.xml");
    final File temp = File.createTempFile("dirty", "");
    temp.delete();
    temp.mkdirs();
    FileUtils.copyFile(xml, new File(temp, "dirty1.xml"));

    final CleanXmlMojo mojo = (CleanXmlMojo) rule.lookupMojo("clean-xml", testPom);
    mojo.setXmlFileSets(new FileSet[0]);
    assertNotNull(mojo);
    try {
        mojo.execute();
    } finally {
        FileUtils.deleteDirectory(temp);
    }
}
 
开发者ID:trajano,项目名称:cleanpom-maven-plugin,代码行数:20,代码来源:CleanXmlMojoTest.java

示例6: testFailWithWithDTDs

import org.apache.maven.model.FileSet; //导入依赖的package包/类
@Test(expected = MojoExecutionException.class)
public void testFailWithWithDTDs() throws Exception {

    final File testPom = new File("src/test/resources/net/trajano/mojo/cleanpom/cleaner-pom.xml");
    final File xml = new File("src/test/resources/net/trajano/mojo/cleanpom/dual-doctype.xml");
    final File temp = File.createTempFile("dirty", "");
    temp.delete();
    temp.mkdirs();
    FileUtils.copyFile(xml, new File(temp, "dirty1.xml"));

    final CleanXmlMojo mojo = (CleanXmlMojo) rule.lookupMojo("clean-xml", testPom);
    final FileSet xmlFiles = new FileSet();
    xmlFiles.setDirectory(temp.getAbsolutePath());
    xmlFiles.addInclude("**/*.xml");
    rule.setVariableValueToObject(mojo, "xmlFileSets", new FileSet[] {
        xmlFiles
    });
    assertNotNull(mojo);
    try {
        mojo.execute();
    } finally {
        FileUtils.deleteDirectory(temp);
    }
}
 
开发者ID:trajano,项目名称:cleanpom-maven-plugin,代码行数:25,代码来源:CleanXmlMojoTest.java

示例7: getResourceFiles

import org.apache.maven.model.FileSet; //导入依赖的package包/类
Collection<String> getResourceFiles(final Iterable<? extends FileSet> fileSets,
    final boolean followLinks, final boolean allowDuplicates, final boolean allowFiles,
    final boolean allowDirs) throws MojoExecutionException {
  final Set<String> result = new LinkedHashSet<>();

  for (final FileSet fileSet : Objects.requireNonNull(fileSets)) {
    final Collection<String> files =
        getResourceFiles(fileSet, followLinks, allowDuplicates, allowFiles, allowDirs);
    for (final String file : files) {
      if (!result.add(file) && !allowDuplicates) {
        getLog()
            .error(
                String.format("a duplicate file %s under directory %s", file,
                    fileSet.getDirectory()));
        throw new MojoExecutionException(String.format("a duplicate file %s under directory %s",
            file, fileSet.getDirectory()));
      }
    }
  }

  return result;
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:23,代码来源:ExecMojo.java

示例8: updateFileSet

import org.apache.maven.model.FileSet; //导入依赖的package包/类
/**
 * Method updateFileSet
 *
 * @param value
 * @param element
 * @param counter
 * @param xmlTag
 */
protected void updateFileSet( FileSet value, String xmlTag, Counter counter, Element element )
{
    boolean shouldExist = value != null;
    Element root = updateElement( counter, element, xmlTag, shouldExist );
    if ( shouldExist )
    {
        Counter innerCount = new Counter( counter.getDepth() + 1 );
        findAndReplaceSimpleElement( innerCount, root, "directory", value.getDirectory(), null );
        findAndReplaceSimpleLists( innerCount, root, value.getIncludes(), "includes", "include" );
        findAndReplaceSimpleLists( innerCount, root, value.getExcludes(), "excludes", "exclude" );
    }
}
 
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:21,代码来源:MavenJDOMWriter.java

示例9: toFileList

import org.apache.maven.model.FileSet; //导入依赖的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();
   }
 
开发者ID:creditkarma,项目名称:maven-exec-jar-plugin,代码行数:12,代码来源:ExecJarMojo.java

示例10: getTmlFiles

import org.apache.maven.model.FileSet; //导入依赖的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;
}
 
开发者ID:ExpediaDotCom,项目名称:tesla,代码行数:14,代码来源:CompileMojo.java

示例11: initFiles

import org.apache.maven.model.FileSet; //导入依赖的package包/类
/**
 * This method retrieves a list of ".aliaslib" files to process in the
 * source directory (usually "target/src") which is a copy of the actual
 * source directory used to compile the TIBCO BusinessWorks EAR.
 */
private List<File> initFiles() throws IOException {
	FileSet restriction = new FileSet();
	File directory = buildSrcDirectory;
	if (directory == null) {
		directory = new File(".");
		getLog().warn(SRC_NOT_SET);
	}

	getLog().debug(directory.getAbsolutePath());
	restriction.setDirectory(directory.getAbsolutePath());

	restriction.addInclude("**/*.aliaslib");

	List<File> result = AbstractProjectsListMojo.toFileList(restriction);

	if (customAliasLibDirectories != null && !customAliasLibDirectories.isEmpty()) {
		for (File customDirectory : customAliasLibDirectories) {
			getLog().debug("Looking for '.aliaslib' files in custom directory: " + customDirectory);
			FileSet customRestriction = new FileSet();
			customRestriction.setDirectory(customDirectory.getAbsolutePath());
			customRestriction.addInclude("**/*.aliaslib");
			result.addAll(AbstractProjectsListMojo.toFileList(customRestriction));
		}
	}

	getLog().debug("List of '.aliaslib' files to update: " + result);
	return result;
}
 
开发者ID:fastconnect,项目名称:tibco-bwmaven,代码行数:34,代码来源:UpdateAliasesLibsMojo.java

示例12: initProjects

import org.apache.maven.model.FileSet; //导入依赖的package包/类
protected final void initProjects(String mandatoryFilename, HashMap<String, String> m, Class<? extends AbstractProject> classAbstractProject) throws IOException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, NoSuchMethodException, XmlPullParserException {
	projects = new ArrayList<AbstractProject>();
	
	restriction= new FileSet();
	restriction.setDirectory(workspaceRoot.getAbsolutePath());
	
	if (recursive) {
		for (String p : patterns) {
			restriction.addInclude(p + mandatoryFilename);
		}
	} else {
		restriction.addInclude(mandatoryFilename); // we are only looking in the "workspaceRoot" directory
	}
	restriction.addExclude("**/target/**/" + mandatoryFilename);
	restriction.addExclude("**/bin/" + mandatoryFilename);
	
	List<File> files = toFileList(restriction);
	
	for (File f : files) {
		Constructor<? extends AbstractProject> ctor = classAbstractProject.getConstructor();
		AbstractProject ap = ctor.newInstance();
		
		ap.initialize(f, workspaceRoot, m, mandatoryFilename, getLog());
		if (!ap.isIgnored()) {
			projects.add(ap);
		} else {
			getLog().debug("Ignoring project '" + ap.getProjectName() + "'");
		}
	}
}
 
开发者ID:fastconnect,项目名称:tibco-bwmaven,代码行数:31,代码来源:AbstractProjectsListMojo.java

示例13: initFiles

import org.apache.maven.model.FileSet; //导入依赖的package包/类
protected List<File> initFiles() throws IOException {
	getLog().debug("Looking for files to process...");

	FileSet restriction = new FileSet();
	File directory = getDirectoryToProcess();
	if (directory == null) {
		directory = new File(".");
	}
	restriction.setDirectory(directory.getAbsolutePath());
	
	restriction.addInclude("**/*.process");
	
	return AbstractProjectsListMojo.toFileList(restriction);
}
 
开发者ID:fastconnect,项目名称:tibco-bwmaven,代码行数:15,代码来源:AbstractDocMojo.java

示例14: initFiles

import org.apache.maven.model.FileSet; //导入依赖的package包/类
@Override
protected List<File> initFiles() throws IOException {
	getLog().debug("Looking for files to process...");

	FileSet restriction = new FileSet();
	restriction.setDirectory(getDirectoryToProcess().getAbsolutePath());
	
	restriction.addInclude("**/*.xml");
	
	return AbstractProjectsListMojo.toFileList(restriction);
}
 
开发者ID:fastconnect,项目名称:tibco-bwmaven,代码行数:12,代码来源:GenerateAPTDocMojo.java

示例15: 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


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