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


Java FileSet类代码示例

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


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

示例1: removeDirectory

import org.apache.maven.shared.model.fileset.FileSet; //导入依赖的package包/类
/**
 * Deletes a directory and its contents.
 * 
 * @param dir
 *            The base directory of the included and excluded files.
 * @throws IOException
 * @throws MojoExecutionException
 *             When a directory failed to get deleted.
 */
public static void removeDirectory( File dir )
    throws IOException
{
    if ( dir != null )
    {
        Log log = new SilentLog();
        FileSetManager fileSetManager = new FileSetManager( log, false );

        FileSet fs = new FileSet();
        fs.setDirectory( dir.getPath() );
        fs.addInclude( "**/**" );
        fileSetManager.delete( fs );

    }
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:25,代码来源:DependencyTestUtils.java

示例2: getSourceBundleFiles

import org.apache.maven.shared.model.fileset.FileSet; //导入依赖的package包/类
protected List<SourceBundleFile> getSourceBundleFiles(BundleSet bundleSet) {
    List<SourceBundleFile> bundleFiles = new LinkedList<SourceBundleFile>();

    FileSetManager fsm = new FileSetManager(getLog());
    File baseDir = project.getBasedir();
    ResourceType type = bundleSet.getType();
    FileSet fs = bundleSet.getSourceFiles();
    File fsBaseDir = new File(baseDir, fs.getDirectory());
    String[] relPathes = fsm.getIncludedFiles(fs);
    for (String relPath : relPathes) {
        File bundleFile = new File(fsBaseDir, relPath);
        bundleFiles.add(
                new SourceBundleFile(type, pathToBundleId(type, relPath),
                        bundleFile, relPath));
    }
    return bundleFiles;
}
 
开发者ID:IBM-Cloud,项目名称:gp-java-tools,代码行数:18,代码来源:GPBaseMojo.java

示例3: getSourceDirectories

import org.apache.maven.shared.model.fileset.FileSet; //导入依赖的package包/类
/**
 * Combine all inputs for source files which are to be included in the SPDX analysis.
 * FileSets are all normalized to include the full (absolute) path and use filtering.
 * @return included files from the project source roots, resources, and includedDirectories parameter
 */
private FileSet[] getSourceDirectories() 
{
    ArrayList<FileSet> result = new ArrayList<FileSet>();
    @SuppressWarnings( "unchecked" )
    List<String> sourceRoots = this.mavenProject.getCompileSourceRoots();
    if ( sourceRoots != null ) 
    {
        Iterator<String> sourceRootIter = sourceRoots.iterator();
        while ( sourceRootIter.hasNext() ) {
            FileSet srcFileSet = new FileSet();
            File sourceDir = new File( sourceRootIter.next() );
            srcFileSet.setDirectory( sourceDir.getAbsolutePath() );
            srcFileSet.addInclude( INCLUDE_ALL );
            result.add( srcFileSet );
            this.getLog().debug( "Adding sourceRoot directory "+srcFileSet.getDirectory() );
        }
    }
    return result.toArray( new FileSet[result.size()] );
}
 
开发者ID:spdx,项目名称:spdx-maven-plugin,代码行数:25,代码来源:CreateSpdxMojo.java

示例4: getTestDirectories

import org.apache.maven.shared.model.fileset.FileSet; //导入依赖的package包/类
/**
 * Combine all inputs for test files which are to be included in the SPDX analysis.
 * FileSets are all normalized to include the full (absolute) path and use filtering.
 * @return included files from the project source roots, resources, and includedDirectories parameter
 */
private FileSet[] getTestDirectories() 
{
    ArrayList<FileSet> result = new ArrayList<FileSet>();
    @SuppressWarnings( "unchecked" )
    List<String> sourceRoots = this.mavenProject.getTestCompileSourceRoots();
    if ( sourceRoots != null ) 
    {
        Iterator<String> sourceRootIter = sourceRoots.iterator();
        while ( sourceRootIter.hasNext() ) {
            FileSet srcFileSet = new FileSet();
            File sourceDir = new File( sourceRootIter.next() );
            srcFileSet.setDirectory( sourceDir.getAbsolutePath() );
            srcFileSet.addInclude( INCLUDE_ALL );
            result.add( srcFileSet );
            this.getLog().debug( "Adding TestSourceRoot directory "+srcFileSet.getDirectory() );
        }
    }
    return result.toArray( new FileSet[result.size()] );
}
 
开发者ID:spdx,项目名称:spdx-maven-plugin,代码行数:25,代码来源:CreateSpdxMojo.java

示例5: testCollectFileInDirectoryPattern

import org.apache.maven.shared.model.fileset.FileSet; //导入依赖的package包/类
@Test
public void testCollectFileInDirectoryPattern() throws SpdxCollectionException {
    FileSet skipBin = new FileSet();
    skipBin.setDirectory( this.fileSets[0].getDirectory() );
    skipBin.addExclude( "**/*.bin" );
    skipBin.setOutputDirectory( this.fileSets[0].getOutputDirectory() );
    SpdxFileCollector collector = new SpdxFileCollector( null );
       SpdxFile[] SpdxFiles = collector.getFiles();
       assertEquals( 0, SpdxFiles.length );
       
       collector.collectFiles( new FileSet[] {skipBin},  this.directory.getAbsolutePath(), this.defaultFileInformation,
                                          new HashMap<String, SpdxDefaultFileInformation>(),
                                          spdxPackage, RelationshipType.GENERATES, container );
       SpdxFiles = collector.getFiles();
       assertEquals( filePaths.length - 2, SpdxFiles.length );
       Arrays.sort(  SpdxFiles );
       int SpdxFilesIndex = 0;
       for ( int i = 0; i < SpdxFileNames.length; i++ ) {
           if ( SpdxFileNames[i].endsWith( ".bin" )) {
               continue;
           }
           assertEquals( SpdxFileNames[i], SpdxFiles[SpdxFilesIndex++].getName() );
       }
}
 
开发者ID:spdx,项目名称:spdx-maven-plugin,代码行数:25,代码来源:TestSpdxFileCollector.java

示例6: testCollectFileInDirectoryPattern

import org.apache.maven.shared.model.fileset.FileSet; //导入依赖的package包/类
@Test
public void testCollectFileInDirectoryPattern() throws SpdxCollectionException {
    FileSet skipBin = new FileSet();
    skipBin.setDirectory( this.fileSets[0].getDirectory() );
    skipBin.addExclude( "**/*.bin" );
    skipBin.setOutputDirectory( this.fileSets[0].getOutputDirectory() );
    SpdxFileCollector collector = new SpdxFileCollector();
       SpdxFile[] SpdxFiles = collector.getFiles();
       assertEquals( 0, SpdxFiles.length );
       
       collector.collectFiles( new FileSet[] {skipBin},  this.defaultFileInformation,
                                          new HashMap<String, SpdxDefaultFileInformation>() );
       SpdxFiles = collector.getFiles();
       assertEquals( filePaths.length - 2, SpdxFiles.length );
       Arrays.sort(  SpdxFiles );
       int SpdxFilesIndex = 0;
       for ( int i = 0; i < SpdxFileNames.length; i++ ) {
           if ( SpdxFileNames[i].endsWith( ".bin" )) {
               continue;
           }
           assertEquals( SpdxFileNames[i], SpdxFiles[SpdxFilesIndex++].getName() );
       }
}
 
开发者ID:spdx,项目名称:spdx-maven-plugin,代码行数:24,代码来源:TestSpdxFileCollector.java

示例7: testOrderOfFileSet

import org.apache.maven.shared.model.fileset.FileSet; //导入依赖的package包/类
@Test
public void testOrderOfFileSet() {
    FileSet fs = new FileSet();
    fs.setDirectory("target/test-classes/aggregation");
    fs.setIncludes(
            ImmutableList.of(
                    "core/the-first-to-aggregate.js",
                    "core/**/*.js",
                    "utils/**/*.js",
                    "plugins/**/*uses*.js",
                    "plugins/**/*.js"
            )
    );
    Aggregation aggregation = new Aggregation();
    aggregation.setFileSets(ImmutableList.of(fs));

    final Collection<File> included = aggregation.getSelectedFiles(new File("target"));
    assertThat(included).hasSize(5);
    // Check order
    assertThat(Iterables.get(included, 0).getAbsolutePath()).isEqualToIgnoringCase(
            new File("target/test-classes/aggregation/core/the-first-to-aggregate.js").getAbsolutePath());
    assertThat(Iterables.get(included, 1).getAbsolutePath()).isEqualToIgnoringCase(
            new File("target/test-classes/aggregation/core/a.js").getAbsolutePath());
    assertThat(Iterables.get(included, 4).getAbsolutePath()).isEqualToIgnoringCase(
            new File("target/test-classes/aggregation/plugins/another-file.js").getAbsolutePath());
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:27,代码来源:AggregationTest.java

示例8: testExcludes

import org.apache.maven.shared.model.fileset.FileSet; //导入依赖的package包/类
@Test
public void testExcludes() {
    FileSet fs = new FileSet();
    fs.setDirectory("target/test-classes/aggregation");
    fs.setIncludes(
            ImmutableList.of(
                    "core/the-first-to-aggregate.js",
                    "core/**/*.js",
                    "utils/**/*.js",
                    "plugins/**/*uses*.js",
                    "plugins/**/*.js"
            )
    );
    fs.setExcludes(
            ImmutableList.of("**/another-file*")
    );
    Aggregation aggregation = new Aggregation();
    aggregation.setFileSets(ImmutableList.of(fs));

    final Collection<File> included = aggregation.getSelectedFiles(new File("target"));
    assertThat(included).hasSize(4);
    assertThat(Iterables.get(included, 0).getAbsolutePath()).isEqualToIgnoringCase(
            new File("target/test-classes/aggregation/core/the-first-to-aggregate.js").getAbsolutePath());
    assertThat(Iterables.get(included, 1).getAbsolutePath()).isEqualToIgnoringCase(
            new File("target/test-classes/aggregation/core/a.js").getAbsolutePath());
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:27,代码来源:AggregationTest.java

示例9: testIncludesCustomization

import org.apache.maven.shared.model.fileset.FileSet; //导入依赖的package包/类
@Test
public void testIncludesCustomization() throws MojoExecutionException, IOException {
    WebJarPackager packager = new WebJarPackager();
    packager.project = mock(MavenProject.class);
    packager.projectHelper = mock(MavenProjectHelper.class);
    when(packager.project.getArtifactId()).thenReturn("test");
    when(packager.project.getVersion()).thenReturn("1.0");
    when(packager.project.getBasedir()).thenReturn(fake);
    packager.buildDirectory = new File("target/junk");
    copy();
    packager.webjar = new WebJar();
    FileSet set = new FileSet();
    set.setDirectory(new File(classes, "assets").getAbsolutePath());
    set.setIncludes(ImmutableList.of("**/coffee/*"));
    packager.webjar.setFileset(set);

    packager.execute();
    final File wj = new File(packager.buildDirectory, "test-1.0-webjar.jar");
    assertThat(wj).isFile();
    JarFile jar = new JarFile(wj);
    assertThat(jar.getEntry(WebJarPackager.ROOT + "test/1.0/missing")).isNull();
    assertThat(jar.getEntry(WebJarPackager.ROOT + "test/1.0/coffee/script.coffee")).isNotNull();
    assertThat(jar.getEntry(WebJarPackager.ROOT + "test/1.0/less/style.less")).isNull();
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:25,代码来源:WebJarPackagerTest.java

示例10: testExcludesCustomization

import org.apache.maven.shared.model.fileset.FileSet; //导入依赖的package包/类
@Test
public void testExcludesCustomization() throws MojoExecutionException, IOException {
    WebJarPackager packager = new WebJarPackager();
    packager.project = mock(MavenProject.class);
    packager.projectHelper = mock(MavenProjectHelper.class);
    when(packager.project.getArtifactId()).thenReturn("test");
    when(packager.project.getVersion()).thenReturn("1.0");
    when(packager.project.getBasedir()).thenReturn(fake);
    packager.buildDirectory = new File("target/junk");
    copy();
    packager.webjar = new WebJar();
    FileSet set = new FileSet();
    set.setDirectory(new File(classes, "assets").getAbsolutePath());
    set.setExcludes(ImmutableList.of("**/less/*"));
    packager.webjar.setFileset(set);

    packager.execute();
    final File wj = new File(packager.buildDirectory, "test-1.0-webjar.jar");
    assertThat(wj).isFile();
    JarFile jar = new JarFile(wj);
    assertThat(jar.getEntry(WebJarPackager.ROOT + "test/1.0/missing")).isNull();
    assertThat(jar.getEntry(WebJarPackager.ROOT + "test/1.0/coffee/script.coffee")).isNotNull();
    assertThat(jar.getEntry(WebJarPackager.ROOT + "test/1.0/less/style.less")).isNull();
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:25,代码来源:WebJarPackagerTest.java

示例11: getIncludedFiles

import org.apache.maven.shared.model.fileset.FileSet; //导入依赖的package包/类
private String[] getIncludedFiles(String absPath, String[] excludes, String[] includes) {
  FileSetManager fileSetManager = new FileSetManager();
  FileSet fs = new FileSet();
  fs.setDirectory(absPath);
  fs.setFollowSymlinks(false);
  for (String include : includes) fs.addInclude(include);
  for (String exclude : excludes) fs.addExclude(exclude);
  return fileSetManager.getIncludedFiles(fs);
}
 
开发者ID:SumoLogic,项目名称:epigraph,代码行数:10,代码来源:AbstractCompilingMojo.java

示例12: getBundleSets

import org.apache.maven.shared.model.fileset.FileSet; //导入依赖的package包/类
protected synchronized List<BundleSet> getBundleSets() {
    if (bundleSets == null) {
        // default SourceBundleSet
        FileSet fs = new FileSet();
        fs.setDirectory("src/main/resources");
        fs.addInclude("**/*.properties");
        // Note: This exclusion pattern might be too aggressive...
        fs.addExclude("**/*_*.properties");
        bundleSets = Collections.singletonList(new BundleSet(fs));
    }
    return bundleSets;
}
 
开发者ID:IBM-Cloud,项目名称:gp-java-tools,代码行数:13,代码来源:GPBaseMojo.java

示例13: collectFiles

import org.apache.maven.shared.model.fileset.FileSet; //导入依赖的package包/类
/**
 * Collect file information in the directory (including subdirectories).  
 * @param fileSets FileSets containing the description of the directory to be scanned
 * @param baseDir project base directory used to construct the relative paths for the SPDX files 
 * @param pathPrefix Path string which should be removed when creating the SPDX file name
 * @param defaultFileInformation Information on default SPDX field data for the files
 * @param pathSpecificInformation Map of path to file information used to override the default file information
 * @param relationshipType Type of relationship to the project package 
 * @param projectPackage Package to which the files belong
 * @param container contains the extracted license infos that may be needed for license parsing
 * @throws SpdxCollectionException 
 */
public void collectFiles( FileSet[] fileSets,
                          String baseDir, SpdxDefaultFileInformation defaultFileInformation,
                          Map<String, SpdxDefaultFileInformation> pathSpecificInformation, 
                          SpdxPackage projectPackage, RelationshipType relationshipType,
                          SpdxDocumentContainer container) throws SpdxCollectionException 
{
   for ( int i = 0; i < fileSets.length; i++ ) 
   {
       String[] includedFiles = fileSetManager.getIncludedFiles( fileSets[i] );
       for ( int j = 0; j < includedFiles.length; j++ )
       {
           String filePath = fileSets[i].getDirectory() + File.separator + includedFiles[j];
           File file = new File( filePath );
           String relativeFilePath = file.getAbsolutePath().substring( baseDir.length() + 1 ).replace( '\\', '/' );;
           SpdxDefaultFileInformation fileInfo = findDefaultFileInformation( relativeFilePath, pathSpecificInformation );
           if ( fileInfo == null ) 
           {
               fileInfo = defaultFileInformation;
           }
           
           String outputFileName;
           if ( fileSets[i].getOutputDirectory() != null ) 
           {
               outputFileName = fileSets[i].getOutputDirectory() + File.separator + includedFiles[j];
           } else 
           {
               outputFileName = file.getAbsolutePath().substring( baseDir.length() + 1 );
           }
           collectFile( file, outputFileName, fileInfo, relationshipType, projectPackage, container );
       }
   }
}
 
开发者ID:spdx,项目名称:spdx-maven-plugin,代码行数:45,代码来源:SpdxFileCollector.java

示例14: getIncludedDirectoriesFromModel

import org.apache.maven.shared.model.fileset.FileSet; //导入依赖的package包/类
/**
 * Get filsets of files included in the project from the Maven model
 * @param model Maven model
 * @return Source file set and resource filesets
 */
@SuppressWarnings( "unused" )
private FileSet[] getIncludedDirectoriesFromModel( Model model ) 
{
    //TODO: This can be refactored to common code from the CreateSpdxMojo
    ArrayList<FileSet> result = new ArrayList<FileSet>();
    String sourcePath = model.getBuild().getSourceDirectory();
    if ( sourcePath != null && !sourcePath.isEmpty() ) {
        FileSet srcFileSet = new FileSet();
        File sourceDir = new File( sourcePath );
        srcFileSet.setDirectory( sourceDir.getAbsolutePath() );
        srcFileSet.addInclude( CreateSpdxMojo.INCLUDE_ALL );
        result.add( srcFileSet );  
    }
  
    List<Resource> resourceList = model.getBuild().getResources();
    if ( resourceList != null ) 
    {
        Iterator<Resource> resourceIter = resourceList.iterator();
        while ( resourceIter.hasNext() ) 
        {
            Resource resource = resourceIter.next();
            FileSet resourceFileSet = new FileSet();
            File resourceDir = new File( resource.getDirectory() );
            resourceFileSet.setDirectory( resourceDir.getAbsolutePath() );
            resourceFileSet.setExcludes( resource.getExcludes() );
            resourceFileSet.setIncludes( resource.getIncludes() );
            result.add( resourceFileSet );
        }
    }
    return result.toArray( new FileSet[result.size()] );
}
 
开发者ID:spdx,项目名称:spdx-maven-plugin,代码行数:37,代码来源:SpdxDependencyInformation.java

示例15: logIncludedDirectories

import org.apache.maven.shared.model.fileset.FileSet; //导入依赖的package包/类
/**
 * Primarily for debugging purposes - logs includedDirectories as info
 * @param includedDirectories
 */
private void logIncludedDirectories( FileSet[] includedDirectories ) 
{
    if ( includedDirectories == null ) {
        return;
    }
    this.getLog().debug( "Logging "+String.valueOf( includedDirectories.length ) + " filesets." );
    for ( int i = 0; i < includedDirectories.length; i++ ) 
    {
        StringBuilder sb = new StringBuilder( "Included Directory: "+includedDirectories[i].getDirectory() );
        @SuppressWarnings( "unchecked" )
        List<String> includes = includedDirectories[i].getIncludes();
        if ( includes != null && includes.size() > 0) 
        {                
            sb.append( "; Included=" );
            sb.append( includes.get( 0 ) );
            for ( int j = 1; j < includes.size(); j++ ) 
            {
                sb.append( "," );
                sb.append( includes.get(j) );
            }
        }
        @SuppressWarnings( "unchecked" )
        List<String> excludes = includedDirectories[i].getExcludes();
        if ( excludes != null && excludes.size() > 0 ) 
        {
            sb.append( "; Excluded=" );
            sb.append( excludes.get( 0 ) );
            for ( int j = 1; j < excludes.size(); j++ ) 
            {
                sb.append( "," );
                sb.append( excludes.get( j ) );
            }
        }
        this.getLog().debug( sb.toString() );
    }
}
 
开发者ID:spdx,项目名称:spdx-maven-plugin,代码行数:41,代码来源:CreateSpdxMojo.java


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