You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2005/09/22 01:28:19 UTC

svn commit: r290859 - in /maven/components/trunk/maven-plugins/maven-assembly-plugin/src: main/java/org/apache/maven/plugin/assembly/ site/ site/apt/

Author: brett
Date: Wed Sep 21 16:28:09 2005
New Revision: 290859

URL: http://svn.apache.org/viewcvs?rev=290859&view=rev
Log:
PR: MNG-926
Submitted by: Allan Ramirez
Reviewed by:  Brett Porter
assembly plugin documentation

Added:
    maven/components/trunk/maven-plugins/maven-assembly-plugin/src/site/
    maven/components/trunk/maven-plugins/maven-assembly-plugin/src/site/apt/
    maven/components/trunk/maven-plugins/maven-assembly-plugin/src/site/apt/descriptor.apt
    maven/components/trunk/maven-plugins/maven-assembly-plugin/src/site/apt/howto.apt
    maven/components/trunk/maven-plugins/maven-assembly-plugin/src/site/apt/introduction.apt
    maven/components/trunk/maven-plugins/maven-assembly-plugin/src/site/site.xml   (with props)
Modified:
    maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AbstractUnpackingMojo.java
    maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AssemblyMojo.java
    maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/UnpackMojo.java

Modified: maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AbstractUnpackingMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AbstractUnpackingMojo.java?rev=290859&r1=290858&r2=290859&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AbstractUnpackingMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AbstractUnpackingMojo.java Wed Sep 21 16:28:09 2005
@@ -16,6 +16,9 @@
  * limitations under the License.
  */
 
+import org.apache.maven.plugin.AbstractMojo;
+import org.codehaus.plexus.util.IOUtil;
+
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -26,11 +29,8 @@
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
-import org.apache.maven.plugin.AbstractMojo;
-import org.codehaus.plexus.util.IOUtil;
-
 /**
- * Base routines for assembly and unpack goals
+ * Base routines for assembly and unpack goals.
  *
  * @version $Id$
  */
