maven-plugins/javadoc/plugin.jelly
aheritier bdf9499354 - Fix MPJAVADOC-40
- Fix the init that was done several times (because there was dots in the var)


git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@116002 13f79535-47bb-0310-9956-ffa450edef68
2004-08-25 19:48:48 +00:00

593 lines
24 KiB
XML

<?xml version="1.0"?>
<!--
/*
* Copyright 2001-2004 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.
*/
-->
<project
xmlns:ant="jelly:ant"
xmlns:define="jelly:define"
xmlns:doc="doc"
xmlns:j="jelly:core"
xmlns:util="jelly:util"
xmlns:artifact="artifact"
xmlns:javadoc="javadoc"
xmlns:maven="jelly:maven"
>
<!-- ================================================================== -->
<!-- Test if we need to call javadoc -->
<!-- ================================================================== -->
<define:taglib uri="javadoc">
<define:tag name="init">
<j:if test="${empty(internal_javadoc_needed)}">
<j:if test="${maven.javadoc.debug}"><ant:echo>javadoc init</ant:echo></j:if>
<!-- internal variables -->
<j:set scope="parent" var="internal_javadoc_jar" value="${maven.build.dir}/${maven.final.name}_javadoc.jar"/>
<j:set scope="parent" var="internal_javadoc_working_dir" value="${maven.build.dir}/javadoc"/>
<j:set scope="parent" var="internal_javadoc_src_tmp" value="${internal_javadoc_working_dir}/src"/>
<j:if test="${maven.javadoc.debug}">
<ant:echo>
### Debug mode is on ###
==================================
=== java plugin properties ===
==================================
maven.compile.encoding = [${maven.compile.encoding}]
maven.compile.src.set = [${context.getAntProject().getReferences().get('maven.compile.src.set')}]
==================================
=== docs properties ===
==================================
maven.docs.outputencoding = [${maven.docs.outputencoding}]
==================================
=== javadoc plugin properties ===
==================================
maven.javadoc.additionalparam = [${maven.javadoc.additionalparam}]
maven.javadoc.author = [${maven.javadoc.author}]
maven.javadoc.customtags = [${maven.javadoc.customtags}]
maven.javadoc.bottom = [${maven.javadoc.bottom}]
maven.javadoc.debug = [${maven.javadoc.debug}]
maven.javadoc.destdir = [${maven.javadoc.destdir}]
maven.javadoc.doclet = [${maven.javadoc.doclet}]
maven.javadoc.docletpath = [${maven.javadoc.docletpath}]
maven.javadoc.excludepackagenames = [${maven.javadoc.excludepackagenames}]
maven.javadoc.links = [${maven.javadoc.links}]
maven.javadoc.locale = [${maven.javadoc.locale}]
maven.javadoc.maxmemory = [${maven.javadoc.maxmemory}]
maven.javadoc.mode.online = [${maven.javadoc.mode.online}]
maven.javadoc.offlineLinks = [${maven.javadoc.offlineLinks}]
maven.javadoc.overview = [${maven.javadoc.overview}]
maven.javadoc.package = [${maven.javadoc.package}]
maven.javadoc.private = [${maven.javadoc.private}]
maven.javadoc.public = [${maven.javadoc.public}]
maven.javadoc.source = [${maven.javadoc.source}]
maven.javadoc.stylesheet = [${maven.javadoc.stylesheet}]
maven.javadoc.tagletpath = [${maven.javadoc.tagletpath}]
maven.javadoc.taglets = [${maven.javadoc.taglets}]
maven.javadoc.use = [${maven.javadoc.use}]
maven.javadoc.useexternalfile = [${maven.javadoc.useexternalfile}]
maven.javadoc.version = [${maven.javadoc.version}]
maven.javadoc.windowtitle = [${maven.javadoc.windowtitle}]
==================================
=== Project descriptor ===
==================================
pom.package = [${pom.package}]
==================================
=== javadoc internal variables ===
==================================
internal_javadoc_jar = [${internal_javadoc_jar}]
internal_javadoc_needed = [${internal_javadoc_needed}]
internal_javadoc_working_dir = [${internal_javadoc_working_dir}]
</ant:echo>
</j:if>
<j:if test="not ${maven.javadoc.debug}">
<ant:echo>
### Debug mode is off ###
</ant:echo>
</j:if>
<ant:mkdir dir="${internal_javadoc_working_dir}"/>
<ant:mkdir dir="${internal_javadoc_src_tmp}"/>
<j:set var="internal_javadoc_needed" scope="parent" value="false" />
<!-- test if sourceModifications are defined -->
<j:if test="${not empty(pom.build.sourceModifications)}">
<j:if test="${maven.javadoc.debug}"><ant:echo>sourceModifications used.</ant:echo></j:if>
<util:tokenize var="sources_dirs" delim="${path.separator}">${context.getAntProject().getReferences().get('maven.compile.src.set')}</util:tokenize>
<ant:copy todir="${internal_javadoc_src_tmp}">
<j:forEach var="dir" items="${sources_dirs}">
<ant:fileset dir="${dir}">
<ant:include name="**/*.java"/>
<ant:include name="**/doc-files/**/*"/>
<!-- handle source modifications -->
<j:forEach var="sm" items="${pom.build.sourceModifications}">
<ant:available property="classPresent" classname="${sm.className}"/>
<j:if test="${classPresent != 'true'}">
<j:forEach var="exclude" items="${sm.excludes}">
<ant:exclude name="${exclude}"/>
</j:forEach> <!-- end sourceModification exclude -->
<j:forEach var="include" items="${sm.includes}">
<ant:include name="${include}"/>
</j:forEach> <!-- end sourceModification include -->
</j:if>
</j:forEach> <!-- end sourceModification -->
</ant:fileset>
</j:forEach>
</ant:copy>
<ant:path id="internal_javadoc_sources">
<ant:pathelement location="${internal_javadoc_src_tmp}"/>
</ant:path>
</j:if>
<!-- test if sourceModifications aren't defined -->
<j:if test="${empty(pom.build.sourceModifications)}">
<j:if test="${maven.javadoc.debug}"><ant:echo>sourceModifications not used.</ant:echo></j:if>
<ant:path id="internal_javadoc_sources">
<ant:pathelement path="${context.getAntProject().getReferences().get('maven.compile.src.set')}"/>
</ant:path>
</j:if>
<!-- Tokenize the set of directories -->
<util:tokenize var="sources_dirs" delim="${path.separator}">${context.getAntProject().getReferences().get('internal_javadoc_sources')}</util:tokenize>
<!-- For each directory -->
<j:forEach var="dir" items="${sources_dirs}">
<!-- If we have not already find sources -->
<j:if test="${internal_javadoc_needed != true}">
<!-- We construct the fileset -->
<util:replace var="packageDir" newChar="/" oldChar="." value="${pom.package}" />
<j:if test="${!empty(packageDir)}">
<j:set var="includes" value="${packageDir}/**/*.java" />
</j:if>
<j:if test="${empty(packageDir)}">
<j:set var="includes" value="**/*.java" />
</j:if>
<ant:fileScanner var="sources">
<ant:fileset dir="${dir}">
<ant:include name="${includes}" />
</ant:fileset>
</ant:fileScanner>
<j:set var="internal_javadoc_needed" scope="parent"
value="${sources.iterator().hasNext()}" />
</j:if>
</j:forEach> <!-- dir in internal.javadoc.src.set -->
<j:if test="${maven.javadoc.debug}">
<ant:echo>internal_javadoc_needed is ${internal_javadoc_needed}</ant:echo>
</j:if>
</j:if>
</define:tag>
<define:jellybean
name="javadocwarnings"
className="org.apache.maven.javadoc.JavadocWarningsTextToXml"
method="build"
/>
</define:taglib>
<!-- ================================================================== -->
<!-- J A V A D O C S R E P O R T S -->
<!-- ================================================================== -->
<goal name="maven-javadoc-plugin:register" prereqs="xdoc:init">
<javadoc:init/>
<j:if test="${internal_javadoc_needed}">
<doc:registerReport
name="JavaDocs"
pluginName="maven-javadoc-plugin"
link="apidocs/index"
target="_blank"
description="JavaDoc API documentation."
/>
<doc:registerReport
name="JavaDoc Report"
pluginName=""
link="javadoc"
description="Report on the generation of JavaDoc."
/>
<doc:registerReport
name="JavaDoc Warnings Report"
pluginName=""
link="javadoc-warnings-report"
description="Formatted report of JavaDoc warnings."
/>
</j:if>
</goal>
<goal name="maven-javadoc-plugin:deregister">
<javadoc:init/>
<j:if test="${internal_javadoc_needed}">
<doc:deregisterReport name="JavaDocs"/>
<doc:deregisterReport name="JavaDoc Report"/>
<doc:deregisterReport name="JavaDoc Warnings Report"/>
</j:if>
</goal>
<!-- ================================================================== -->
<!-- J A V A D O C S -->
<!-- ================================================================== -->
<goal name="maven-javadoc-plugin:report"
description="Generate API documentation" prereqs="xdoc:init">
<javadoc:init/>
<j:if test="${internal_javadoc_needed}">
<ant:mkdir dir="${maven.javadoc.destdir}"/>
<!-- Get the year to display in the Javadocs -->
<ant:tstamp>
<ant:format property="currentYear" pattern="yyyy"/>
</ant:tstamp>
<ant:tstamp>
<j:choose>
<j:when test="${pom.inceptionYear.equals(currentYear)}">
<ant:format property="year" pattern="yyyy"/>
</j:when>
<j:otherwise>
<ant:format property="year" pattern="${pom.inceptionYear}-yyyy"/>
</j:otherwise>
</j:choose>
</ant:tstamp>
<!-- calculate online/offline mode -->
<j:set var="online" value="${maven.javadoc.mode.online}"/>
<j:if test="${empty(online)}">
<j:set var="online" value="${maven.mode.online}"/>
</j:if>
<j:choose>
<j:when test="${online}">
<util:tokenize var="links" delim="," trim="true">${maven.javadoc.links}</util:tokenize>
<j:forEach var="link" items="${links}">
<ant:echo>Linking with API information from ${link.trim()} ...</ant:echo>
</j:forEach>
</j:when>
<j:otherwise>
<util:tokenize var="links" delim="," trim="true">${maven.javadoc.offlineLinks}</util:tokenize>
<j:forEach var="link" items="${links}">
<ant:echo>Linking offline API information from ${link.trim()} ...</ant:echo>
</j:forEach>
</j:otherwise>
</j:choose>
<j:set var="maxMemory" value="${maven.javadoc.maxmemory}" />
<ant:mkdir dir="${internal_javadoc_working_dir}" />
<ant:record name="${internal_javadoc_working_dir}/report.txt" action="start" />
<j:choose>
<j:when test="${pom.package != null and !pom.package.equals('')}">
<j:set var="packageNamesValue" value="${pom.package}.*" />
</j:when>
<j:otherwise>
<j:set var="packageNamesValue" value="*" />
</j:otherwise>
</j:choose>
<ant:javadoc
packagenames ="${packageNamesValue}"
destdir ="${maven.javadoc.destdir}"
author ="${maven.javadoc.author}"
public ="${maven.javadoc.public}"
package ="${maven.javadoc.package}"
private ="${maven.javadoc.private}"
version ="${maven.javadoc.version}"
use ="${maven.javadoc.use}"
windowtitle ="${maven.javadoc.windowtitle}"
doctitle ="${maven.javadoc.windowtitle}"
stylesheetfile ="${maven.javadoc.stylesheet}"
additionalparam ="${maven.javadoc.additionalparam}"
useexternalfile ="${maven.javadoc.useexternalfile}"
verbose ="${maven.javadoc.debug}"
>
<ant:sourcepath>
<ant:path refid="internal_javadoc_sources"/>
</ant:sourcepath>
<j:if test="${pom.package == null or pom.package.equals('')}">
<util:tokenize var="sources_dirs" delim="${path.separator}">${context.getAntProject().getReferences().get('maven.compile.src.set')}</util:tokenize>
<j:forEach var="dir" items="${sources_dirs}">
<ant:fileset dir="${dir}">
<ant:include name="*.java"/>
</ant:fileset>
</j:forEach>
</j:if>
<j:if test="${context.getVariable('maven.javadoc.source') != null}">
<ant:setProperty name="source" value="${maven.javadoc.source}" />
</j:if>
<j:if test="${context.getVariable('maven.compile.encoding') != null}">
<ant:setProperty name="encoding" value="${maven.compile.encoding}" />
</j:if>
<j:if test="${context.getVariable('maven.javadoc.excludepackagenames') != null}">
<ant:setProperty name="excludepackagenames" value="${maven.javadoc.excludepackagenames}" />
</j:if>
<j:if test="${context.getVariable('maven.javadoc.bottom') != null and !context.getVariable('maven.javadoc.bottom').equals('')}">
<ant:setProperty name="bottom" value="${maven.javadoc.bottom}" />
</j:if>
<!-- Process/Parse links -->
<!-- This code allows to specify a packagelistLoc even when in online mode -->
<j:forEach var="link" items="${links}">
<j:set var="pos" value="${link.indexOf('#')}" />
<!-- set href and packagelistLoc -->
<j:choose>
<!-- I am bad with jelly, the test is: "pos == -1" -->
<j:when test="${1+pos == 0}">
<j:set var="href" value="${link.trim()}" />
<j:set var="packagelistLoc" value="${href}"/>
</j:when>
<j:otherwise>
<j:set var="href" value="${link.substring(0,pos).trim()}"/>
<j:set var="packagelistLoc" value="${link.substring(pos).substring(1).trim()}"/>
</j:otherwise>
</j:choose>
<!-- generate the link -->
<j:choose>
<j:when test="${online}" >
<ant:link href="${href}" offline="false" packagelistLoc="${packagelistLoc}" />
</j:when>
<j:otherwise>
<ant:link href="${href}" offline="true" packagelistLoc="${packagelistLoc}" />
</j:otherwise>
</j:choose>
</j:forEach>
<ant:classpath>
<ant:path refid="maven.dependency.classpath"/>
<ant:path location="${maven.build.dest}"/>
</ant:classpath>
<j:if test="${context.getVariable('maven.javadoc.locale') != null}">
<ant:setProperty name="locale" value="${maven.javadoc.locale}" />
</j:if>
<j:if test="${context.getVariable('maven.javadoc.overview') != null}">
<ant:setProperty name="overview" value="${maven.javadoc.overview}" />
</j:if>
<j:if test="${maxMemory != null}">
<ant:setProperty name="maxmemory" value="${maven.javadoc.maxmemory}" />
</j:if>
<j:forEach var="packageGroup" items="${pom.packageGroups}">
<ant:group title="${packageGroup.title}" packages="${packageGroup.packages}"/>
</j:forEach>
<!-- allow custom doclets -->
<j:if test="${context.getVariable('maven.javadoc.doclet') != null}">
<ant:setProperty name="doclet" value="${maven.javadoc.doclet}" />
</j:if>
<j:if test="${context.getVariable('maven.javadoc.docletpath') != null}">
<ant:setProperty name="docletpath" value="${maven.javadoc.docletpath}" />
</j:if>
<!-- allow custom tags -->
<util:tokenize var="listOfTags" delim=" ">${maven.javadoc.customtags}</util:tokenize>
<j:forEach var="someTag" items="${listOfTags}">
<j:set var="nameVar" value="${someTag}.name"/>
<j:set var="name" value="${context.findVariable(nameVar)}"/>
<j:set var="descriptionVar" value="${someTag}.description"/>
<j:set var="description" value="${context.findVariable(descriptionVar)}"/>
<j:set var="enabledVar" value="${someTag}.enabled"/>
<j:set var="enabled" value="${context.findVariable(enabledVar)}"/>
<j:set var="scopeVar" value="${someTag}.scope"/>
<j:set var="scope" value="${context.findVariable(scopeVar)}"/>
<ant:tag name="${name}" description="${description}"
enabled="${enabled}" scope="${scope}"/>
</j:forEach>
<!-- allow taglets -->
<util:tokenize var="listOfTaglets" delim="," trim="true">${maven.javadoc.taglets}</util:tokenize>
<j:set var="tagletPath" value="${context.getVariable('maven.javadoc.tagletpath')}" />
<j:forEach var="someTaglet" items="${listOfTaglets}">
<ant:taglet name="${someTaglet}" path="${tagletPath}" />
</j:forEach>
</ant:javadoc>
<j:if test="${pom.package == null or pom.package.equals('')}">
<!--
Because the javadoc doesn't copy
automatically doc-files directories if we don't
specify a package, we must do it manually.
-->
<ant:copy todir="${maven.javadoc.destdir}">
<util:tokenize var="sources_dirs" delim="${path.separator}">${context.getAntProject().getReferences().get('maven.compile.src.set')}</util:tokenize>
<j:forEach var="dir" items="${sources_dirs}">
<ant:fileset dir="${dir}">
<ant:include name="**/doc-files/**/*"/>
</ant:fileset>
</j:forEach>
</ant:copy>
</j:if>
<ant:record name="${internal_javadoc_working_dir}/report.txt" action="stop" />
<j:set var="genDocs" value="${maven.gen.docs}" />
<!-- load file in order to remove absolute paths -->
<util:file name="${internal_javadoc_working_dir}/report.txt" var="inputFileObject"/>
<util:loadText var="inputText" file="${inputFileObject}"/>
<!-- remove [javadoc] prefix from rows -->
<j:invokeStatic var="inputText" className="org.apache.commons.lang.StringUtils" method="replace">
<j:arg type="java.lang.String" value="${inputText}" />
<j:arg type="java.lang.String" value="[javadoc] " />
<j:arg type="java.lang.String" value="" />
</j:invokeStatic>
<!-- trim path to basedir/ -->
<j:set var="pathToTrim">${basedir}${file.separator}</j:set>
<j:invokeStatic var="inputText" className="org.apache.commons.lang.StringUtils" method="replace">
<j:arg type="java.lang.String" value="${inputText}" />
<j:arg type="java.lang.String" value="${pathToTrim}" />
<j:arg type="java.lang.String" value="" />
</j:invokeStatic>
<!-- trim path to maven home (stylesheet copy) -->
<j:set var="pathToTrim">${maven.home}${file.separator}</j:set>
<j:invokeStatic var="inputText" className="org.apache.commons.lang.StringUtils" method="replace">
<j:arg type="java.lang.String" value="${inputText}" />
<j:arg type="java.lang.String" value="${pathToTrim}" />
<j:arg type="java.lang.String" value="" />
</j:invokeStatic>
<doc:text-xdoc
title="Javadoc Report"
section="Javadoc Report"
inputText="${inputText}"
output="${genDocs}/javadoc.xml"/>
<javadoc:javadocwarnings
verbose="${maven.javadoc.debug}"
inputFileName="${internal_javadoc_working_dir}/report.txt"
outputFileName="${internal_javadoc_working_dir}/javadoc-warnings.xml"
outputEncoding="${maven.docs.outputencoding}"
/>
<doc:jsl
input="${internal_javadoc_working_dir}/javadoc-warnings.xml"
output="javadoc-warnings-report.xml"
stylesheet="${plugin.resources}/javadoc-warnings.jsl"
encoding="${maven.docs.outputencoding}"
outputMode="xml"
prettyPrint="true"
/>
<ant:delete dir="${internal_javadoc_src_tmp}"/>
</j:if>
<j:if test="${not internal_javadoc_needed}">
<ant:echo>*******************************************</ant:echo>
<ant:echo>* No sources found. Javadoc not created ! *</ant:echo>
<ant:echo>*******************************************</ant:echo>
</j:if>
</goal>
<!-- ================================================================== -->
<!-- P A C K A G E A N D D E P L O Y J A V A D O C S -->
<!-- ================================================================== -->
<!--==================================================================-->
<!-- Create a jar file containing the javadoc -->
<!--==================================================================-->
<goal name="javadoc:jar" prereqs="javadoc">
<j:if test="${internal_javadoc_needed}">
<j:set var="maven.javadoc.final.name"
value="${internal_javadoc_jar}" />
<ant:jar
destfile="${maven.javadoc.final.name}"
basedir="${maven.javadoc.destdir}"
update="true">
</ant:jar>
</j:if>
</goal>
<!--==================================================================-->
<!-- Install the jar in the local repository -->
<!--==================================================================-->
<goal name="javadoc:install"
prereqs="javadoc:jar"
description="Install the jar containing javadoc in the local repository">
<j:if test="${internal_javadoc_needed}">
<artifact:install
artifact="${maven.javadoc.final.name}"
type="javadoc.jar"
project="${pom}"/>
</j:if>
</goal>
<!--==================================================================-->
<!-- Install the snapshot version of the jar in the local repository -->
<!--==================================================================-->
<goal name="javadoc:install-snapshot"
prereqs="javadoc:jar"
description="Install the snapshot version of the jar containing javadoc in the local repository">
<j:if test="${internal_javadoc_needed}">
<artifact:install-snapshot
artifact="${maven.javadoc.final.name}"
type="javadoc.jar"
project="${pom}"/>
</j:if>
</goal>
<!--==================================================================-->
<!-- Deploys the javadoc to the remote repository -->
<!--==================================================================-->
<goal name="javadoc:deploy"
prereqs="javadoc:jar"
description="Deploys the jar containing javadoc to the remote repository">
<j:if test="${internal_javadoc_needed}">
<artifact:deploy
artifact="${maven.javadoc.final.name}"
type="javadoc.jar"
project="${pom}"/>
</j:if>
</goal>
<!--==================================================================-->
<!-- Deploys the snapshot of the javadoc to the remote repository -->
<!--==================================================================-->
<goal name="javadoc:deploy-snapshot"
prereqs="javadoc:jar"
description="Deploys the snapshot version of jar containing javadoc to remote repository">
<j:if test="${internal_javadoc_needed}">
<artifact:deploy-snapshot
artifact="${maven.javadoc.final.name}"
type="javadoc.jar"
project="${pom}"/>
</j:if>
</goal>
<!-- ================================================================== -->
<!-- B A C K W A R D C O M P A T I B I L I T Y -->
<!-- ================================================================== -->
<!-- Some aliases for ease of use and backward compat. -->
<goal name="javadoc:generate" prereqs="maven-javadoc-plugin:report"/>
<goal name="javadoc" prereqs="maven-javadoc-plugin:report"/>
</project>