You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2006/06/28 17:29:04 UTC

svn commit: r417791 - in /maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar: AbstractJarMojo.java JarMojo.java TestJarMojo.java

Author: brett
Date: Wed Jun 28 08:29:04 2006
New Revision: 417791

URL: http://svn.apache.org/viewvc?rev=417791&view=rev
Log:
[MJAR-20] revert r417029 and re-opening, as it caused a regression (details in JIRA)

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

Modified: maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/AbstractJarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/AbstractJarMojo.java?rev=417791&r1=417790&r2=417791&view=diff
==============================================================================
--- maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/AbstractJarMojo.java (original)
+++ maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/AbstractJarMojo.java Wed Jun 28 08:29:04 2006
@@ -1,7 +1,7 @@
 package org.apache.maven.plugin.jar;
 
 /*
- * Copyright 2001-2006 The Apache Software Foundation.
+ * 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.
@@ -86,60 +86,16 @@
     private MavenProjectHelper projectHelper;
 
     /**
-     * Get the directory where the classes to be jarred are (the root of the archive)
-     * 
-     * @return the directory
+     * Return the specific output directory to serve as the root for the archive.
      */
     protected abstract File getClassesDirectory();
 
-    /**
-     * Set the directory where the classes to be jarred are
-     * 
-     * @param classesDirectory the directory
-     */
-    protected abstract void setClassesDirectory( File classesDirectory );
-
-    /**
-     * Set {@link JarArchiver} used to create the archive
-     * 
-     * @param jarArchiver
-     */
-    protected void setJarArchiver( JarArchiver jarArchiver )
-    {
-        this.jarArchiver = jarArchiver;
-    }
-
-    /**
-     * Get {@link JarArchiver} used to create the archive
-     * 
-     * @return the archiver
-     */
-    protected JarArchiver getJarArchiver()
-    {
-        return jarArchiver;
-    }
-
-    /**
-     * Get the {@link MavenProject} that will be used to gather the data needed
-     * 
-     * @return the maven project
-     */
     protected final MavenProject getProject()
     {
         return project;
     }
 
     /**
-     * Set the {@link MavenProject} whose data will be used in the archive
-     * 
-     * @param project
-     */
-    protected void setMavenProject( MavenProject project )
-    {
-        this.project = project;
-    }
-
-    /**
      * Overload this to produce a test-jar, for example.
      */
     protected abstract String getClassifier();
@@ -159,10 +115,9 @@
     }
 
     /**
-     * Generates the JAR. If contentDirectory does not exist the JAR won't be created.
+     * Generates the JAR.
      *
      * @todo Add license files in META-INF directory.
-     * @return the JAR file or <code>null</code> if contentDirectory does not exist
      */
     public File createArchive()
         throws MojoExecutionException
@@ -171,22 +126,21 @@
 
         MavenArchiver archiver = new MavenArchiver();
 
-        archiver.setArchiver( getJarArchiver() );
+        archiver.setArchiver( jarArchiver );
 
         archiver.setOutputFile( jarFile );
 
         try
         {
             File contentDirectory = getClassesDirectory();
-
             if ( !contentDirectory.exists() )
             {
-                getLog().warn( "Directory " + contentDirectory + " does not exist, not creating JAR file." );
-
-                return null;
+                getLog().warn( "JAR will be empty - no content was marked for inclusion!" );
+            }
+            else
+            {
+                archiver.getArchiver().addDirectory( contentDirectory, DEFAULT_INCLUDES, DEFAULT_EXCLUDES );
             }
-
-            archiver.getArchiver().addDirectory( contentDirectory, DEFAULT_INCLUDES, DEFAULT_EXCLUDES );
 
             archiver.createArchive( project, archive );
 
@@ -209,17 +163,14 @@
     {
         File jarFile = createArchive();
 
-        if ( jarFile != null )
+        String classifier = getClassifier();
+        if ( classifier != null )
         {
-            String classifier = getClassifier();
-            if ( classifier != null )
-            {
-                projectHelper.attachArtifact( getProject(), "jar", classifier, jarFile );
-            }
-            else
-            {
-                getProject().getArtifact().setFile( jarFile );
-            }
+            projectHelper.attachArtifact( getProject(), "jar", classifier, jarFile );
+        }
+        else
+        {
+            getProject().getArtifact().setFile( jarFile );
         }
     }
 }

Modified: maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarMojo.java?rev=417791&r1=417790&r2=417791&view=diff
==============================================================================
--- maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarMojo.java (original)
+++ maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarMojo.java Wed Jun 28 08:29:04 2006
@@ -50,13 +50,11 @@
         return classifier;
     }
 
+    /**
+     * Return the main classes directory, so it's used as the root of the jar.
+     */
     protected File getClassesDirectory()
     {
         return classesDirectory;
-    }
-
-    protected void setClassesDirectory( File classesDirectory )
-    {
-        this.classesDirectory = classesDirectory;
     }
 }

Modified: maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/TestJarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/TestJarMojo.java?rev=417791&r1=417790&r2=417791&view=diff
==============================================================================
--- maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/TestJarMojo.java (original)
+++ maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/TestJarMojo.java Wed Jun 28 08:29:04 2006
@@ -43,13 +43,11 @@
         return "tests";
     }
 
+    /**
+     * Return the test-classes directory, to serve as the root of the tests jar.
+     */
     protected File getClassesDirectory()
     {
         return testClassesDirectory;
-    }
-
-    protected void setClassesDirectory( File classesDirectory )
-    {
-        this.testClassesDirectory = classesDirectory;
     }
 }