@@ -40,87 +40,119 @@
     static protected final String[] EMPTY_STRING_ARRAY = {};
 
     /**
+     * The output directory of the assembled distribution file.
+     *
      * @parameter expression="${project.build.directory}"
      * @required
      */
     protected File outputDirectory;
 
     /**
+     * The filename of the assembled distribution file.
+     *
      * @parameter expression="${project.build.finalName}"
      * @required
      */
     protected String finalName;
 
     /**
+     * Project dependencies.
+     *
      * @parameter expression="${project.artifacts}"
      * @readonly
      */
     protected Set dependencies;
 
     /**
-	 * Directory to unpack JARs into if needed
-	 * @parameter  expression="${project.build.directory}/assembly/work"
-	 * @required
-	 */
-	protected File workDirectory;
-
-	protected void unpack(File file, File location) throws IOException {
-		String fileName = file.getAbsolutePath().toLowerCase().trim();
-		// Should be checking for '.' too?
-		// Not doing this to be consistent with existing code
-		if ( fileName.endsWith( "jar" ) )
-		{
-			unpackJar( file, location );
-		}
-		else if( fileName.endsWith( "zip" ) )
-		{
-			unpackZip( file, location );
-		}
-	}
-
-	private void unpackJar( File file, File tempLocation )
-	    throws IOException
-	{
-	    if ( !file.getAbsolutePath().toLowerCase().trim().endsWith( "jar" ) )
-	    {
-	        getLog().warn( "Trying to unpack a non-jar file " + file.getAbsolutePath() + " - IGNORING" );
-	        return;
-	    }
-	
-	    JarFile jar = new JarFile( file );
-	    for ( Enumeration e = jar.entries(); e.hasMoreElements(); )
-	    {
-	        JarEntry entry = (JarEntry) e.nextElement();
-	
-	        if ( !entry.isDirectory() )
-	        {
-	            File outFile = new File( tempLocation, entry.getName() );
-	            outFile.getParentFile().mkdirs();
-	            IOUtil.copy( jar.getInputStream( entry ), new FileOutputStream( outFile ) );
-	        }
-	    }
-	}
-
-	private void unpackZip(File file, File tempLocation) throws IOException {
-	    if ( !file.getAbsolutePath().toLowerCase().trim().endsWith( "zip" ) )
-	    {
-	        getLog().warn( "Trying to unpack a non-zip file " + file.getAbsolutePath() + " - IGNORING" );
-	        return;
-	    }
-	
-	    ZipFile zip = new ZipFile( file );
-	    for ( Enumeration e = zip.entries(); e.hasMoreElements(); )
-	    {
-	        ZipEntry entry = (ZipEntry) e.nextElement();
-	
-	        if ( !entry.isDirectory() )
-	        {
-	            File outFile = new File( tempLocation, entry.getName() );
-	            outFile.getParentFile().mkdirs();
-	            IOUtil.copy( zip.getInputStream( entry ), new FileOutputStream( outFile ) );
-	        }
-	    }
-	}
+     * Directory to unpack JARs into if needed
+     *
+     * @parameter expression="${project.build.directory}/assembly/work"
+     * @required
+     */
+    protected File workDirectory;
+
+    /**
+     * Unpacks the archive file.
+     *
+     * @param file File to be unpacked.
+     * @param location Location where to put the unpacked files.
+     * @throws IOException
+     */
+    protected void unpack( File file, File location )
+        throws IOException
+    {
+        String fileName = file.getAbsolutePath().toLowerCase().trim();
+        // Should be checking for '.' too?
+        // Not doing this to be consistent with existing code
+        if ( fileName.endsWith( "jar" ) )
+        {
+            unpackJar( file, location );
+        }
+        else if ( fileName.endsWith( "zip" ) )
+        {
+            unpackZip( file, location );
+        }
+    }
+
+    /**
+     * Unpacks the Jar file.
+     *
+     * @param file File to be unpack/unjar.
+     * @param tempLocation Location where to put the unpacked files.
+     * @throws IOException
+     */
+    private void unpackJar( File file, File tempLocation )
+        throws IOException
+    {
+        if ( !file.getAbsolutePath().toLowerCase().trim().endsWith( "jar" ) )
+        {
+            getLog().warn( "Trying to unpack a non-jar file " + file.getAbsolutePath() + " - IGNORING" );
+            return;
+        }
+
+        JarFile jar = new JarFile( file );
+        for ( Enumeration e = jar.entries(); e.hasMoreElements(); )
+        {
+            JarEntry entry = (JarEntry) e.nextElement();
+
+            if ( !entry.isDirectory() )
+            {
+                File outFile = new File( tempLocation, entry.getName() );
+                outFile.getParentFile().mkdirs();
+                IOUtil.copy( jar.getInputStream( entry ), new FileOutputStream( outFile ) );
+            }
+        }
+    }
+
+    /**
+     * Unpacks the Zip file.
+     *
+     * @param file Zip file to be unpacked.
+     * @param tempLocation Location where to unpack the files.
+     * @throws IOException
+     */
+    private void unpackZip( File file, File tempLocation )
+        throws IOException
+    {
+        if ( !file.getAbsolutePath().toLowerCase().trim().endsWith( "zip" ) )
+        {
+            getLog().warn( "Trying to unpack a non-zip file " + file.getAbsolutePath() + " - IGNORING" );
+            return;
+        }
+
+        ZipFile zip = new ZipFile( file );
+        for ( Enumeration e = zip.entries(); e.hasMoreElements(); )
+        {
+            ZipEntry entry = (ZipEntry) e.nextElement();
+
+            if ( !entry.isDirectory() )
+            {
+                File outFile = new File( tempLocation, entry.getName() );
+                outFile.getParentFile().mkdirs();
+                IOUtil.copy( zip.getInputStream( entry ), new FileOutputStream( outFile ) );
+            }
+        }
+    }
 
 
 }

