org.codehaus.plexus.archiver.util.DefaultFileSet Java Examples

The following examples show how to use org.codehaus.plexus.archiver.util.DefaultFileSet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DockerAssemblyManager.java    From docker-maven-plugin with Apache License 2.0 6 votes vote down vote up
private TarArchiver createBuildArchiver(File outputDir, File archive, AssemblyConfiguration assemblyConfig) throws NoSuchArchiverException {
    TarArchiver archiver = (TarArchiver) archiverManager.getArchiver("tar");
    archiver.setLongfile(TarLongFileMode.posix);

    AssemblyMode mode = assemblyConfig != null ? assemblyConfig.getMode() : null;
    if (mode != null && mode.isArchive()) {
        DefaultArchivedFileSet archiveSet =
                DefaultArchivedFileSet.archivedFileSet(new File(outputDir,  assemblyConfig.getName() + "." + mode.getExtension()));
        archiveSet.setPrefix(assemblyConfig.getName() + "/");
        archiveSet.setIncludingEmptyDirectories(true);
        archiveSet.setUsingDefaultExcludes(false);
        archiver.addArchivedFileSet(archiveSet);
    } else {
        DefaultFileSet fileSet = DefaultFileSet.fileSet(outputDir);
        fileSet.setUsingDefaultExcludes(false);
        archiver.addFileSet(fileSet);
    }
    archiver.setDestFile(archive);
    return archiver;
}
 
Example #2
Source File: NativeJavahMojo.java    From maven-native with MIT License 5 votes vote down vote up
private void attachGeneratedIncludeFilesAsIncZip()
    throws MojoExecutionException
{
    try
    {
        ZipArchiver archiver = new ZipArchiver();
        DefaultFileSet fileSet = new DefaultFileSet();
        fileSet.setUsingDefaultExcludes( true );
        fileSet.setDirectory( javahOutputDirectory );
        archiver.addFileSet( fileSet );
        archiver.setDestFile( this.incZipFile );
        archiver.createArchive();

        if ( StringUtils.isBlank( this.classifier ) )
        {
            projectHelper.attachArtifact( this.project, INCZIP_TYPE, null, this.incZipFile );
        }
        else
        {
            projectHelper.attachArtifact( this.project, INCZIP_TYPE, this.classifier, this.incZipFile );
        }
    }
    catch ( Exception e )
    {
        throw new MojoExecutionException( "Unable to archive/deploy generated include files", e );
    }
}
 
Example #3
Source File: DockerAssemblyManager.java    From docker-maven-plugin with Apache License 2.0 5 votes vote down vote up
private void excludeDockerfile(DefaultFileSet fileSet, File dockerFile) {
    ArrayList<String> excludes =
        fileSet.getExcludes() != null ?
            new ArrayList<>(Arrays.asList(fileSet.getExcludes())) :
            new ArrayList<String>();
    excludes.add(dockerFile.getName());
    fileSet.setExcludes(excludes.toArray(new String[0]));
}
 
Example #4
Source File: DockerAssemblyManager.java    From docker-maven-plugin with Apache License 2.0 5 votes vote down vote up
private void addDockerExcludes(DefaultFileSet fileSet, MojoParameters params) throws IOException {
    File directory = fileSet.getDirectory();
    List<String> excludes = new ArrayList<>();
    // Output directory will be always excluded
    excludes.add(params.getOutputDirectory() + "/**");
    for (String file : new String[] { DOCKER_EXCLUDE, DOCKER_IGNORE } ) {
        File dockerIgnore = new File(directory, file);
        if (dockerIgnore.exists()) {
            excludes.addAll(Arrays.asList(FileUtils.fileReadArray(dockerIgnore)));
            excludes.add(DOCKER_IGNORE);
        }
    }
    fileSet.setExcludes(excludes.toArray(new String[0]));
}
 
Example #5
Source File: DockerAssemblyManager.java    From docker-maven-plugin with Apache License 2.0 5 votes vote down vote up
private void addDockerIncludes(DefaultFileSet fileSet) throws IOException {
    File directory = fileSet.getDirectory();
    File dockerInclude = new File(directory, DOCKER_INCLUDE);
    if (dockerInclude.exists()) {
        ArrayList<String> includes = new ArrayList<>(Arrays.asList(FileUtils.fileReadArray(dockerInclude)));
        fileSet.setIncludes(includes.toArray(new String[0]));
    }
}
 
Example #6
Source File: NativeBundleIncludeFilesMojo.java    From maven-native with MIT License 4 votes vote down vote up
public void execute()
    throws MojoExecutionException
{
    if ( skipIncludeDeployment )
    {
        return;
    }

    if ( this.sources.length != 0 )
    {
        try
        {
            ZipArchiver archiver = new ZipArchiver();

            boolean zipIt = false;
            for ( int i = 0; i < sources.length; ++i )
            {
                if ( sources[i].isDeployable() )
                {
                    DefaultFileSet fileSet = new DefaultFileSet();
                    fileSet.setUsingDefaultExcludes( true );
                    fileSet.setDirectory( sources[i].getDirectory() );
                    fileSet.setIncludes( sources[i].getIncludes() );
                    fileSet.setExcludes( sources[i].getExcludes() );
                    archiver.addFileSet( fileSet );
                    zipIt = true;
                }
            }

            if ( zipIt )
            {
                archiver.setDestFile( this.incZipFile );
                archiver.createArchive();
                projectHelper.attachArtifact( this.project, INCZIP_TYPE, null, this.incZipFile );
            }
        }
        catch ( Exception e )
        {
            throw new MojoExecutionException( e.getMessage(), e );
        }
    }
}
 
Example #7
Source File: DockerAssemblyManager.java    From docker-maven-plugin with Apache License 2.0 4 votes vote down vote up
private void addDockerIncludesExcludesIfPresent(DefaultFileSet fileSet, MojoParameters params) throws IOException {
    addDockerExcludes(fileSet, params);
    addDockerIncludes(fileSet);
}