bundle javadoc with java source releases

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@320991 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-10-14 03:50:52 +00:00
parent ca0e872a5a
commit 79058b9388
4 changed files with 94 additions and 19 deletions

View File

@ -2,13 +2,16 @@
<parent>
<artifactId>maven-plugin-parent</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<version>2.0-beta-1</version>
<version>2.0-beta-4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>maven-javadoc-plugin</artifactId>
<packaging>maven-plugin</packaging>
<name>Maven Javadoc Plugin</name>
<version>2.0-beta-2-SNAPSHOT</version>
<prerequisites>
<maven>2.0-beta-4-SNAPSHOT</maven>
</prerequisites>
<developers>
<developer>
<id>evenisse</id>
@ -41,10 +44,20 @@
<artifactId>plexus-archiver</artifactId>
<version>1.0-alpha-3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>2.0-beta-4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.0-beta-4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-impl</artifactId>
<version>2.0-beta-1</version>
<version>2.0-beta-4-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@ -16,8 +16,11 @@ package org.apache.maven.plugin.javadoc;
* limitations under the License.
*/
import org.apache.maven.artifact.handler.ArtifactHandler;
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.ArchiverException;
import org.codehaus.plexus.archiver.jar.JarArchiver;
@ -27,7 +30,7 @@ import java.io.IOException;
/**
* @goal jar
* @phase package
* @execute phase="javadoc:javadoc"
* @execute goal="javadoc"
*/
public class JavadocJar
extends AbstractMojo
@ -42,12 +45,47 @@ public class JavadocJar
*/
private String finalName;
/**
* @parameter expression="${project}"
* @readonly
* @required
*/
private MavenProject project;
/**
* @parameter expression="${component.org.apache.maven.project.MavenProjectHelper}
*/
private MavenProjectHelper projectHelper;
/**
* @parameter expression="${attach}" default-value="true"
*/
private boolean attach = true;
public void execute()
throws MojoExecutionException
{
ArtifactHandler artifactHandler = project.getArtifact().getArtifactHandler();
if ( !"java".equals( artifactHandler.getLanguage() ) || !artifactHandler.isAddedToClasspath() )
{
getLog().info( "Not executing Javadoc as the project is not a Java classpath-capable package" );
}
try
{
generateArchive( outputDirectory + "/javadoc", finalName + "-javadoc.jar" );
File outputFile = generateArchive( outputDirectory + "/javadoc", finalName + "-javadoc.jar" );
if ( !attach )
{
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 )
{
@ -59,7 +97,7 @@ public class JavadocJar
}
}
private void generateArchive( String source, String target )
private File generateArchive( String source, String target )
throws MojoExecutionException, ArchiverException, IOException
{
File javadocFiles = new File( source );
@ -83,5 +121,7 @@ public class JavadocJar
archiver.setDestFile( javadocJar );
archiver.createArchive();
return javadocJar;
}
}

View File

@ -20,6 +20,7 @@ import org.apache.commons.lang.ClassUtils;
import org.apache.commons.lang.SystemUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.model.Model;
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.AbstractMavenReport;
@ -600,6 +601,13 @@ public class JavadocReport
protected void executeReport( Locale locale )
throws MavenReportException
{
ArtifactHandler artifactHandler = project.getArtifact().getArtifactHandler();
if ( !"java".equals( artifactHandler.getLanguage() ) || !artifactHandler.isAddedToClasspath() )
{
getLog().info( "Not executing Javadoc as the project is not a Java classpath-capable package" );
return;
}
int actualYear = Calendar.getInstance().get( Calendar.YEAR );
String year = String.valueOf( actualYear );
@ -836,19 +844,19 @@ public class JavadocReport
addArgIf( arguments, serialwarn, "-serialwarn" );
addArgIf( arguments, splitindex, "-splitindex" );
addArgIfNotEmpty( arguments, "-stylesheetfile", quotedPathArgument( stylesheetfile ) );
addArgIfNotEmpty( arguments, "-tag", quotedArgument( tag ), 1.4f, true );
if ( tags != null && !tags.isEmpty() )
{
for ( Iterator it = tags.iterator(); it.hasNext(); )
{
String tag = (String) it.next();
addArgIfNotEmpty( arguments, "-tag", quotedArgument( tag ), 1.4f, true );
}
}
addArgIfNotEmpty( arguments, "-taglet", quotedArgument( taglet ), 1.4f );
addArgIfNotEmpty( arguments, "-tagletpath", quotedPathArgument( tagletpath ), 1.4f );
addArgIf( arguments, use, "-use" );
@ -1107,9 +1115,9 @@ public class JavadocReport
{
for ( int i = 0; i < offlineLinks.size(); i++ )
{
OfflineLink offlineLink = (OfflineLink)offlineLinks.get(i);
addArgIfNotEmpty( arguments, "-linkoffline",
quotedPathArgument( offlineLink.getUrl() ) + " " + quotedPathArgument( offlineLink.getLocation().getAbsolutePath() ), true );
OfflineLink offlineLink = (OfflineLink) offlineLinks.get( i );
addArgIfNotEmpty( arguments, "-linkoffline", quotedPathArgument( offlineLink.getUrl() ) + " " +
quotedPathArgument( offlineLink.getLocation().getAbsolutePath() ), true );
}
}
}
@ -1125,7 +1133,7 @@ public class JavadocReport
{
for ( int i = 0; i < links.size(); i++ )
{
addArgIfNotEmpty( arguments, "-link", quotedPathArgument( (String)links.get(i) ), true );
addArgIfNotEmpty( arguments, "-link", quotedPathArgument( (String) links.get( i ) ), true );
}
}
}

View File

@ -9,9 +9,9 @@
<name>Maven Repository Switchboard</name>
<layout>default</layout>
<url>http://www.ibiblio.org/maven2</url>
<!--
<url>http://repo1.maven.org/maven2</url>
-->
<!--
<url>http://repo1.maven.org/maven2</url>
-->
<snapshots>
<enabled>false</enabled>
</snapshots>
@ -23,9 +23,9 @@
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://www.ibiblio.org/maven2</url>
<!--
<url>http://repo1.maven.org/maven2</url>
-->
<!--
<url>http://repo1.maven.org/maven2</url>
-->
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
@ -83,6 +83,20 @@
</execution>
</executions>
</plugin>
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>