Modified: maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AssemblyMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AssemblyMojo.java?rev=290859&r1=290858&r2=290859&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AssemblyMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AssemblyMojo.java Wed Sep 21 16:28:09 2005
@@ -71,23 +71,31 @@
 {
 
     /**
+     * Predefined Assembly Descriptor Id's.  You can select bin, jar-with-dependencies, or src.
+     *
      * @parameter expression="${maven.assembly.descriptorId}"
      */
     protected String descriptorId;
 
     /**
+     * Assembly XML Descriptor file.  This must be the path to your customized descriptor file.
+     *
      * @parameter expression="${maven.assembly.descriptor}"
      */
     protected File descriptor;
 
     /**
+     * Base directory of the project.
+     *
      * @parameter expression="${basedir}"
      * @required
      * @readonly
      */
     private String basedir;
-    
+
     /**
+     * The Maven Project.
+     *
      * @parameter expression="${project}"
      * @required
      * @readonly
@@ -95,6 +103,8 @@
     private MavenProject project;
 
     /**
+     * Maven ProjectHelper
+     *
      * @parameter expression="${component.org.apache.maven.project.MavenProjectHelper}"
      * @required
      * @readonly
@@ -102,13 +112,19 @@
     private MavenProjectHelper projectHelper;
 
     /**
+     * Temporary directory that contain the files to be assembled.
+     *
      * @parameter expression="${project.build.directory}/archive-tmp"
      * @required
      * @readonly
      */
     private File tempRoot;
 
-
+    /**
+     * Create the binary distribution.
+     *
+     * @throws MojoExecutionException
+     */
     public void execute()
         throws MojoExecutionException
     {
@@ -123,11 +139,16 @@
         }
     }
 
+    /**
+     * Create the binary distribution.
+     *
+     * @throws ArchiverException, IOException, MojoExecutionException, XmlPullParserException
+     */
     private void doExecute()
         throws ArchiverException, IOException, MojoExecutionException, XmlPullParserException
     {
         Reader r = null;
-    
+
         if ( descriptor != null )
         {
             r = new FileReader( descriptor );
@@ -146,35 +167,35 @@
             // TODO: better exception
             throw new MojoExecutionException( "You must specify descriptor or descriptorId" );
         }
-    
+
         try
         {
             AssemblyXpp3Reader reader = new AssemblyXpp3Reader();
             Assembly assembly = reader.read( r );
-    
+
             // TODO: include dependencies marked for distribution under certain formats
             // TODO: how, might we plug this into an installer, such as NSIS?
             // TODO: allow file mode specifications?
-    
+
             String fullName = finalName + "-" + assembly.getId();
-    
+
             for ( Iterator i = assembly.getFormats().iterator(); i.hasNext(); )
             {
                 String format = (String) i.next();
-    
+
                 String filename = fullName + "." + format;
-    
+
                 // TODO: use component roles? Can we do that in a mojo?
                 Archiver archiver = createArchiver( format );
-    
+
                 processFileSets( archiver, assembly.getFileSets(), assembly.isIncludeBaseDirectory() );
                 processDependencySets( archiver, assembly.getDependencySets(), assembly.isIncludeBaseDirectory() );
-    
+
                 File destFile = new File( outputDirectory, filename );
                 archiver.setDestFile( destFile );
                 archiver.createArchive();
-                
-                projectHelper.attachArtifact(project, format, format + "-assembly", destFile );
+
+                projectHelper.attachArtifact( project, format, format + "-assembly", destFile );
             }
         }
         finally
@@ -183,6 +204,14 @@
         }
     }
 
