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/10/04 07:44:09 UTC

svn commit: r293542 - in /maven/components/trunk: maven-model/ maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/

Author: brett
Date: Mon Oct  3 22:43:58 2005
New Revision: 293542

URL: http://svn.apache.org/viewcvs?rev=293542&view=rev
Log:
PR: MNG-816
allow attachment of another jar during the build process

Modified:
    maven/components/trunk/maven-model/pom.xml
    maven/components/trunk/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/AbstractJarMojo.java
    maven/components/trunk/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarMojo.java
    maven/components/trunk/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/TestJarMojo.java

Modified: maven/components/trunk/maven-model/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-model/pom.xml?rev=293542&r1=293541&r2=293542&view=diff
==============================================================================
--- maven/components/trunk/maven-model/pom.xml (original)
+++ maven/components/trunk/maven-model/pom.xml Mon Oct  3 22:43:58 2005
@@ -36,7 +36,6 @@
     <profile>
       <id>all-models</id>
       <build>
-        <finalName>${pom.artifactId}-${pom.version}-all</finalName>
         <plugins>
           <plugin>
             <groupId>org.codehaus.modello</groupId>
@@ -57,6 +56,20 @@
               </execution>
             </executions>
           </plugin>
+          <plugin>
+            <artifactId>maven-jar-plugin</artifactId>
+            <executions>
+              <execution>
+                <phase>package</phase>
+                <configuration>
+                  <classifier>all</classifier>
+                </configuration>
+                <goals>
+                  <goal>jar</goal>
+                </goals>
+              </execution>
+           </executions> 
+         </plugin>
         </plugins>
       </build>
     </profile>

Modified: maven/components/trunk/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/AbstractJarMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/AbstractJarMojo.java?rev=293542&r1=293541&r2=293542&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/AbstractJarMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/AbstractJarMojo.java Mon Oct  3 22:43:58 2005
@@ -21,13 +21,14 @@
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectHelper;
 import org.codehaus.plexus.archiver.jar.JarArchiver;
 
 import java.io.File;
 
 /**
  * Base class for creating a jar from project classes.
- * 
+ *
  * @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
  * @version $Id$
  */
@@ -45,7 +46,6 @@
      * @parameter expression="${project.build.directory}"
      * @required
      * @readonly
-     *
      * @todo Change type to File
      */
     private String basedir;
@@ -81,24 +81,26 @@
      * @parameter
      */
     private MavenArchiveConfiguration archive = new MavenArchiveConfiguration();
-    
+
+    /**
+     * @component
+     */
+    private MavenProjectHelper projectHelper;
+
     /**
      * Return the specific output directory to serve as the root for the archive.
      */
     protected abstract File getOutputDirectory();
-    
+
     protected final MavenProject getProject()
     {
         return project;
     }
-    
+
     /**
      * Overload this to produce a test-jar, for example.
      */
-    protected String getClassifier()
-    {
-        return "";
-    }
+    protected abstract String getClassifier();
 
     /**
      * Generates the JAR.
@@ -109,7 +111,7 @@
         throws MojoExecutionException
     {
         String classifier = getClassifier();
-        
+
         if ( classifier == null )
         {
             classifier = "";
@@ -118,7 +120,7 @@
         {
             classifier = "-" + classifier;
         }
-        
+
         File jarFile = new File( basedir, finalName + classifier + ".jar" );
 
         MavenArchiver archiver = new MavenArchiver();
@@ -140,13 +142,34 @@
             }
 
             archiver.createArchive( project, archive );
-            
+
             return jarFile;
         }
         catch ( Exception e )
         {
             // TODO: improve error handling
             throw new MojoExecutionException( "Error assembling JAR", e );
+        }
+    }
+
+    /**
+     * Generates the JAR.
+     *
+     * @todo Add license files in META-INF directory.
+     */
+    public void execute()
+        throws MojoExecutionException
+    {
+        File jarFile = createArchive();
+
+        String classifier = getClassifier();
+        if ( classifier != null )
+        {
+            projectHelper.attachArtifact( getProject(), "jar", classifier, jarFile );
+        }
+        else
+        {
+            getProject().getArtifact().setFile( jarFile );
         }
     }
 }

Modified: maven/components/trunk/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarMojo.java?rev=293542&r1=293541&r2=293542&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarMojo.java Mon Oct  3 22:43:58 2005
@@ -42,16 +42,15 @@
     private File outputDirectory;
 
     /**
-	 * Generates the JAR.
+     * Classifier to add to the artifact generated. If given, the artifact will be an attachment instead.
      *
-     * @todo Add license files in META-INF directory.
+     * @parameter
      */
-    public void execute()
-        throws MojoExecutionException
+    private String classifier;
+
+    protected String getClassifier()
     {
-        File jarFile = createArchive();
-        
-        getProject().getArtifact().setFile( jarFile );
+        return classifier;
     }
 
     /**

Modified: maven/components/trunk/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/TestJarMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/TestJarMojo.java?rev=293542&r1=293541&r2=293542&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/TestJarMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/TestJarMojo.java Mon Oct  3 22:43:58 2005
@@ -42,29 +42,9 @@
      */
     private File testOutputDirectory;
 
-    /**
-     * @component role="org.apache.maven.project.MavenProjectHelper"
-     */
-    private MavenProjectHelper projectHelper;
-
     protected String getClassifier()
     {
         return "tests";
-    }
-
-    /**
-     * Generates the JAR.
-     *
-     * @todo Add license files in META-INF directory.
-     */
-    public void execute()
-        throws MojoExecutionException
-    {
-        getLog().info( "Creating a jar containing the test classes for this project." );
-
-        File jarFile = createArchive();
-
-        projectHelper.attachArtifact( getProject(), "jar", "tests", jarFile );
     }
 
     /**



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