maven-plugins/xdoc/plugin.jelly

1101 lines
44 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!--
/*
* 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:define="jelly:define"
xmlns:j="jelly:core"
xmlns:jsl="jelly:jsl"
xmlns:log="jelly:log"
xmlns:maven="jelly:maven"
xmlns:pom="pom"
xmlns:util="jelly:util"
xmlns:x="jelly:xml"
xmlns:velocity="jelly:velocity"
xmlns:ant="jelly:ant"
xmlns:fmt="jelly:fmt"
xmlns:doc="doc"
xmlns:xdoc="jelly:org.apache.maven.xdoc.XdocTagLibrary">
<j:new var="reports" className="java.util.ArrayList"/>
<define:taglib uri="doc">
<define:tag name="deregisterReport">
<!-- @name : Report to deregister, must be same as name used to register -->
<maven:pluginVar var="reports" plugin="maven-xdoc-plugin" property="reports" />
<j:set var="removeRpt" value="null"/>
<j:forEach var="rpt" items="${reports}">
<j:if test="${rpt.get('name').equals(name)}">
<j:set var="removeRpt" value="${rpt}"/>
</j:if>
</j:forEach>
<j:if test="${removeRpt != null}">
<j:set var="dummy" value="${reports.remove(removeRpt)}"/>
</j:if>
</define:tag>
<define:tag name="registerReport">
<!--
@name the name of this report. Used for navigation items
@pluginName the name of the plugin. @plugin:report goal must exist
@description text description of report
@link the nav-bar link for this report
@target the target for the new page (_self, _blank, ...)
-->
<maven:pluginVar var="reports" plugin="maven-xdoc-plugin" property="reports" />
<!-- check if the given name is in the list already -->
<j:set var="add" value="true"/>
<j:forEach var="rpt" items="${reports}">
<j:if test="${rpt.get('name').equals(name)}">
<j:set var="add" value="false"/>
</j:if>
</j:forEach>
<j:if test="${add.equals('true')}">
<j:new var="report" className="java.util.HashMap"/>
<j:set var="dummy">
${report.put('name', name)}
${report.put('pluginName', pluginName)}
${report.put('description', description)}
${report.put('link', link)}
${report.put('externalLink', externalLink)}
${report.put('target', target)}
${reports.add(report)}
</j:set>
</j:if>
</define:tag>
<define:tag name="formatAsNumber">
<!--
| @string
| @pattern
-->
<!-- This appears to need to be here which is no good. Need
more of a global tool box.
-->
<j:useBean var="formatter" class="org.apache.maven.util.DVSLFormatter"/>
${formatter.formatNumber(string,pattern)}
</define:tag>
<define:tag name="jslFile">
<!--
| Basic tag for performing arbitrary jsl transformations
| on arbitrary jsl inputs.
| @input (optional)
| @output
| @stylesheet
| @encoding
| @omitXmlDeclaration
| @outputMode
| @prettyPrint
-->
<!-- Set default encoding if not set. -->
<j:if test="${encoding == null}">
<j:set var="encoding"
value="${plugin.getVariable('maven.docs.outputencoding')}"/>
</j:if>
<j:if test="${input != null}">
<util:file name="${input}" var="inputFile" />
<x:parse var="doc" xml="${inputFile}"/>
</j:if>
<j:set var="stylesheetURI" value="file:${stylesheet}"/>
<j:file
name="${output}"
encoding="${encoding}"
omitXmlDeclaration="${omitXmlDeclaration}"
outputMode="${outputMode}"
prettyPrint="${prettyPrint}">
<j:include uri="${stylesheetURI.toString()}"/>
</j:file>
</define:tag>
<define:tag name="jsl">
<!--
| This tag has a lot of defaults suitable for transforming
| documents easily. See jslCore for a tag suitable for
| transforming documents how you want.
| @input
| @outputDirectory - Will be placed under ${maven.gen.docs}
| @stylesheet
| @encoding - defaults to ${maven.docs.outputencoding}
| @omitXmlDeclaration - defaults to ${maven.docs.omitXmlDeclaration}
| @outputMode
| @prettyPrint
-->
<!--
@todo make sure the output directory exists.
-->
<!-- Set default outputDirectory if not set. -->
<j:if test="${empty(outputDirectory)}">
<j:set var="outputDirectory" value="${maven.gen.docs}"
/>
</j:if>
<!-- Set default encoding if not set. -->
<j:if test="${encoding == null}">
<j:set var="encoding" value="${maven.docs.outputencoding}" />
</j:if>
<j:if test="${omitXmlDeclaration == null}">
<j:set var="omitXmlDeclaration" value="${maven.docs.omitXmlDeclaration}"/>
</j:if>
<mkdir dir="${outputDirectory}"/>
<doc:jslFile
input="${input}"
output="${outputDirectory}/${output}"
stylesheet="${stylesheet}"
encoding="${encoding}"
omitXmlDeclaration="${omitXmlDeclaration}"
outputMode="${outputMode}"
prettyPrint="${prettyPrint}"/>
</define:tag>
<!--
@link
@relativePath
@name
@img
@state - expanded / collapsed / none
@target
-->
<define:tag name="itemLink">
<x:element name="a">
<x:attribute name="href">${pathTool.calculateLink(link,relativePath)}</x:attribute>
<j:choose>
<j:when test="${target != null and target.equals('_blank')}">
<x:attribute name="class">newWindow</x:attribute>
<x:attribute name="title">New Window</x:attribute>
</j:when>
<j:when test="${link.startsWith('http')}">
<x:attribute name="class">externalLink</x:attribute>
<x:attribute name="title">External Link</x:attribute>
</j:when>
</j:choose>
<j:if test="${!empty(target)}">
<x:attribute name="target">${target}</x:attribute>
</j:if>
<j:if test="${empty(state)}"><j:set var="state" value="none"/></j:if>
<j:if test="${empty(img)}">${name}</j:if>
<j:if test="${!empty(img)}"><img style="border: 1px" src="${pathTool.calculateLink(img, relativePath)}" title="${name}" alt="${name}"/></j:if>
</x:element>
</define:tag>
<define:tag name="text-xdoc">
<!--
@output - The output file
@title - Title for page
@section - Section heading
@encoding - The XML encoding
@preamble - Placed in paragraph block prior to text
@inputText - Will be wrapped in a CDATA, will not escape CDATA tags (as yet)
@inputFile - Will be read in and wrapped in CDATA. Overrides inputText if set
-->
<j:set var="inputFile">${inputFile}</j:set>
<j:if test="${inputFile != ''}">
<util:file name="${inputFile}" var="inputFileObject"/>
<util:loadText var="inputText" file="${inputFileObject}"/>
</j:if>
<!-- Set default encoding if not set. -->
<j:if test="${encoding == null}">
<j:set var="encoding"
value="${plugin.getVariable('maven.docs.outputencoding')}"/>
</j:if>
<j:file name="${output}" prettyPrint="false" encoding="${encoding}">
<document>
<properties><title>${title}</title></properties>
<body>
<section name="${section}">
<p>${preamble}</p>
<source>
<![CDATA[${inputText}]]>
</source>
</section>
</body>
</document>
</j:file>
</define:tag>
<!-- Alternator for row style in a table -->
<define:tag name="printRow">
<j:if test="${(count % 2) gt 0}">
<x:element name="tr">
<x:attribute name="class">a</x:attribute>
</x:element>
</j:if>
<j:if test="${(count % 2) le 0}">
<x:element name="tr">
<x:attribute name="class">b</x:attribute>
</x:element>
</j:if>
</define:tag>
<!-- Generates the JSL files on the given srcdir attribute depending the locale wanted -->
<define:tag name="performJSL">
<!-- Safety : Reinit the defaultLocale -->
<echo>${defaultLocale}</echo>
<j:if test="${defaultLocale == null}">
<!-- Init the default language -->
<j:invokeStatic className="org.apache.commons.lang.StringUtils" method="isEmpty" var="isEmptyLocaleDefault">
<j:arg value="${maven.xdoc.locale.default}" type="java.lang.String"/>
</j:invokeStatic>
<j:if test="${isEmptyLocaleDefault}">
<j:invokeStatic className="java.util.Locale" method="getDefault" var="defaultLocaleTmp"/>
<j:set var="maven.xdoc.locale.default" value="${defaultLocaleTmp.toString().substring(0, 2)}"/>
</j:if>
<j:invokeStatic className="org.apache.maven.xdoc.util.LocaleUtil" method="codeToLocale" var="defaultLocale">
<j:arg value="${maven.xdoc.locale.default}" type="java.lang.String"/>
</j:invokeStatic>
</j:if>
<!-- First step: default resource bundle -->
<doc:performJSL-i18n srcdir="${srcdir}" destdir="${destdir}" currentLocale="${defaultLocale}"/>
<!-- Second step: local-specific resource bundle -->
<j:forEach var="locale" items="${locales}">
<j:if test="${!currentLocale.equals(defaultLocale)}">
<doc:performJSL-i18n srcdir="${srcdir}/${locale}" destdir="${destdir}/${locale}" currentLocale="${locale}"/>
</j:if>
</j:forEach>
</define:tag>
<define:tag name="performJSLTransform">
<!-- Safety : Reinit the defaultLocale -->
<j:if test="${defaultLocale == null}">
<!-- Init the default language -->
<j:invokeStatic className="org.apache.commons.lang.StringUtils" method="isEmpty" var="isEmptyLocaleDefault">
<j:arg value="${maven.xdoc.locale.default}" type="java.lang.String"/>
</j:invokeStatic>
<j:if test="${isEmptyLocaleDefault}">
<j:invokeStatic className="java.util.Locale" method="getDefault" var="defaultLocaleTmp"/>
<j:set var="maven.xdoc.locale.default" value="${defaultLocaleTmp.toString().substring(0, 2)}"/>
</j:if>
<j:invokeStatic className="org.apache.maven.xdoc.util.LocaleUtil" method="codeToLocale" var="defaultLocale">
<j:arg value="${maven.xdoc.locale.default}" type="java.lang.String"/>
</j:invokeStatic>
</j:if>
<!-- First step: default resource bundle -->
<doc:performJSL-i18n srcdir="${srcdir}" destdir="${destdir}" currentLocale="${defaultLocale}"/>
<!-- Second step: local-specific resource bundle -->
<j:forEach var="locale" items="${locales}">
<j:if test="${!currentLocale.equals(defaultLocale)}">
<doc:performJSL-i18n srcdir="${srcdir}" destdir="${destdir}/${locale}" currentLocale="${locale}"/>
</j:if>
</j:forEach>
</define:tag>
<!-- Generates the JSL files on the given srcdir attribute -->
<define:tag name="performJSL-i18n">
<util:file var="srcdirFile" name="${srcdir}"/>
<j:set var="srcdir" value="${srcdirFile.getCanonicalPath()}"/>
<util:file var="destdirFile" name="${destdir}"/>
<j:set var="destdir" value="${destdirFile.getCanonicalPath()}"/>
<util:replace var="fromPattern" oldChar="\" newChar="/" value="${srcdir}/*.xml"/>
<util:replace var="toPattern" oldChar="\" newChar="/" value="${destdir}/*.html"/>
<j:if test="${mapper == null}">
<j:new var="mapper" className="org.apache.maven.util.CaseInsensitiveGlobPatternMapper"/>
</j:if>
<j:setProperties object="${mapper}" from="${fromPattern}" to="${toPattern}"/>
<util:replace var="fromDirPattern" oldChar="\" newChar="/" value="${srcdir}*"/>
<util:replace var="toDirPattern" oldChar="\" newChar="/" value="${destdir}*"/>
<j:new var="dirMapper" className="org.apache.maven.util.CaseInsensitiveGlobPatternMapper"/>
<j:setProperties object="${dirMapper}" from="${fromDirPattern}" to="${toDirPattern}"/>
<maven:pluginVar var="maven_xdoc_xml_copy_pattern"
plugin='maven-xdoc-plugin' property='maven.xdoc.xml.copy' />
<!-- Set the current locale as default -->
<j:if test="${currentLocale.equals(defaultLocale)}">
<fmt:setLocale value="${defaultLocale}"/>
</j:if>
<j:if test="${!currentLocale.equals(defaultLocale)}">
<fmt:setLocale value="${currentLocale}"/>
</j:if>
<fmt:setBundle basename="plugin-resources/templates/templates" var="msg"/>
<!-- User bundle -->
<!-- Goal grabClassLoader should be call first -->
<xdoc:grabClassLoader resource="${maven.xdoc.bundle.src}"/>
<fmt:setBundle basename="${maven.xdoc.bundle}" var="myMsg"/>
<!-- Echo information -->
<j:if test="${currentLocale.equals(defaultLocale)}">
<echo message="The current Locale is the default one"/>
</j:if>
<j:if test="${!currentLocale.equals(defaultLocale)}">
<echo message="The current Locale is '${currentLocale}'"/>
</j:if>
<echo message="Scanning '${srcdir}'..."/>
<!-- This test is only used to prevent error if other plugins calls this tag like linkcheck -->
<util:available file="${srcdir}">
<fileScanner var="docFiles">
<fileset dir="${srcdir}">
<patternset>
<exclude name="**/project.xml"/>
<exclude name="**/template.xml"/>
<exclude name="**/navigation.xml"/>
<exclude name="changes.xml"/>
<exclude name="**/*.properties"/>
<j:if test="${maven_xdoc_xml_copy_pattern!=null and !maven_xdoc_xml_copy_pattern.equals('')}">
<util:tokenize var="xmlPatterns" delim=",">${maven_xdoc_xml_copy_pattern}</util:tokenize>
<j:forEach var="xmlPattern" items="${xmlPatterns}">
<exclude name="${xmlPattern}"/>
</j:forEach>
</j:if>
<include name="**/*.xml"/>
<j:if test="${currentLocale.equals(defaultLocale)}">
<j:forEach var="locale" items="${locales}">
<exclude name="${locale}/**"/>
</j:forEach>
</j:if>
<j:if test="${!currentLocale.equals(defaultLocale)}">
<j:forEach var="locale" items="${locales}">
<j:if test="${currentLocale.equals(locale)}">
<include name="${locale}/**"/>
</j:if>
<j:if test="${!currentLocale.equals(locale)}">
<exclude name="${locale}/**"/>
</j:if>
</j:forEach>
</j:if>
</patternset>
</fileset>
</fileScanner>
<!-- determine nav file to be used:- 1. check for sitewide nav files -->
<!-- supplied nav file as project.xml in stylesheets dir -->
<util:available file="${maven.docs.src}/stylesheets/project.xml">
<util:file var="siteNavFile" name="${maven.docs.src}/stylesheets/project.xml"/>
</util:available>
<!-- supplied nav file as project.xml in root of xdocs source tree -->
<util:available file="${maven.docs.src}/project.xml">
<util:file var="siteNavFile" name="${maven.docs.src}/project.xml"/>
</util:available>
<!-- supplied navigation file in root of xdocs source tree -->
<util:available file="${maven.docs.src}/navigation.xml">
<util:file var="siteNavFile" name="${maven.docs.src}/navigation.xml"/>
</util:available>
<!-- navigation file that was generated -->
<util:available file="${maven.gen.docs}/navigation.xml">
<util:file var="siteNavFile" name="${maven.gen.docs}/navigation.xml"/>
</util:available>
<!-- hold onto maven.docs.src for later -->
<util:file var="docsSrcFile" name="${maven.docs.src}"/>
<!-- parse the project nav. Someone jellier than me can remove the temp file requirement -->
<maven:pluginVar var="reports" plugin="maven-xdoc-plugin" property="reports" />
<util:file var="tempnav" name="${maven.build.dir}/project-nav.xml"/>
<j:file name="${tempnav.toString()}" outputMode="xml">
<j:import file="${plugin.resources}/navigation.jelly" inherit="true"/>
</j:file>
<x:parse var="projectNavRoot" xml="${tempnav}"/>
<x:set var="projectNav" select="$projectNavRoot/project"/>
<j:forEach var="file" items="${docFiles.iterator()}">
<util:replace var="inDirForward" oldChar="\" newChar="/" value="${file.parent}"/>
<j:set var="outDir" value="${dirMapper.mapFileName(inDirForward).0}"/>
<mkdir dir="${outDir}"/>
<!-- generate output file name -->
<util:replace var="outFileForward" oldChar="\" newChar="/" value="${file.toString()}"/>
<j:set var="outFile" value="${mapper.mapFileName(outFileForward).0}"/>
<echo>Generating ${outFile} from ${file}</echo>
<!-- work out relative path -->
<util:replace var="docsForward" oldChar="\" newChar="/" value="${srcdir}"/>
<j:if test="${pathTool == null}">
<j:useBean var="pathTool" class="org.apache.maven.util.DVSLPathTool"/>
</j:if>
<j:set var="relativePath" value="${pathTool.getRelativePath(docsForward, outFileForward)}"/>
<j:set var="relativePathForLocale" value="${pathTool.getRelativePath(docsForward, outFileForward)}"/>
<!-- Relative path if locale used -->
<j:set var="relativePathForLocale" value="${relativePath}/"/>
<j:if test="${!currentLocale.equals(defaultLocale)}">
<j:set var="relativePathForLocale" value="${relativePath}/../"/>
</j:if>
<!-- determine nav file to be used: 2. check for nav file -->
<!-- in the same directory as xml file being processed -->
<!-- if no such nav file available use sitewide nav file -->
<j:set var="navFile" value="${siteNavFile}" />
<util:available file="${file.parentFile.absoluteFile}/navigation.xml">
<!-- dont use current directory navigation.xml if it's in maven.docs.src -->
<j:if test="${!(file.parentFile.equals(docsSrcFile))}">
<util:file var="navFile" name="${file.parentFile.absoluteFile}/navigation.xml"/>
</j:if>
</util:available>
<!-- parse nav and make it available to the stylesheet -->
<j:if test="${navFile != null}">
<x:parse var="navXML" xml="${navFile}"/>
<x:set var="nav" select="$navXML/project"/>
</j:if>
<!-- parse the doc and pass it to the stylesheet -->
<x:parse var="doc" xml="${file}"/>
<j:file name="${outFile}" encoding="${outputencoding}"
omitXmlDeclaration="true" outputMode="xml"
prettyPrint="no">
<j:include uri="${stylesheet.toString()}"/>
</j:file>
</j:forEach>
</util:available>
</define:tag>
<define:tag name="jslToSite">
<!--
| transforms files in the given dir using the site stylesheet and navigation and place them
| in maven.docs.dest (typically target/docs)
| @srcdir source directory
-->
<maven:param-check value="${srcdir}" fail="true" message="'srcdir' must be specified"/>
<maven:pluginVar var="maven.xdoc.jsl"
plugin='maven-xdoc-plugin' property='maven.xdoc.jsl' />
<!-- copy old value for restoring it later -->
<j:set var="previous.plugin.resources" value="${plugin.resources}" />
<maven:pluginVar var="plugin.resources"
plugin='maven-xdoc-plugin' property='plugin.resources' />
<maven:pluginVar var="includeProjectDocumentation"
plugin='maven-xdoc-plugin' property='maven.xdoc.includeProjectDocumentation' />
<maven:pluginVar var="maven.xdoc.poweredby.image"
plugin='maven-xdoc-plugin' property='maven.xdoc.poweredby.image' />
<maven:pluginVar var="maven.xdoc.poweredby.title"
plugin='maven-xdoc-plugin' property='maven.xdoc.poweredby.title' />
<maven:pluginVar var="maven.xdoc.poweredby.url"
plugin='maven-xdoc-plugin' property='maven.xdoc.poweredby.url' />
<maven:pluginVar var="maven.xdoc.crumb.separator"
plugin='maven-xdoc-plugin' property='maven.xdoc.crumb.separator' />
<j:set var="outputDirectory" value="${maven.gen.docs}" />
<j:set var="stylesheet" value="file:${plugin.resources}/site.jsl" />
<j:set var="outputencoding" value="${maven.docs.outputencoding}" />
<doc:performJSL srcdir="${srcdir}" destdir="${maven.docs.dest}" />
<!-- restore plugin.resources -->
<j:set var="plugin.resources" value="${previous.plugin.resources}" />
</define:tag>
<!--
| escapes a string for generating a valid name token (need for "name" attribute in html anchors)
| @value given token
-->
<define:tag name="escapeNameToken">
<j:invokeStatic var="escapedtoken" className="org.apache.commons.lang.StringUtils" method="replaceChars">
<j:arg type="java.lang.String" value="${value}" useContextClassLoader="true"/>
<j:arg type="java.lang.String" value=" .,;!?/'\()[]{}+*°" useContextClassLoader="true"/>
<j:arg type="java.lang.String" value="__________________" useContextClassLoader="true"/>
</j:invokeStatic>${escapedtoken}</define:tag>
</define:taglib>
<!-- ================================================================== -->
<!-- P R O J E C T D O C U M E N T A T I O N -->
<!-- ================================================================== -->
<goal name="xdoc"
prereqs="xdoc:generate-from-pom, xdoc:transform"
description="Generate html project documentation xdoc sources"/>
<goal name="xdoc:init"
prereqs="xdoc:init-i18n"
description="Generates the directory structure required for xdocs">
<echo message="Generates the directory structure required for xdocs"/>
<mkdir dir="${maven.gen.docs}"/>
<mkdir dir="${maven.docs.dest}"/>
<j:forEach var="locale" items="${locales}">
<j:if test="${!currentLocale.equals(defaultLocale)}">
<mkdir dir="${maven.gen.docs}/${locale}"/>
</j:if>
</j:forEach>
</goal>
<goal name="xdoc:init-i18n"
description="Init the i18n support">
<j:if test="${initI18n == null}">
<echo message="Init the i18n support"/>
<!-- Init the default language -->
<j:invokeStatic className="org.apache.commons.lang.StringUtils" method="isEmpty" var="isEmptyLocaleDefault">
<j:arg value="${maven.xdoc.locale.default}" type="java.lang.String"/>
</j:invokeStatic>
<j:if test="${isEmptyLocaleDefault}">
<j:invokeStatic className="java.util.Locale" method="getDefault" var="defaultLocaleTmp"/>
<j:set var="maven.xdoc.locale.default" value="${defaultLocaleTmp.toString().substring(0, 2)}"/>
</j:if>
<j:invokeStatic className="org.apache.maven.xdoc.util.LocaleUtil" method="codeToLocale" var="defaultLocale">
<j:arg value="${maven.xdoc.locale.default}" type="java.lang.String"/>
</j:invokeStatic>
<!-- Init locales variables and create local-specific directories -->
<j:catch var="ex">
<j:invokeStatic className="org.apache.maven.xdoc.util.LocaleUtil" method="codesToLocales" var="locales">
<j:arg value="${maven.xdoc.locale.supported}" type="java.lang.String"/>
</j:invokeStatic>
</j:catch>
<j:if test="${ex != null}">
<log:debug>java.lang.reflect.InvocationTargetException</log:debug>
<log:debug>Caused by: org.apache.maven.xdoc.util.LocaleUtil.codesToLocales(java.lang.String)</log:debug>
<log:debug>${ex.getCause().getTargetException().getMessage()}</log:debug>
</j:if>
<j:if test="${ex == null}">
<j:set var="localeList.isValid" value="true"/>
</j:if>
<maven:param-check value="${localeList.isValid}" fail="true"
message="ERROR: The locales list '${maven.xdoc.locale.supported}' seems to contain invalid locale code. Verify the 'maven.xdoc.locale.supported' property."/>
<log:debug>defaultLocale=[${defaultLocale}]</log:debug>
<j:forEach var="locale" items="${locales}">
<log:debug>locale_supported=[${locale}]</log:debug>
</j:forEach>
<j:set var="initI18n" value="true"/>
</j:if>
</goal>
<!-- Validate the user locale entries -->
<goal name="xdoc:i18n-validation"
description="Validation of the locale entries for internationalization support">
<echo message="Validation of the locale entries"/>
<j:invokeStatic method="getAvailableLocales" className="java.util.Locale" var="availableLocales"/>
<j:invokeStatic className="java.util.Arrays" method="asList" var="availableLocalesAsList">
<j:arg value="${availableLocales}" type="[Ljava.lang.Object;"/>
</j:invokeStatic>
<j:forEach var="locale" items="${locales}">
<j:if test="${!availableLocalesAsList.contains(locale)}">
<echo message="WARNING: The locale '${locale}' is not a valid one."/>
</j:if>
</j:forEach>
</goal>
<goal
name="xdoc:generate-from-pom"
prereqs="xdoc:init, xdoc:i18n-validation, xdoc:register-reports"
description="Generates xdocs for site based on project descriptor">
<echo>Generating xdocs from POM ... </echo>
<util:tokenize var="pomDocuments" delim=",">${maven.xdoc.pomDocuments}</util:tokenize>
<!-- All the templates use $project for now. -->
<j:set var="project" value="${pom}"/>
<maven:pluginVar var="reports" plugin="maven-xdoc-plugin" property="reports" />
<!-- Does the user want the maven-generated docs on their site? -->
<j:set
var="includeProjectDocumentation"
value="${maven.xdoc.includeProjectDocumentation}"/>
<!-- Need the escaper to html output. -->
<j:useBean var="escape" class="org.apache.velocity.anakia.Escape"/>
<j:useBean var="files" class="org.apache.velocity.texen.util.FileUtil"/>
<!-- Need to enrich information about dependency by taking some information from its POM. -->
<j:useBean var="dependencyDescriber" class="org.apache.maven.DependencyDescriberBean"/>
${dependencyDescriber.build(pom)}
<j:if test="${encoding == null}">
<j:set
var="encoding"
value="${maven.docs.outputencoding}"
/>
</j:if>
<j:forEach var="pomDocument" items="${pomDocuments}">
<!-- If the template ends with ".xml" use velocity to generate the
HTML. If it ends with ".jelly" use JSL. -->
<j:choose>
<j:when test="${pomDocument.endsWith('.xml')}">
<velocity:merge
name="${maven.gen.docs}/${pomDocument}"
basedir="${plugin.resources}/templates"
template="${pomDocument}"
inputEncoding="${encoding}"
outputEncoding="${encoding}"
/>
</j:when>
<j:when test="${pomDocument.endsWith('.jelly')}">
<doc:jslFile
output="${maven.gen.docs}/${pomDocument.substring(0,pomDocument.indexOf('.jelly'))}.xml"
stylesheet="${plugin.resources}/templates/${pomDocument}"
outputMode="xml"
prettyPrint="no"/>
</j:when>
<j:otherwise>
<fail>Unknown report format for report [${pomDocument}].</fail>
</j:otherwise>
</j:choose>
</j:forEach>
<!-- Copy all generated files in an internationalize site structure, ie:
|__ en\
|__ index.xml
|__ ... (mail-lists.xml, maven-reports.xml...)
|__ fr\
|__ index.xml
|__ ... (mail-lists.xml, maven-reports.xml...)
|__ index.xml
|__ ... (mail-lists.xml, maven-reports.xml...)
-->
<j:forEach var="locale" items="${locales}">
<j:if test="${!currentLocale.equals(defaultLocale)}">
<copy todir="${maven.gen.docs}/${locale}" filtering="no">
<fileset dir="${maven.gen.docs}">
<exclude name="**/CVS/*"/>
<exclude name="images/**"/>
<exclude name="**/*.properties"/>
<j:forEach var="locale" items="${locales}">
<exclude name="${locale}/**"/>
</j:forEach>
<exclude name="stylesheets/*"/>
<include name="**/*.xml"/>
<include name="**/*.fml"/>
</fileset>
</copy>
</j:if>
</j:forEach>
</goal>
<!-- ================================================================== -->
<!-- V A L I D A T E X D O C S -->
<!-- ================================================================== -->
<!-- validate xdocs -->
<goal name="xdoc:validate" prereqs="pom:taglib"
description="Validate xdocs match the schema">
<available file="${maven.docs.src}" type="dir"
property="maven.docs.src.available"/>
<j:if test="${maven.docs.src.available}">
<fileScanner var="navFiles">
<fileset dir="${maven.docs.src}">
<patternset>
<include name="**/navigation.xml"/>
</patternset>
</fileset>
</fileScanner>
<j:forEach var="file" items="${navFiles.iterator()}">
<echo>Validating ${file}</echo>
<pom:validate validator="${maven.home}/maven-navigation-1.0.xsd"
projectDescriptor="${file}"/>
</j:forEach>
</j:if>
</goal>
<!-- ================================================================== -->
<!-- C O P Y R E S O U R C E S -->
<!-- ================================================================== -->
<!-- copy resources needed for xdocs -->
<goal name="xdoc:copy-resources"
prereqs="xdoc:init"
description="copy static resources for use in xdocs generated html">
<!-- Read in the ui properties. -->
<util:properties uri="file:${plugin.resources}/ui.properties" var="uiProperties"/>
<!-- Copy maven supplied stylesheets. -->
<copy todir="${maven.docs.dest}/style" overwrite="yes" filtering="yes">
<fileset dir="${plugin.resources}/css">
<include name="**/*.css"/>
</fileset>
<filterset>
<j:forEach var="uiProperty" items="${uiProperties.keys()}">
<util:replace var="token" oldChar="." newChar="_" value="${uiProperty}"/>
<j:set var="token" value="${token.substring(6).toUpperCase()}"/>
<!-- Check if User has overidden this property -->
<j:set var="propertyName" value="${uiProperty}" />
<j:set var="propertyValue" value="${context.getVariable(propertyName)}"/>
<j:choose>
<j:when test="${propertyValue != null}">
<!-- Use user's properties -->
<filter token="${token}" value="${propertyValue}"/>
</j:when>
<j:otherwise>
<!-- Use plugin's default properties -->
<filter token="${token}" value="${uiProperties.getProperty(uiProperty)}"/>
</j:otherwise>
</j:choose>
</j:forEach>
</filterset>
</copy>
<!-- Copy maven supplied images. -->
<copy todir="${maven.docs.dest}/images">
<fileset dir="${plugin.resources}/images">
<include name="**/*.gif"/>
<include name="**/*.jpeg"/>
<include name="**/*.jpg"/>
<include name="**/*.png"/>
<util:tokenize var="files" delim=",">${maven.xdoc.copy.excludes}</util:tokenize>
<j:forEach var="pattern" items="${files}">
<exclude name="${pattern}" />
</j:forEach>
<j:if test="${context.getVariable('maven.xdoc.theme') != 'classic'}">
<util:tokenize var="files" delim=",">${maven.xdoc.copy.excludes.classic}</util:tokenize>
<j:forEach var="pattern" items="${files}">
<exclude name="${pattern}" />
</j:forEach>
</j:if>
</fileset>
</copy>
<!-- excluded by default from previous -->
<j:set var="var" value="${maven.xdoc.poweredby.image}" />
<j:if test="${!empty(var)}">
<mkdir dir="${maven.docs.dest}/images/logos" />
<copy todir="${maven.docs.dest}/images/logos"
file="${plugin.resources}/images/logos/${var}" />
</j:if>
</goal>
<!-- ================================================================== -->
<!-- C O P Y U S E R S U P P L I E D R E S O U R C E S -->
<!-- ================================================================== -->
<!-- copy user bundles for xdocs -->
<!-- Known issue with a multiproject goal. -->
<!-- http://www.mail-archive.com/dev@maven.apache.org/msg21646.html -->
<!-- Lets see multiproject:prepare-site-i18n -->
<goal name="xdoc:copy-user-bundles"
description="Copy user provided resources to docs destination">
<!--
<available file="${maven.docs.src}" type="dir"
property="maven.docs.src.available"/>
<j:if test="${maven.docs.src.available}">
<log:info>
Copying user bundles.
</log:info>
<util:available file="${maven.xdoc.bundle.src}/${maven.xdoc.bundle}.properties">
<copy todir="${plugin.resources}/temp" filtering="no">
<fileset dir="${maven.xdoc.bundle.src}">
<include name="${maven.xdoc.bundle}*"/>
</fileset>
</copy>
<j:set var="user.bundle.available" value="true"/>
</util:available>
<j:if test="${!empty(maven.xdoc.locale.supported)}">
<maven:param-check value="${user.bundle.available}" fail="true"
message="ERROR: Unable to translate the documentation. Disagreement between the definition of 'maven.xdoc.locale.supported' property and the local-specific resources bundles."/>
</j:if>
</j:if>
-->
</goal>
<!-- copy user resources -->
<goal name="xdoc:copy-user-resources"
prereqs="xdoc:init, xdoc:copy-user-bundles"
description="Copy user provided resources to docs destination">
<j:if test="${maven.docs.src.available}">
<log:info>
Copying user supplied resources.
</log:info>
<!-- Copy user supplied resources -->
<copy todir="${maven.docs.dest}" filtering="no">
<fileset dir="${maven.docs.src}">
<exclude name="**/*.xml"/>
<exclude name="**/*.fml"/>
<exclude name="**/CVS/*"/>
<exclude name="stylesheets/*"/>
<exclude name="**/*.properties"/>
</fileset>
<fileset dir="${maven.gen.docs}">
<exclude name="**/*.xml"/>
<exclude name="**/CVS/*"/>
<exclude name="**/*.properties"/>
<j:forEach var="locale" items="${locales}">
<exclude name="${locale}/**"/>
</j:forEach>
<exclude name="stylesheets/*"/>
</fileset>
</copy>
<!-- Copy all default site structure to differents locales -->
<j:forEach var="locale" items="${locales}">
<j:if test="${!currentLocale.equals(defaultLocale)}">
<copy todir="${maven.gen.docs}/${locale}" filtering="no">
<fileset dir="${maven.docs.src}">
<exclude name="**/CVS/*"/>
<exclude name="images/**"/>
<exclude name="**/*.properties"/>
<include name="**/*.xml"/>
<include name="**/*.fml"/>
</fileset>
</copy>
</j:if>
</j:forEach>
<!-- Multi project bugs
<util:available file="${maven.xdoc.bundle.src}/${maven.xdoc.bundle}.properties">
<copy todir="${plugin.resources}/temp" filtering="no">
<fileset dir="${maven.xdoc.bundle.src}">
<include name="${maven.xdoc.bundle}*"/>
</fileset>
</copy>
<j:set var="user.bundle.available" value="true"/>
</util:available>
<j:if test="${!empty(maven.xdoc.locale.supported)}">
<maven:param-check value="${user.bundle.available}" fail="true"
message="ERROR: Unable to translate the documentation. Disagreement between the definition of 'maven.xdoc.locale.supported' property and the local-specific resources bundles."/>
</j:if>
-->
<util:available file="${maven.docs.src}/stylesheets">
<!-- Copy user supplied stylesheets, can override maven -->
<copy todir="${maven.docs.dest}/style">
<fileset dir="${maven.docs.src}/stylesheets">
<include name="**/*.css"/>
</fileset>
</copy>
</util:available>
</j:if>
<maven:pluginVar var="maven_xdoc_xml_copy_pattern"
plugin='maven-xdoc-plugin' property='maven.xdoc.xml.copy' />
<j:if test="${maven_xdoc_xml_copy_pattern!=null and !maven_xdoc_xml_copy_pattern.equals('')}">
<util:tokenize var="xmlPatterns" delim=",">${maven_xdoc_xml_copy_pattern}</util:tokenize>
<log:info>
Copying user supplied xml files.
</log:info>
<!-- Copy xml files -->
<copy todir="${maven.docs.dest}" filtering="no">
<fileset dir="${maven.docs.src}">
<j:forEach var="xmlPattern" items="${xmlPatterns}">
<include name="${xmlPattern}"/>
</j:forEach>
</fileset>
</copy>
</j:if>
</goal>
<!-- ================================================================== -->
<!-- D V S L D O C U M E N T A T I O N -->
<!-- ================================================================== -->
<goal name="xdoc:transform"
prereqs="xdoc:init"
description="Generate html project documentation xdoc sources">
<!-- Use jelly utils here -->
<available
file="${maven.gen.docs}"
type="dir"
property="maven.gen.docs.available"
/>
<available
file="${maven.docs.src}"
type="dir"
property="maven.docs.src.available"
/>
<!-- use JSL in Jelly to build the documenation -->
<attainGoal name="xdoc:copy-resources"/>
<attainGoal name="xdoc:copy-user-resources"/>
<attainGoal name="xdoc:jelly-transform"/>
<xdoc:unGrabClassLoader/>
</goal>
<!-- ================================================================== -->
<!-- J E L L Y D O C U M E N T A T I O N -->
<!-- ================================================================== -->
<goal name="xdoc:jelly-init" description="Set up jelly xdoc requirements">
<tstamp>
<format property="mavenCurrentYear" pattern="yyyy"/>
</tstamp>
<!-- Set the current time in a locale-sensitive manner (pattern/locale) -->
<tstamp>
<format property="build.date" pattern="${maven.xdoc.date.format}"
locale="${maven.xdoc.date.locale}"/>
</tstamp>
<!-- Set the current time to display the date in the current locale -->
<j:useBean var="now" class="java.util.Date"/>
</goal>
<goal name="xdoc:register-reports">
<!--
| We need to have each <report> register itself with us so we can
| build up our navbar. To do this, we call the plugin:register
| goal on each report plugin.
|-->
<j:if test="${!pom.reports.isEmpty()}">
<j:forEach var="report" items="${pom.reports}">
<attainGoal name="${report}:register"/>
</j:forEach>
</j:if>
<!-- If the descriptor is empty, use these as defaults -->
<j:if test="${pom.reports.isEmpty()}">
<attainGoal name="maven-jdepend-plugin:register"/>
<attainGoal name="maven-checkstyle-plugin:register"/>
<attainGoal name="maven-changes-plugin:register"/>
<attainGoal name="maven-changelog-plugin:register"/>
<attainGoal name="maven-developer-activity-plugin:register"/>
<attainGoal name="maven-file-activity-plugin:register"/>
<attainGoal name="maven-license-plugin:register"/>
<attainGoal name="maven-javadoc-plugin:register"/>
<attainGoal name="maven-jxr-plugin:register"/>
<attainGoal name="maven-junit-report-plugin:register"/>
<attainGoal name="maven-linkcheck-plugin:register"/>
<attainGoal name="maven-tasklist-plugin:register"/>
</j:if>
</goal>
<goal name="xdoc:jelly-transform"
prereqs="xdoc:init, xdoc:jelly-init, xdoc:register-reports"
description="transform xdocs using jelly/jsl rather than dvsl">
<j:set var="destdir" value="${maven.docs.dest}"/>
<j:set var="outputencoding" value="${maven.docs.outputencoding}"/>
<!-- need to parse navigation into $nav -->
<!-- mapper for determining output file name -->
<j:new var="mapper" className="org.apache.maven.util.CaseInsensitiveGlobPatternMapper"/>
<!-- path tool for relative processing -->
<j:useBean var="pathTool" class="org.apache.maven.util.DVSLPathTool"/>
<!-- tool for loading resources from the class loader -->
<j:useBean class="org.apache.maven.util.ResourceBean" var="resourceTool"/>
<!-- determine which stylesheet to use -->
<j:set var="stylesheet" value="${maven.xdoc.jsl}"/>
<j:if test="${empty(stylesheet)}">
<j:set var="stylesheet" value="${resourceTool.findResource('plugin-resources/site.jsl')}"/>
<j:if test="${empty(stylesheet)}">
<log:warn>Could not load the JSL stylesheet 'site.jsl' on the classpath</log:warn>
<j:set var="stylesheet" value="./site.jsl"/>
</j:if>
</j:if>
<util:available file="${maven.gen.docs}">
<log:info>About to use JSL stylesheet ${stylesheet}</log:info>
<!-- perform JSL on generated docs -->
<doc:performJSL srcdir="${maven.gen.docs}" destdir="${maven.docs.dest}"/>
</util:available>
<!-- perform JSL on user provided docs -->
<j:if test="${maven.docs.src.available}">
<log:info>
Transforming user supplied documentation.
</log:info>
<doc:performJSLTransform srcdir="${maven.docs.src}" destdir="${maven.docs.dest}"/>
</j:if>
</goal>
<!--
! This is required as the linkchecker runs as a final pass over the generated
! document tree.
! FIXME: Why isn't this in linkcheck?
!-->
<goal name="xdoc:performJSL"
description="Allows the LinkCheck plugin to xdoc a single directory">
<maven:pluginVar var="maven.xdoc.src" plugin="maven-linkcheck-plugin" property="maven.xdoc.src" />
<doc:performJSL
srcdir="${maven.xdoc.src}"
destdir="${maven.docs.dest}"/>
</goal>
<goal name="xdoc:dump-report-settings">
<echo>Dumping report settings</echo>
<maven:pluginVar var="reports" plugin="maven-xdoc-plugin" property="reports" />
<j:forEach var="report" items="${reports}">
<echo>Report: ${report}</echo>
</j:forEach>
</goal>
<goal name="xdoc:clean"
description="Remove all extra xdoc artifacts">
<ant:delete file="${basedir}/velocity.log" quiet="true" failonerror="false"/>
<ant:delete file="${basedir}/velocity.log.1" quiet="true" failonerror="false"/>
</goal>
<!-- Used to clean the directory ${user.home}/.maven/cache/maven-xdoc-plugin-XXX/plugin-resources/temp/ -->
<goal name="xdoc:clean-user-bundles"
description="Clean the user bundles in the plugin resources">
<delete>
<fileset dir="${plugin.resources}/temp" includes="${maven.xdoc.bundle}*"/>
</delete>
</goal>
<preGoal name="clean:clean">
<attainGoal name="xdoc:clean" />
</preGoal>
</project>