maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vsive...@apache.org
Subject svn commit: r659968 - in /maven/plugins/trunk/maven-javadoc-plugin: ./ src/main/java/org/apache/maven/plugin/javadoc/ src/test/java/org/apache/maven/plugin/javadoc/stubs/
Date Sun, 25 May 2008 11:49:36 GMT
Author: vsiveton
Date: Sun May 25 04:49:35 2008
New Revision: 659968

URL: http://svn.apache.org/viewvc?rev=659968&view=rev
Log:
MJAVADOC-187: Javadoc jar manifest should contain Specification and Implementation details

o added MavenArchiveConfiguration to create the file
o updated test case
o bumped to maven dep 2.0.9 due to tests errors
o bumped to p-u:1.4.9 (TODO bump to the last one)

Modified:
    maven/plugins/trunk/maven-javadoc-plugin/pom.xml
    maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocJar.java
    maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/JavadocJarDefaultMavenProjectStub.java
    maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/JavadocPluginArtifactStub.java

Modified: maven/plugins/trunk/maven-javadoc-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/pom.xml?rev=659968&r1=659967&r2=659968&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/pom.xml Sun May 25 04:49:35 2008
@@ -49,7 +49,7 @@
   </scm>
 
   <prerequisites>
-    <maven>2.0.8</maven>
+    <maven>2.0.9</maven>
   </prerequisites>
 
   <build>
@@ -95,32 +95,37 @@
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-project</artifactId>
-      <version>2.0.8</version>
+      <version>2.0.9</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-model</artifactId>
-      <version>2.0.8</version>
+      <version>2.0.9</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-settings</artifactId>
-      <version>2.0.8</version>
+      <version>2.0.9</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-api</artifactId>
-      <version>2.0.8</version>
+      <version>2.0.9</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.reporting</groupId>
       <artifactId>maven-reporting-api</artifactId>
-      <version>2.0.8</version>
+      <version>2.0.9</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-artifact</artifactId>
-      <version>2.0.8</version>
+      <version>2.0.9</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-archiver</artifactId>
+      <version>2.3</version>
     </dependency>
 
     <!-- Doxia -->
@@ -175,12 +180,15 @@
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-archiver</artifactId>
-      <version>1.0-alpha-7</version>
+      <version>1.0-alpha-9</version>
       <exclusions>
-        <!-- Using org.codehaus.plexus:plexus-utils instead of -->
         <exclusion>
-          <groupId>plexus</groupId>
-          <artifactId>plexus-utils</artifactId>
+          <groupId>org.codehaus.plexus</groupId>
+          <artifactId>plexus-container-default</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.codehaus.plexus</groupId>
+          <artifactId>plexus-component-api</artifactId>
         </exclusion>
       </exclusions>
     </dependency>
