Java Code Examples for org.codehaus.plexus.archiver.util.DefaultFileSet#setDirectory()

The following examples show how to use org.codehaus.plexus.archiver.util.DefaultFileSet#setDirectory() . 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: 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 2
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 );
        }
    }
}