maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: maven-components/maven-plugins/maven-assemble-plugin/src/main/java/org/apache/maven/plugin/assemble AssembleMojo.java
Date Mon, 21 Mar 2005 07:59:29 GMT
brett       2005/03/20 23:59:28

  Modified:    maven-plugins/maven-assemble-plugin/src/main/java/org/apache/maven/plugin/assemble
                        AssembleMojo.java
  Log:
  make the assembly mojo work, and use field type
  
  Revision  Changes    Path
  1.4       +51 -14    maven-components/maven-plugins/maven-assemble-plugin/src/main/java/org/apache/maven/plugin/assemble/AssembleMojo.java
  
  Index: AssembleMojo.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugins/maven-assemble-plugin/src/main/java/org/apache/maven/plugin/assemble/AssembleMojo.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AssembleMojo.java	18 Mar 2005 12:36:49 -0000	1.3
  +++ AssembleMojo.java	21 Mar 2005 07:59:28 -0000	1.4
  @@ -17,15 +17,14 @@
    */
   
   import org.apache.maven.plugin.AbstractPlugin;
  -import org.apache.maven.plugin.PluginExecutionRequest;
  -import org.apache.maven.plugin.PluginExecutionResponse;
  +import org.apache.maven.plugin.PluginExecutionException;
   import org.apache.maven.plugins.assemble.model.Assembly;
   import org.apache.maven.plugins.assemble.model.FileSet;
   import org.apache.maven.plugins.assemble.model.io.xpp3.AssemblyXpp3Reader;
   import org.codehaus.plexus.archiver.Archiver;
   import org.codehaus.plexus.archiver.jar.JarArchiver;
  -import org.codehaus.plexus.archiver.zip.ZipArchiver;
   import org.codehaus.plexus.archiver.tar.TarArchiver;
  +import org.codehaus.plexus.archiver.zip.ZipArchiver;
   
   import java.io.File;
   import java.io.FileReader;
  @@ -36,8 +35,8 @@
    * @version $Id$
    * @goal assemble
    * @description assemble an application bundle or distribution
  - * @parameter name="outputDirectory" type="String" required="true" validator="" expression="#project.build.directory"
description=""
  - * @parameter name="descriptor" type="String" required="true" validator="" expression="#maven.assemble.descriptor"
description=""
  + * @parameter name="outputDirectory" type="java.io.File" required="true" validator="" expression="#project.build.directory"
description=""
  + * @parameter name="descriptor" type="java.io.File" required="true" validator="" expression="#maven.assemble.descriptor"
description=""
    * @parameter name="finalName" type="String" required="true" validator="" expression="#project.build.finalName"
description=""
    */
   public class AssembleMojo
  @@ -45,16 +44,31 @@
   {
       private static final String[] EMPTY_STRING_ARRAY = {};
   
  -    public void execute( PluginExecutionRequest request, PluginExecutionResponse response
)
  -        throws Exception
  +    private File outputDirectory;
  +
  +    private File descriptor;
  +
  +    private String finalName;
  +
  +    public void execute()
  +        throws PluginExecutionException
       {
  -        // TODO: align all to basedir
  -        String outputDirectory = (String) request.getParameter( "outputDirectory" );
  -        String descriptor = (String) request.getParameter( "descriptor" );
  -        String finalName = (String) request.getParameter( "finalName" );
  +        try
  +        {
  +            doExecute();
  +        }
  +        catch ( Exception e )
  +        {
  +            // TODO: don't catch exception
  +            throw new PluginExecutionException( "Error creating assembly", e );
  +        }
  +    }
   
  +    private void doExecute()
  +        throws Exception
  +    {
           AssemblyXpp3Reader reader = new AssemblyXpp3Reader();
  -        Assembly assembly = reader.read( new FileReader( new File( descriptor ) ) );
  +        Assembly assembly = reader.read( new FileReader( descriptor ) );
   
           // TODO: include dependencies marked for distribution under certain formats
           // TODO: have a default set of descriptors that can be used instead of the file
  @@ -80,7 +94,21 @@
                   {
                       // TODO: this needs a cleanup in plexus archiver - use a real typesafe
enum
                       TarArchiver.TarCompressionMethod tarCompressionMethod = new TarArchiver.TarCompressionMethod();
  -                    tarCompressionMethod.setValue( format.substring( index + 1 ) );
  +                    // TODO: this should accept gz and bz2 as well so we can skip over
the switch
  +                    String compression = format.substring( index + 1 );
  +                    if ( compression.equals( "gz" ) )
  +                    {
  +                        tarCompressionMethod.setValue( "gzip" );
  +                    }
  +                    else if ( compression.equals( "bz2" ) )
  +                    {
  +                        tarCompressionMethod.setValue( "bzip2" );
  +                    }
  +                    else
  +                    {
  +                        // TODO: better handling
  +                        throw new IllegalArgumentException( "Unknown compression format:
" + compression );
  +                    }
                       tarArchiver.setCompression( tarCompressionMethod );
                   }
               }
  @@ -108,8 +136,17 @@
                   {
                       output = directory;
                   }
  +                if ( !output.endsWith( "/" ) && !output.endsWith( "\\" ) )
  +                {
  +                    // TODO: shouldn't archiver do this?
  +                    output += '/';
  +                }
   
                   String[] includes = (String[]) fileset.getIncludes().toArray( EMPTY_STRING_ARRAY
);
  +                if ( includes.length == 0 )
  +                {
  +                    includes = null;
  +                }
                   String[] excludes = (String[]) fileset.getExcludes().toArray( EMPTY_STRING_ARRAY
);
                   archiver.addDirectory( new File( directory ), output, includes, excludes
);
               }
  
  
  

Mime
View raw message