+    /**
+     * Processes Dependency Sets
+     *
+     * @param archiver
+     * @param dependencySets
+     * @param includeBaseDirectory
+     * @throws ArchiverException, IOException, MojoExecutionException
+     */
     private void processDependencySets( Archiver archiver, List dependencySets, boolean includeBaseDirectory )
         throws ArchiverException, IOException, MojoExecutionException
     {
@@ -192,15 +221,13 @@
             String output = dependencySet.getOutputDirectory();
             output = getOutputDirectory( output, includeBaseDirectory );
 
-            archiver.setDefaultDirectoryMode( Integer.parseInt( 
-                    dependencySet.getDirectoryMode(), 8 ) );
+            archiver.setDefaultDirectoryMode( Integer.parseInt( dependencySet.getDirectoryMode(), 8 ) );
 
-            archiver.setDefaultFileMode( Integer.parseInt( 
-                    dependencySet.getFileMode(), 8 ) );
+            archiver.setDefaultFileMode( Integer.parseInt( dependencySet.getFileMode(), 8 ) );
 
-            getLog().debug("DependencySet["+output+"]" +
-                " dir perms: " + Integer.toString( archiver.getDefaultDirectoryMode(), 8 ) +
-                " file perms: " + Integer.toString( archiver.getDefaultFileMode(), 8 ) );
+            getLog().debug( "DependencySet[" + output + "]" + " dir perms: " +
+                Integer.toString( archiver.getDefaultDirectoryMode(), 8 ) + " file perms: " +
+                Integer.toString( archiver.getDefaultFileMode(), 8 ) );
 
             AndArtifactFilter filter = new AndArtifactFilter();
             filter.add( new ScopeArtifactFilter( dependencySet.getScope() ) );
@@ -222,7 +249,7 @@
                 if ( filter.include( artifact ) )
                 {
                     String name = artifact.getFile().getName();
-                    
+
                     if ( dependencySet.isUnpack() )
                     {
                         // TODO: something like zipfileset in plexus-archiver
@@ -254,10 +281,17 @@
                     }
                 }
             }
-        } 
+        }
     }
 
-
+    /**
+     * Process Files that will be included in the distribution.
+     *
+     * @param archiver
+     * @param fileSets
+     * @param includeBaseDirecetory
+     * @throws ArchiverException
+     */
     private void processFileSets( Archiver archiver, List fileSets, boolean includeBaseDirecetory )
         throws ArchiverException
     {
@@ -268,24 +302,22 @@
             String output = fileSet.getOutputDirectory();
 
             String lineEnding = getLineEndingCharacters( fileSet.getLineEnding() );
-            
+
             File tmpDir = null;
-                
+
             if ( lineEnding != null )
             {
                 tmpDir = FileUtils.createTempFile( "", "", tempRoot );
                 tmpDir.mkdirs();
             }
-            
-            archiver.setDefaultDirectoryMode( Integer.parseInt( 
-                    fileSet.getDirectoryMode(), 8 ) );
-
-            archiver.setDefaultFileMode( Integer.parseInt( 
-                    fileSet.getFileMode(), 8 ) );
-            
-            getLog().debug("FileSet["+output+"]" +
-                " dir perms: " + Integer.toString( archiver.getDefaultDirectoryMode(), 8 ) +
-                " file perms: " + Integer.toString( archiver.getDefaultFileMode(), 8 ) +
+
+            archiver.setDefaultDirectoryMode( Integer.parseInt( fileSet.getDirectoryMode(), 8 ) );
+
+            archiver.setDefaultFileMode( Integer.parseInt( fileSet.getFileMode(), 8 ) );
+
+            getLog().debug( "FileSet[" + output + "]" + " dir perms: " +
+                Integer.toString( archiver.getDefaultDirectoryMode(), 8 ) + " file perms: " +
+                Integer.toString( archiver.getDefaultFileMode(), 8 ) +
                 ( fileSet.getLineEnding() == null ? "" : " lineEndings: " + fileSet.getLineEnding() ) );
 
             if ( directory == null )
@@ -304,7 +336,7 @@
                 }
             }
             output = getOutputDirectory( output, includeBaseDirecetory );
-    
+
             String[] includes = (String[]) fileSet.getIncludes().toArray( EMPTY_STRING_ARRAY );
             if ( includes.length == 0 )
             {
@@ -315,10 +347,9 @@
             List excludesList = fileSet.getExcludes();
             excludesList.addAll( getDefaultExcludes() );
             String[] excludes = (String[]) excludesList.toArray( EMPTY_STRING_ARRAY );
-    
-            
+
             File archiveBaseDir = new File( directory );
-            
+
             if ( lineEnding != null )
             {
                 copySetReplacingLineEndings( archiveBaseDir, tmpDir, includes, excludes, lineEnding );
@@ -330,16 +361,23 @@
         }
     }
 
