maven-plugins/linkcheck/plugin.jelly
2004-07-26 16:16:35 +00:00

123 lines
4.0 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:j="jelly:core"
xmlns:define="jelly:define"
xmlns:linkcheck="linkcheck"
xmlns:maven="jelly:maven"
xmlns:x="jelly:xml"
xmlns:util="jelly:util"
xmlns:doc="doc">
<goal name="maven-linkcheck-plugin:register">
<doc:registerReport
name="Link Check Report"
pluginName="maven-linkcheck-plugin"
link="linkcheck"
description="Report on the validity of all links in the documentation."/>
</goal>
<goal name="maven-linkcheck-plugin:deregister">
<doc:deregisterReport name="Link Check Report"/>
</goal>
<define:taglib uri="linkcheck">
<define:jellybean
name="linkcheck"
className="org.apache.maven.linkcheck.LinkCheck"
method="doExecute"
/>
</define:taglib>
<!-- ================================================================== -->
<!-- C R E A T E L I N K C H E C K X M L R E P O R T -->
<!-- ================================================================== -->
<!-- The reason for the odd goal configuration is this:
We really don't want the link checker to run until everything else is complete
-->
<goal name="maven-linkcheck-plugin:report">
<copy file="${plugin.resources}/linkcheck-temp.xml"
toFile="${maven.gen.docs}/linkcheck.xml"/>
</goal>
<postGoal name="xdoc:jelly-transform">
<maven:pluginVar var="reports" plugin="maven-xdoc-plugin" property="reports" />
<j:set var="online">${maven.mode.online}</j:set>
<j:if test="${online.trim().length() > 0}">
<j:forEach var="report" items="${reports}">
<!-- FIXME: Why special case linkcheck - fix it! -->
<j:if test="${report.get('pluginName').equals('maven-linkcheck-plugin')}">
<attainGoal name="maven-linkcheck-plugin:report-real"/>
</j:if>
</j:forEach>
</j:if>
</postGoal>
<goal
name="maven-linkcheck-plugin:report-real"
description="Generate link check results and then transform to HTML">
<mkdir dir="${maven.build.dir}/linkcheck"/>
<mkdir dir="${maven.build.dir}/linkcheck/docs"/>
<linkcheck:linkcheck
project="${pom}"
cache="${maven.linkcheck.cache}"
exclude="${maven.linkcheck.exclude}"
basedir="${maven.docs.dest}"
output="${maven.build.dir}/linkcheck/linkcheck-results.xml"
outputEncoding="${maven.docs.outputencoding}"
/>
<!-- Do we want an error to be generated if there are link errors? -->
<j:if test="${context.getVariable('maven.linkcheck.failonerror') == 'true'}">
<!-- Are there any error? -->
<util:file var="resultsAsFile"
name="${maven.build.dir}/linkcheck/linkcheck-results.xml"/>
<x:parse var="doc" xml="${resultsAsFile}"/>
<x:if select="$doc//unsuccessful[string() != '0'] | $doc//status[string() != 'OK']">
<fail>There are broken links.</fail>
</x:if>
</j:if>
<doc:jslFile
input="${maven.build.dir}/linkcheck/linkcheck-results.xml"
output="${maven.build.dir}/linkcheck/docs/linkcheck.xml"
stylesheet="${plugin.resources}/linkcheck.jsl"
outputMode="xml"
prettyPrint="true"
/>
<doc:jslToSite srcdir="${maven.build.dir}/linkcheck/docs"/>
</goal>
<goal name="maven-linkcheck-plugin:clearcache"
description="Removes the cache file">
<delete file="${maven.linkcheck.cache}"/>
</goal>
</project>