diff --git a/maven-plugins/maven-javadoc-plugin/pom.xml b/maven-plugins/maven-javadoc-plugin/pom.xml index d7d5de4f03..d4da922961 100644 --- a/maven-plugins/maven-javadoc-plugin/pom.xml +++ b/maven-plugins/maven-javadoc-plugin/pom.xml @@ -44,6 +44,16 @@ plexus plexus-utils + + plexus + plexus-archiver + 1.0-alpha-1 + + + plexus + plexus-container-default + 1.0-alpha-1 + diff --git a/maven-plugins/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocJar.java b/maven-plugins/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocJar.java new file mode 100644 index 0000000000..70da2d3007 --- /dev/null +++ b/maven-plugins/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocJar.java @@ -0,0 +1,87 @@ +package org.apache.maven.plugin.javadoc; + +/* + * Copyright 2004-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. + */ + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.codehaus.plexus.archiver.ArchiverException; +import org.codehaus.plexus.archiver.jar.JarArchiver; + +import java.io.File; +import java.io.IOException; + +/** + * @goal jar + * @phase package + * @execute phase="javadoc:javadoc" + */ +public class JavadocJar + extends AbstractMojo +{ + /** + * @parameter expression="${project.build.directory}" + */ + private String outputDirectory; + + /** + * @parameter expression="${project.build.finalName}" + */ + private String finalName; + + public void execute() + throws MojoExecutionException + { + try + { + generateArchive( outputDirectory + "/javadoc", finalName + "-javadoc.jar" ); + } + catch ( ArchiverException e ) + { + throw new MojoExecutionException( "Error while creating archive.", e ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Error while creating archive.", e ); + } + } + + private void generateArchive( String source, String target ) + throws MojoExecutionException, ArchiverException, IOException + { + File javadocFiles = new File( source ); + + if ( !javadocFiles.exists() ) + { + throw new MojoExecutionException( "javadoc files not found." ); + } + + File javadocJar = new File( outputDirectory, target ); + + if ( javadocJar.exists() ) + { + javadocJar.delete(); + } + + JarArchiver archiver = new JarArchiver(); + + archiver.addDirectory( javadocFiles ); + + archiver.setDestFile( javadocJar ); + + archiver.createArchive(); + } +} diff --git a/maven-plugins/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocReport.java b/maven-plugins/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocReport.java index 97caaa18d7..de2d48fb87 100644 --- a/maven-plugins/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocReport.java +++ b/maven-plugins/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocReport.java @@ -124,8 +124,7 @@ public class JavadocReport * Uses the sentence break iterator to determine the end of the first sentence. * See breakiterator. * - * @parameter expression="${breakiterator}" - * default-value="false" + * @parameter expression="${breakiterator}" default-value="false" */ private boolean breakiterator = false; @@ -197,8 +196,7 @@ public class JavadocReport * This option created documentation with the appearance and functionality of documentation generated by Javadoc 1.1. * See 1.1. * - * @parameter expression="${old}" - * default-value="false" + * @parameter expression="${old}" default-value="false" */ private boolean old = false; @@ -214,8 +212,7 @@ public class JavadocReport * Shows only protected and public classes and members. * See package. * - * @parameter expression="${package}" - * default-value="true" + * @parameter expression="${package}" default-value="true" */ private boolean showPackage = true; @@ -223,8 +220,7 @@ public class JavadocReport * Shows only protected and public classes and members. * See protected. * - * @parameter expression="${protected}" - * default-value="false" + * @parameter expression="${protected}" default-value="false" */ private boolean showProtected = false; @@ -232,8 +228,7 @@ public class JavadocReport * Shows all classes and members. * See private * - * @parameter expression="${private}" - * default-value="false" + * @parameter expression="${private}" default-value="false" */ private boolean showPrivate = false; @@ -241,8 +236,7 @@ public class JavadocReport * Shows only public classes and members. * See public. * - * @parameter expression="${public}" - * default-value="false" + * @parameter expression="${public}" default-value="false" */ private boolean public_ = false; @@ -250,8 +244,7 @@ public class JavadocReport * Shuts off non-error and non-warning messages, leaving only the warnings and errors appear, making them easier to view. * See quiet. * - * @parameter expression="${quiet}" - * default-value="false" + * @parameter expression="${quiet}" default-value="false" */ private boolean quiet = false; @@ -267,8 +260,7 @@ public class JavadocReport * Provides more detailed messages while javadoc is running. * See verbose. * - * @parameter expression="${verbose}" - * default-value="false" + * @parameter expression="${verbose}" default-value="false" */ private boolean verbose = false; @@ -278,8 +270,7 @@ public class JavadocReport * Specifies whether or not the author text is included in the generated Javadocs. * See author. * - * @parameter expression="${author}" - * default-value="true" + * @parameter expression="${author}" default-value="true" */ private boolean author = true; @@ -287,8 +278,7 @@ public class JavadocReport * Specifies the text to be placed at the bottom of each output file. * See bottom. * - * @parameter expression="${bottom}" - * default-value="Copyright ${project.inceptionYear-currentYear} ${project.organization.name}. All Rights Reserved." + * @parameter expression="${bottom}" default-value="Copyright ${project.inceptionYear-currentYear} ${project.organization.name}. All Rights Reserved." */ private String bottom; @@ -296,8 +286,7 @@ public class JavadocReport * Specifies the HTML character set for this document. * See charset. * - * @parameter expression="${charset}" - * default-value="ISO-8859-1" + * @parameter expression="${charset}" default-value="ISO-8859-1" */ private String charset = "ISO-8859-1"; @@ -305,8 +294,7 @@ public class JavadocReport * Specifies the destination directory where javadoc saves the generated HTML files. * See d. * - * @parameter expression="${destDir}" - * default-value="${project.build.directory}/site/apidocs" + * @parameter expression="${destDir}" default-value="${project.build.directory}/site/apidocs" */ private String destDir; @@ -314,8 +302,7 @@ public class JavadocReport * Enables deep copying of "doc-files" directories. * See docfilessubdirs. * - * @parameter expression="${docfilessubdirs}" - * default-value="false" + * @parameter expression="${docfilessubdirs}" default-value="false" */ private boolean docfilessubdirs = false; @@ -331,8 +318,7 @@ public class JavadocReport * Specifies the title to be placed near the top of the overview summary file. * See doctitle. * - * @parameter expression="${doctitle}" - * default-value="${windowtitle}" + * @parameter expression="${doctitle}" default-value="${project.name} ${project.version} API" */ private String doctitle; @@ -399,8 +385,7 @@ public class JavadocReport * Creates an HTML version of each source file (with line numbers) and adds links to them from the standard HTML documentation. * See linksource. * - * @parameter expression="${linksource}" - * default-value="false" + * @parameter expression="${linksource}" default-value="false" */ private boolean linksource = false; @@ -408,8 +393,7 @@ public class JavadocReport * Suppress the entire comment body, including the main description and all tags, generating only declarations. * Ssee nocomment. * - * @parameter expression="${nocomment}" - * default-value="false" + * @parameter expression="${nocomment}" default-value="false" */ private boolean nocomment = false; @@ -417,8 +401,7 @@ public class JavadocReport * Prevents the generation of any deprecated API at all in the documentation. * See nodeprecated. * - * @parameter expression="${nodeprecated}" - * default-value="false" + * @parameter expression="${nodeprecated}" default-value="false" */ private boolean nodeprecated = false; @@ -426,8 +409,7 @@ public class JavadocReport * Prevents the generation of the file containing the list of deprecated APIs (deprecated-list.html) and the link in the navigation bar to that page. * See nodeprecatedlist. * - * @parameter expression="${nodeprecatedlist}" - * default-value="false" + * @parameter expression="${nodeprecatedlist}" default-value="false" */ private boolean nodeprecatedlist = false; @@ -435,8 +417,7 @@ public class JavadocReport * Omits the HELP link in the navigation bars at the top and bottom of each page of output. * See nohelp. * - * @parameter expression="${nohelp}" - * default-value="false" + * @parameter expression="${nohelp}" default-value="false" */ private boolean nohelp = false; @@ -444,8 +425,7 @@ public class JavadocReport * Omits the index from the generated docs. * See noindex. * - * @parameter expression="${noindex}" - * default-value="false" + * @parameter expression="${noindex}" default-value="false" */ private boolean noindex = false; @@ -453,8 +433,7 @@ public class JavadocReport * Omits the index from the generated docs. The default value is 'false'. * See nonavbar. * - * @parameter expression="${nonavbar}" - * default-value="false" + * @parameter expression="${nonavbar}" default-value="false" */ private boolean nonavbar = false; @@ -470,8 +449,7 @@ public class JavadocReport * Omits from the generated docs the "Since" sections associated with the since tags. * See nosince. * - * @parameter expression="${nosince}" - * default-value="false" + * @parameter expression="${nosince}" default-value="false" */ private boolean nosince = false; @@ -479,8 +457,7 @@ public class JavadocReport * Omits the class/interface hierarchy pages from the generated docs. * See notree. * - * @parameter expression="${notree}" - * default-value="false" + * @parameter expression="${notree}" default-value="false" */ private boolean notree = false; @@ -488,8 +465,7 @@ public class JavadocReport * Generates compile-time warnings for missing serial tags. * See serialwarn * - * @parameter expression="${serialwarn}" - * default-value="false" + * @parameter expression="${serialwarn}" default-value="false" */ private boolean serialwarn = false; @@ -498,8 +474,7 @@ public class JavadocReport * start with non-alphabetical characters. * See splitindex. * - * @parameter expression="${splitindex}" - * default-value="false" + * @parameter expression="${splitindex}" default-value="false" */ private boolean splitindex = false; @@ -540,8 +515,7 @@ public class JavadocReport * Includes one "Use" page for each documented class and package. * See use. * - * @parameter expression="${use}" - * default-value="true" + * @parameter expression="${use}" default-value="true" */ private boolean use = true; @@ -549,8 +523,7 @@ public class JavadocReport * Includes the version text in the generated docs. * See version. * - * @parameter expression="${version}" - * default-value="true" + * @parameter expression="${version}" default-value="true" */ private boolean version = true; @@ -559,8 +532,7 @@ public class JavadocReport * The default is '${project.name} ${project.version} API'. * See windowtitle. * - * @parameter expression="${windowtitle}" - * default-value="${project.name} ${project.version} API" + * @parameter expression="${windowtitle}" default-value="${project.name} ${project.version} API" */ private String windowtitle;