+    /**
+     * Evaluates Filename Mapping
+     *
+     * @param expression
+     * @param artifact
+     * @return expression
+     */
     private static String evaluateFileNameMapping( String expression, Artifact artifact )
         throws MojoExecutionException
     {
         // this matches the last ${...} string
         Pattern pat = Pattern.compile( "^(.*)\\$\\{([^\\}]+)\\}(.*)$" );
         Matcher mat = pat.matcher( expression );
-    
-        String left,right;
+
+        String left, right;
         Object middle;
-    
+
         if ( mat.matches() )
         {
             left = evaluateFileNameMapping( mat.group( 1 ), artifact );
@@ -347,12 +385,12 @@
             {
                 middle = ReflectionValueExtractor.evaluate( "dep." + mat.group( 2 ), artifact );
             }
-            catch (Exception e)
+            catch ( Exception e )
             {
-                throw new MojoExecutionException("Cannot evaluate filenameMapping", e);
+                throw new MojoExecutionException( "Cannot evaluate filenameMapping", e );
             }
             right = mat.group( 3 );
-    
+
             if ( middle == null )
             {
                 // TODO: There should be a more generic way dealing with that. Having magic words is not good at all.
@@ -367,20 +405,31 @@
                     middle = "${" + mat.group( 2 ) + "}";
                 }
             }
-    
+
             return left + middle + right;
         }
-    
+
         return expression;
     }
-    
+
+    /**
+     * Get the files to be excluded and put it into list.
+     *
+     * @return l List of filename patterns to be excluded.
+     */
     private static List getJarExcludes()
     {
         List l = new ArrayList( getDefaultExcludes() );
         l.add( "META-INF/**" );
         return l;
     }
-    
+
+    /**
+     * Get the Output Directory by parsing the String output directory.
+     *
+     * @param output The string representation of the output directory.
+     * @param includeBaseDirectory True if base directory is to be included in the assembled file.
+     */
     private String getOutputDirectory( String output, boolean includeBaseDirectory )
     {
         if ( output == null )
@@ -392,7 +441,7 @@
             // TODO: shouldn't archiver do this?
             output += '/';
         }
-    
+
         if ( includeBaseDirectory )
         {
             if ( output.startsWith( "/" ) )
@@ -413,7 +462,14 @@
         }
         return output;
     }
-    
+
+    /**
+     * Creates the necessary archiver to build the distribution file.
+     *
+     * @param format Archive format
+     * @return archiver  Archiver generated
+     * @throws ArchiverException
+     */
     private static Archiver createArchiver( String format )
         throws ArchiverException
     {
@@ -463,7 +519,12 @@
         }
         return archiver;
     }
-    
+
+    /**
+     * Insert into the exclude list the default excludes file pattern.
+     *
+     * @return defaultExcludes List containing the default patterns of files to be excluded.
+     */
     public static List getDefaultExcludes()
     {
         List defaultExcludes = new ArrayList();
@@ -472,40 +533,40 @@
         defaultExcludes.add( "**/.#*" );
         defaultExcludes.add( "**/%*%" );
         defaultExcludes.add( "**/._*" );
-    
+
         // CVS
         defaultExcludes.add( "**/CVS" );
         defaultExcludes.add( "**/CVS/**" );
         defaultExcludes.add( "**/.cvsignore" );
-    
+
         // SCCS
         defaultExcludes.add( "**/SCCS" );
         defaultExcludes.add( "**/SCCS/**" );
-    
+
         // Visual SourceSafe
         defaultExcludes.add( "**/vssver.scc" );
-    
+
         // Subversion
         defaultExcludes.add( "**/.svn" );
         defaultExcludes.add( "**/.svn/**" );
-    
+
         // Mac
         defaultExcludes.add( "**/.DS_Store" );
-    
+
         return defaultExcludes;
     }