@@ -199,7 +207,7 @@
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
-      <version>1.4.6</version>
+      <version>1.4.9</version>
     </dependency>
 
     <dependency>

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocJar.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocJar.java?rev=659968&r1=659967&r2=659968&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocJar.java
(original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocJar.java
Sun May 25 04:49:35 2008
@@ -19,6 +19,9 @@
  * under the License.
  */
 
+import org.apache.maven.archiver.MavenArchiveConfiguration;
+import org.apache.maven.archiver.MavenArchiver;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
 import org.apache.maven.artifact.handler.ArtifactHandler;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProjectHelper;
@@ -26,6 +29,7 @@
 import org.apache.maven.model.Resource;
 import org.codehaus.plexus.archiver.ArchiverException;
 import org.codehaus.plexus.archiver.jar.JarArchiver;
+import org.codehaus.plexus.archiver.jar.ManifestException;
 
 import java.io.File;
 import java.io.IOException;
@@ -69,7 +73,7 @@
     private String finalName;
 
     /**
-     * Used for attaching the artifact in the project
+     * Used for attaching the artifact in the project.
      *
      * @component
      */
@@ -83,13 +87,48 @@
     private boolean attach;
 
     /**
+     * The archive configuration to use.
+     * See <a href="http://maven.apache.org/shared/maven-archiver/index.html">Maven
Archiver Reference</a>.
+     *
+     * @parameter
+     * @since 2.5
+     */
+    private MavenArchiveConfiguration archive = new MavenArchiveConfiguration();
+
+    /**
+     * The Jar archiver.
+     *
+     * @parameter expression="${component.org.codehaus.plexus.archiver.Archiver#jar}"
+     * @since 2.5
+     */
+    private JarArchiver jarArchiver;
+
+    /**
+     * Path to the default MANIFEST file to use. It will be used if
+     * <code>useDefaultManifestFile</code> is set to <code>true</code>.
+     *
+     * @parameter expression="${project.build.outputDirectory}/META-INF/MANIFEST.MF"
+     * @required
+     * @readonly
+     * @since 2.5
+     */
+    private File defaultManifestFile;
+
+    /**
+     * Set this to <code>true</code> to enable the use of the <code>defaultManifestFile</code>.
+     *
+     * @parameter default-value="false"
+     * @since 2.5
+     */
+    private boolean useDefaultManifestFile;
+
+    /**
      * @see org.apache.maven.reporting.AbstractMavenReport#execute()
      */
     public void execute()
         throws MojoExecutionException
     {
         File destDir = this.destDir;
-
         if ( destDir == null )
         {
             destDir = outputDirectory;
@@ -105,47 +144,51 @@
             {
                 getLog().info( "Not executing Javadoc as the project is not a Java classpath-capable
package" );
             }
+
+            return;
         }
-        else
+
+        try
         {
-            try
+            executeReport( Locale.getDefault() );
+
+            if ( destDir.exists() )
             {
-                executeReport( Locale.getDefault() );
+                File outputFile = generateArchive( destDir, finalName + "-javadoc.jar" );
 
-                if ( destDir.exists() )
+                if ( !attach )
                 {
-                    File outputFile = generateArchive( destDir, finalName + "-javadoc.jar"
);
-
-                    if ( !attach )
-                    {
-                        if ( getLog().isInfoEnabled() )
-                        {
-                            getLog().info( "NOT adding javadoc to attached artifacts list."
);
-                        }
-                    }
-                    else
+                    if ( getLog().isInfoEnabled() )
                     {
-                        // TODO: these introduced dependencies on the project are going to
become problematic - can we export it
-                        //  through metadata instead?
-                        projectHelper.attachArtifact( project, "javadoc", "javadoc", outputFile
);
+                        getLog().info( "NOT adding javadoc to attached artifacts list." );
                     }
                 }
+                else
+                {
+                    // TODO: these introduced dependencies on the project are going to become
problematic - can we export it
+                    //  through metadata instead?
+                    projectHelper.attachArtifact( project, "javadoc", "javadoc", outputFile
);
+                }
             }
-            catch ( ArchiverException e )
-            {
-                throw new MojoExecutionException( "Error while creating archive:" + e.getMessage(),
e );
-            }
-            catch ( IOException e )
-            {
-                throw new MojoExecutionException( "Error while creating archive:" + e.getMessage(),
e );
-            }
-            catch ( MavenReportException e )
-            {
-                throw new MojoExecutionException( "Error while creating archive:" + e.getMessage(),
e );
-            }
+        }
+        catch ( ArchiverException e )
+        {
+            throw new MojoExecutionException( "ArchiverException: Error while creating archive:"
+ e.getMessage(), e );
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "IOException: Error while creating archive:"
+ e.getMessage(), e );
+        }
+        catch ( MavenReportException e )
+        {
+            throw new MojoExecutionException( "MavenReportException: Error while creating
archive:" + e.getMessage(), e );
         }
     }
 
+    // ----------------------------------------------------------------------
+    // private methods
+    // ----------------------------------------------------------------------
+
     /**
      * Method that creates the jar file
      *
@@ -165,27 +208,51 @@
             javadocJar.delete();
         }
 
-        JarArchiver archiver = new JarArchiver();
+        MavenArchiver archiver = new MavenArchiver();
+        archiver.setArchiver( jarArchiver );
+        archiver.setOutputFile( javadocJar );
+
+        File contentDirectory = javadocFiles;
+        if ( !contentDirectory.exists() )
+        {
+            getLog().warn( "JAR will be empty - no content was marked for inclusion!" );
+        }
+        else
+        {
+            archiver.getArchiver().addDirectory( contentDirectory );
+        }
 
         List resources = project.getBuild().getResources();
 
         for ( Iterator i = resources.iterator(); i.hasNext(); )
         {
             Resource r = (Resource) i.next();
-
             if ( r.getDirectory().endsWith( "maven-shared-archive-resources" ) )
             {
-                archiver.addDirectory( new File( r.getDirectory() ) );
+                archiver.getArchiver().addDirectory( new File( r.getDirectory() ) );
             }
         }
 
-        //archiver.setDotFileDirectory( new File( project.getBuild().getDirectory() ) );
-
-        archiver.addDirectory( javadocFiles );
-
-        archiver.setDestFile( javadocJar );
+        if ( useDefaultManifestFile && defaultManifestFile.exists() && archive.getManifestFile()
== null )
+        {
+            getLog().info( "Adding existing MANIFEST to archive. Found under: " + defaultManifestFile.getPath()
);
+            archive.setManifestFile( defaultManifestFile );
+        }
 
-        archiver.createArchive();
+        try
+        {
+            // we dont want Maven stuff
+            archive.setAddMavenDescriptor( false );
+            archiver.createArchive( project, archive );
+        }
+        catch ( ManifestException e )
+        {
+            throw new ArchiverException( "ManifestException: " + e.getMessage(), e );
+        }
+        catch ( DependencyResolutionRequiredException e )
+        {
+            throw new ArchiverException( "DependencyResolutionRequiredException: " + e.getMessage(),
e );
+        }
 
         return javadocJar;
     }

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/JavadocJarDefaultMavenProjectStub.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/JavadocJarDefaultMavenProjectStub.java?rev=659968&r1=659967&r2=659968&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/JavadocJarDefaultMavenProjectStub.java
(original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/JavadocJarDefaultMavenProjectStub.java
Sun May 25 04:49:35 2008
@@ -25,6 +25,7 @@
 import org.apache.maven.model.Scm;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.project.MavenProject;
 
 import java.io.File;
 import java.io.FileReader;
@@ -50,7 +51,7 @@
         try
         {
             model = pomReader.read( new FileReader( new File( getBasedir() +
-                "/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml"
) ) );
+                "/src/test/resources/unit/javadocjar-default/javadocjar-default-plugin-config.xml"
) ) );
             setModel( model );
         }
         catch ( Exception e )
@@ -69,9 +70,11 @@
         scm.setConnection( "scm:svn:http://svn.apache.org/maven/sample/trunk" );
         setScm( scm );
 
-        Artifact artifact =
+        JavadocPluginArtifactStub artifact =
             new JavadocPluginArtifactStub( getGroupId(), getArtifactId(), getVersion(), getPackaging()
);
         artifact.setArtifactHandler( new DefaultArtifactHandlerStub() );
+        artifact.setType( "jar" );
+        artifact.setBaseVersion( "1.0-SNAPSHOT" );
         setArtifact( artifact );
 
         Build build = new Build();

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/JavadocPluginArtifactStub.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/JavadocPluginArtifactStub.java?rev=659968&r1=659967&r2=659968&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/JavadocPluginArtifactStub.java
(original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/JavadocPluginArtifactStub.java
Sun May 25 04:49:35 2008
@@ -38,6 +38,8 @@
 
     private String packaging;
 
+    private String baseVersion;
+
     private VersionRange versionRange;
 
     private ArtifactHandler handler;
@@ -110,4 +112,14 @@
     {
         this.handler = handler;
     }
+
+    public String getBaseVersion()
+    {
+        return baseVersion;
+    }
+
+    public void setBaseVersion( String string )
+    {
+        this.baseVersion = string;
+    }
 }



Mime
View raw message