-    
+
     private void copyReplacingLineEndings( File source, File dest, String lineEndings )
         throws IOException
     {
         getLog().debug( "Copying while replacing line endings: " + source + " to " + dest );
 
-        BufferedReader in = new BufferedReader( new FileReader ( source ) );
-        BufferedWriter out = new BufferedWriter ( new FileWriter( dest ) );
-        
+        BufferedReader in = new BufferedReader( new FileReader( source ) );
+        BufferedWriter out = new BufferedWriter( new FileWriter( dest ) );
+
         String line;
-        
-        while ( ( line = in.readLine()) != null )
+
+        while ( ( line = in.readLine() ) != null )
         {
             out.write( line );
             out.write( lineEndings );
@@ -514,8 +575,9 @@
         out.close();
     }
 
-    
-    private void copySetReplacingLineEndings( File archiveBaseDir, File tmpDir, String[] includes, String[] excludes, String lineEnding )
+
+    private void copySetReplacingLineEndings( File archiveBaseDir, File tmpDir, String[] includes, String[] excludes,
+                                              String lineEnding )
         throws ArchiverException
     {
         DirectoryScanner scanner = new DirectoryScanner();
@@ -523,36 +585,34 @@
         scanner.setIncludes( includes );
         scanner.setExcludes( excludes );
         scanner.scan();
-        
+
         String [] dirs = scanner.getIncludedDirectories();
-        
-        for ( int j = 0; j < dirs.length; j ++)
+
+        for ( int j = 0; j < dirs.length; j ++ )
         {
             new File( tempRoot, dirs[j] ).mkdirs();
         }
-    
+
         String [] files = scanner.getIncludedFiles();
-    
-        for ( int j = 0; j < files.length; j ++)
+
+        for ( int j = 0; j < files.length; j ++ )
         {
             File targetFile = new File( tmpDir, files[j] );
-    
+
             try
             {
                 targetFile.getParentFile().mkdirs();
 
                 copyReplacingLineEndings( new File( archiveBaseDir, files[j] ), targetFile, lineEnding );
             }
-            catch (IOException e)
+            catch ( IOException e )
             {
-                throw new ArchiverException("Error copying file '" +
-                    files[j] + "' to '" + targetFile + "'", e);
+                throw new ArchiverException( "Error copying file '" + files[j] + "' to '" + targetFile + "'", e );
             }
         }
 
-    }	
+    }
 
-    
     private static String getLineEndingCharacters( String lineEnding )
         throws ArchiverException
     {
@@ -572,13 +632,12 @@
             }
             else
             {
-                throw new ArchiverException( "Illlegal lineEnding specified: '" +
-                    lineEnding + "'");
+                throw new ArchiverException( "Illlegal lineEnding specified: '" + lineEnding + "'" );
             }
         }
-        
+
         return lineEnding;
     }
 
-    
+
 }

Modified: maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/UnpackMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/UnpackMojo.java?rev=290859&r1=290858&r2=290859&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/UnpackMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/UnpackMojo.java Wed Sep 21 16:28:09 2005
@@ -1,11 +1,11 @@
 package org.apache.maven.plugin.assembly;
 
-import java.io.File;
-import java.util.Iterator;
-
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.MojoExecutionException;
 
+import java.io.File;
+import java.util.Iterator;
+
 /*
  * Copyright 2001-2005 The Apache Software Foundation.
  *
@@ -33,27 +33,40 @@
 public class UnpackMojo
     extends AbstractUnpackingMojo
 {
-
-	public void execute() throws MojoExecutionException {
-	    try
-	    {
-	        doExecute();
-	    }
-	    catch ( Exception e )
-	    {
-	        // TODO: don't catch exception
-	        throw new MojoExecutionException( "Error unpacking", e );
-	    }
-	}
-
-	private void doExecute() throws Exception {
+    /**
+     * Unpacks the archive file.
+     *
+     * @throws MojoExecutionException
+     */
+    public void execute()
+        throws MojoExecutionException
+    {
+        try
+        {
+            doExecute();
+        }
+        catch ( Exception e )
+        {
+            // TODO: don't catch exception
+            throw new MojoExecutionException( "Error unpacking", e );
+        }
+    }
+
+    /**
+     * Unpacks the project dependencies.
+     *
+     * @throws Exception
+     */
+    private void doExecute()
+        throws Exception
+    {
 
         for ( Iterator j = dependencies.iterator(); j.hasNext(); )
         {
             Artifact artifact = (Artifact) j.next();
 
             String name = artifact.getFile().getName();
-            
+
             File tempLocation = new File( workDirectory, name.substring( 0, name.length() - 4 ) );
             boolean process = false;
             if ( !tempLocation.exists() )
@@ -68,9 +81,9 @@
 
             if ( process )
             {
-            	File file = artifact.getFile();
-            	unpack(file, tempLocation);
+                File file = artifact.getFile();
+                unpack( file, tempLocation );
             }
-        }            
-	}
+        }
+    }
 }

Added: maven/components/trunk/maven-plugins/maven-assembly-plugin/src/site/apt/descriptor.apt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-assembly-plugin/src/site/apt/descriptor.apt?rev=290859&view=auto
==============================================================================
--- maven/components/trunk/maven-plugins/maven-assembly-plugin/src/site/apt/descriptor.apt (added)
+++ maven/components/trunk/maven-plugins/maven-assembly-plugin/src/site/apt/descriptor.apt Wed Sep 21 16:28:09 2005
@@ -0,0 +1,93 @@
+ ------
+ Maven 2 Assembly Plugin 
+ ------
+ Johnny R. Ruiz III
+ <jr...@exist.com>
+ ------
+ September 20, 2005
+
+Pre-defined Descriptor Files
+
+*bin.xml    descriptorId:bin
+
+------
+    <assembly>
+      <id>bin</id>
+      <formats>
+        <format>tar.gz</format>
+        <format>tar.bz2</format>
+        <format>zip</format>
+      </formats>
+      <fileSets>
+        <fileSet>
+          <includes>
+            <include>README*</include>
+            <include>LICENSE*</include>
+            <include>NOTICE*</include>
+          </includes>
+        </fileSet>
+        <fileSet>
+          <directory>target</directory>
+          <outputDirectory></outputDirectory>
+          <includes>
+            <include>*.jar</include>
+          </includes>
+        </fileSet>
+      </fileSets>
+    </assembly>
+------
+
+*jar-with-dependencies.xml  descriptorId:jar-with-dependencies
+
+-----
+<assembly>
+  <id>jar-with-dependencies</id>
+  <formats>
+    <format>jar</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <fileSets>
+    <fileSet>
+      <directory>target/classes</directory>
+      <outputDirectory>/</outputDirectory>
+    </fileSet>
+  </fileSets>
+  <dependencySets>
+    <dependencySet>
+      <outputDirectory>/</outputDirectory>
+      <unpack>true</unpack>
+      <scope>runtime</scope>
+    </dependencySet>
+  </dependencySets>
+</assembly>
+-----
+
+*src.xml   descriptorId:xml
+
+-----
+<assembly>
+  <id>src</id>
+  <formats>
+    <format>tar.gz</format>
+    <format>tar.bz2</format>
+    <format>zip</format>
+  </formats>
+  <fileSets>
+    <fileSet>
+      <includes>
+        <include>README*</include>
+        <include>LICENSE*</include>
+        <include>NOTICE*</include>
+        <include>pom.xml</include>
+      </includes>
+    </fileSet>
+    <fileSet>
+      <directory>src</directory>
+    </fileSet>
+  </fileSets>
+</assembly>
+-----
+
+
+ 
+

Added: maven/components/trunk/maven-plugins/maven-assembly-plugin/src/site/apt/howto.apt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-assembly-plugin/src/site/apt/howto.apt?rev=290859&view=auto
==============================================================================
--- maven/components/trunk/maven-plugins/maven-assembly-plugin/src/site/apt/howto.apt (added)
+++ maven/components/trunk/maven-plugins/maven-assembly-plugin/src/site/apt/howto.apt Wed Sep 21 16:28:09 2005
@@ -0,0 +1,72 @@
+ ------
+ Maven 2 Assembly Plugin 
+ ------
+ Johnny R. Ruiz III
+ <jr...@exist.com>
+ ------
+ September 20, 2005
+
+How to Use
+
+  These is a brief example on how to use the assembly:assembly goal and assembly:unpack goal.  
+  
+  To use the assembly:assembly goal, you must define the descriptor file that you are going to use or 
+  define the descriptorId from the predefined {{{descriptor.html}descriptor ids}}.  
+
+
+* How To use assembly:assembly using a customized descriptor file.  
+
+-----
+  m2 assembly:assembly -Dmaven.assembly.descriptor=path/to/descriptor.xml
+-----
+
+ 
+* How to use assembly:assembly using predefined descriptor ids.
+
+----
+
+  m2 assembly:assembly -Dmaven.assembly.descriptorId=bin      
+
+  or  m2 assembly:assembly -Dmaven.assembly.descriptorId=jar-with-dependencies
+
+  or  m2 assembly:assembly -Dmaven.assembly.descriptorId=src
+
+-----
+
+* How to configure assembly:assembly plugin in pom.xml
+
+ You can also configure this plugin inside your pom.xml.  To run use "m2 assembly:assembly".
+
+-------------------
+<project>
+   ...
+      <build>
+         ...
+        <plugins>
+            <plugin>
+                 <artifactId>maven-assembly-plugin</artifactId>
+                 <version>2.0-beta-1</version>
+                 <configuration>
+                   <descriptor>path/to/descriptor.xml</descriptor>
+                   <finalName>final_name</finalName>
+                   <outputDirectory>output/directory</outputDirectory>
+                   <workDirectory>target/assembly/work</workDirectory>
+                 </configuration>
+            </plugin>
+         </plugins>
+         ...
+      </build>
+   ...
+</project>
+-------------------
+
+* How to use assembly:unpack
+
+  After running this goal, all dependencies will be extracted at the specified "\<workDirectory\>".
+
+-----
+ m2 assembly:unpack
+-----
+
+  For full documentation, click {{{index.html}here}}.
+ 

Added: maven/components/trunk/maven-plugins/maven-assembly-plugin/src/site/apt/introduction.apt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-assembly-plugin/src/site/apt/introduction.apt?rev=290859&view=auto
==============================================================================
--- maven/components/trunk/maven-plugins/maven-assembly-plugin/src/site/apt/introduction.apt (added)
+++ maven/components/trunk/maven-plugins/maven-assembly-plugin/src/site/apt/introduction.apt Wed Sep 21 16:28:09 2005
@@ -0,0 +1,23 @@
+ ------
+ Maven 2 Assembly Plugin 
+ ------
+ Johnny R. Ruiz III
+ <jr...@exist.com>
+ ------
+ September 20, 2005
+
+Introduction
+
+ This plugin is the Maven2 version of Maven1's Distribution Plugin.  
+ 
+ This plugin provides the capability to create a binary distribution and source distribution.  
+ Currently it can create distribution format such as: zip format, tar.bz, tar.gz2, jar format.
+ The goal to do this is "assembly:assembly".
+
+ It also provides the capability to extract all project dependencies on certain working directory.  
+ The goal to do this is "assembly:unpack".
+
+ To learn how to use the plugin, click {{{howto.html}here}}.
+
+ 
+

Added: maven/components/trunk/maven-plugins/maven-assembly-plugin/src/site/site.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-assembly-plugin/src/site/site.xml?rev=290859&view=auto
==============================================================================
--- maven/components/trunk/maven-plugins/maven-assembly-plugin/src/site/site.xml (added)
+++ maven/components/trunk/maven-plugins/maven-assembly-plugin/src/site/site.xml Wed Sep 21 16:28:09 2005
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!--
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+<project name="Maven Assembly Plugin">
+  <bannerLeft>
+    <name>Maven Assembly Plugin</name>
+    <src>http://maven.apache.org/images/apache-maven-project.png</src>
+    <href>http://maven.apache.org/</href>
+  </bannerLeft>
+  <bannerRight>
+    <src>http://maven.apache.org/images/maven-small.gif</src>
+  </bannerRight>
+  <body>
+    <links>
+      <item name="Maven 2" href="http://maven.apache.org/maven2/"/>
+    </links>
+
+    <menu name="Overview">
+      <item name="Introduction" href="introduction.html"/>
+      <item name="How to Use" href="howto.html"/>
+      <item name="Predefined Descriptors" href="descriptor.html"/>
+    </menu>
+    ${reports}
+  </body>
+</project>

Propchange: maven/components/trunk/maven-plugins/maven-assembly-plugin/src/site/site.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-plugins/maven-assembly-plugin/src/site/site.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org