Apply MAVEN-904 with some changes for reporting.
Add a test project to test new functionality. git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@114180 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f0ce20ec34
commit
a7badd88b1
122
faq/plugin.jelly
122
faq/plugin.jelly
@ -5,58 +5,71 @@
|
||||
xmlns:util="jelly:util"
|
||||
xmlns:x="jelly:xml"
|
||||
xmlns:ant="jelly:ant"
|
||||
xmlns:doc="doc">
|
||||
xmlns:define="jelly:define"
|
||||
xmlns:doc="doc"
|
||||
xmlns:faq="faq">
|
||||
|
||||
<goal name="maven-faq-plugin:register">
|
||||
<doc:registerReport
|
||||
name="FAQs"
|
||||
pluginName="faq"
|
||||
description="Frequently Asked Questions."
|
||||
link="faq"/>
|
||||
</goal>
|
||||
<define:taglib uri="faq">
|
||||
|
||||
<goal name="maven-faq-plugin:deregister">
|
||||
<doc:deregisterReport name="FAQs"/>
|
||||
</goal>
|
||||
<!--
|
||||
Transforms *.fml files into *.xml xdoc files.
|
||||
parameters:
|
||||
srcdir: directory where to find *.fml files under
|
||||
destdir: directory where to produce output xdoc xml files
|
||||
-->
|
||||
<define:tag name="performTransformation">
|
||||
<!-- NOTE: part of this tag implementation is based on jelly-code from xdoc-plugin -->
|
||||
|
||||
<goal name="faq:report"
|
||||
description="Generate FAQs">
|
||||
<attainGoal name="faq"/>
|
||||
</goal>
|
||||
<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()}"/>
|
||||
|
||||
<!--
|
||||
| @TODO: Make this a tag and transform multiple *.fml files
|
||||
-->
|
||||
<goal name="faq"
|
||||
description="Generates an FAQ xdoc file from an FAQ XML document">
|
||||
<!-- construct a mapper, which is to help map input files to output path -->
|
||||
<util:replace var="fromPattern" oldChar="\" newChar="/" value="${srcdir}/*.fml"/>
|
||||
<util:replace var="toPattern" oldChar="\" newChar="/" value="${destdir}/*.xml"/>
|
||||
<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}"/>
|
||||
|
||||
<j:set var="destfile" value="${maven.faq.dest.file}"/>
|
||||
<j:if test="${empty(destfile)}">
|
||||
<j:set var="destfile" value="${maven.build.dir}/generated-xdocs/faq.xml"/>
|
||||
</j:if>
|
||||
<!-- construct a mapper, which is to help map input dirs to output dirs (so we can create output paths) -->
|
||||
<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}"/>
|
||||
|
||||
<ant:mkdir dir="${maven.build.dir}/generated-xdocs"/>
|
||||
<!-- scan for all .fml faq source files -->
|
||||
<ant:fileScanner var="faqFilenames">
|
||||
<ant:fileset dir="${srcdir}">
|
||||
<ant:patternset>
|
||||
<ant:include name="**/*.fml"/>
|
||||
</ant:patternset>
|
||||
</ant:fileset>
|
||||
</ant:fileScanner>
|
||||
|
||||
<j:set var="srcfile" value="${maven.faq.src.file}"/>
|
||||
<j:if test="${empty(srcfile)}">
|
||||
<j:set var="srcfile" value="${basedir}/xdocs/faq.fml"/>
|
||||
</j:if>
|
||||
<j:set var="outputencoding" value="${maven.docs.outputencoding}"/>
|
||||
|
||||
<util:file var="srcfileFile" name="${srcfile}"/>
|
||||
<j:set var="srcfile" value="${srcfileFile.canonicalPath}"/>
|
||||
<util:file var="destfileFile" name="${destfile}"/>
|
||||
<j:set var="destfile" value="${destfileFile.canonicalPath}"/>
|
||||
<!-- loop each found .fml file and produce output .xml xdocs file -->
|
||||
<j:forEach var="faqFile" items="${faqFilenames.iterator()}">
|
||||
<!-- first, create the relative output-dir into the destdir -->
|
||||
<!-- e.g.: if source file is "xdocs/faqs/foofaq.fml" we need to create "target/generated-xdocs/faqs" -->
|
||||
<util:replace var="inDirForward" oldChar="\" newChar="/" value="${faqFile.parent}"/>
|
||||
<j:set var="outDir" value="${dirMapper.mapFileName(inDirForward).0}"/>
|
||||
<mkdir dir="${outDir}"/>
|
||||
|
||||
<j:set var="outputencoding" value="${maven.docs.outputencoding}"/>
|
||||
<!-- generate output file name -->
|
||||
<util:replace var="outFileForward" oldChar="\" newChar="/" value="${faqFile.toString()}"/>
|
||||
<j:set var="outFile" value="${mapper.mapFileName(outFileForward).0}"/>
|
||||
|
||||
<util:available file="${srcfile}">
|
||||
<j:set var="srcFileExists" value="true" />
|
||||
</util:available>
|
||||
<j:if test="${srcFileExists == 'true'}">
|
||||
<x:parse var="doc" xml="${srcfileFile}"/>
|
||||
<x:set var="root" select="$doc/*"/>
|
||||
<echo>Generating ${outFile} from ${faqFile}</echo>
|
||||
|
||||
<j:file name="${destfile}" encoding="${outputencoding}" outputMode="xml">
|
||||
<!-- xml-parse .fml faq file -->
|
||||
<x:parse var="doc" xml="${faqFile}"/>
|
||||
<x:set var="root" select="$doc/*"/>
|
||||
|
||||
<!-- produce a output xdoc xml file from parsed .fml source -->
|
||||
<j:file name="${outFile}" encoding="${outputencoding}" outputMode="xml">
|
||||
<document>
|
||||
|
||||
<properties>
|
||||
@ -102,8 +115,31 @@
|
||||
</x:forEach>
|
||||
</body>
|
||||
</document>
|
||||
</j:file>
|
||||
</j:if>
|
||||
</j:file>
|
||||
</j:forEach>
|
||||
</define:tag>
|
||||
|
||||
</define:taglib>
|
||||
|
||||
<goal name="maven-faq-plugin:register">
|
||||
<doc:registerReport
|
||||
name="FAQs"
|
||||
pluginName="maven-faq-plugin"
|
||||
description="Frequently Asked Questions."
|
||||
link="faq"/>
|
||||
</goal>
|
||||
|
||||
<goal name="maven-faq-plugin:deregister">
|
||||
<doc:deregisterReport name="FAQs"/>
|
||||
</goal>
|
||||
|
||||
<goal name="maven-faq-plugin:report"
|
||||
description="Generate FAQs">
|
||||
<attainGoal name="faq"/>
|
||||
</goal>
|
||||
|
||||
<goal name="faq" description="Generates FAQ xdoc files from FAQ XML documents">
|
||||
<faq:performTransformation srcdir="${maven.faq.src}" destdir="${maven.faq.dest}" />
|
||||
</goal>
|
||||
|
||||
</project>
|
||||
|
||||
5
faq/plugin.properties
Normal file
5
faq/plugin.properties
Normal file
@ -0,0 +1,5 @@
|
||||
# Where source *.fml files are looked for
|
||||
maven.faq.src=${basedir}/xdocs
|
||||
|
||||
# Destination directory where output xdocs file are produced
|
||||
maven.faq.dest=${maven.build.dir}/generated-xdocs
|
||||
2
faq/src/plugin-test/.cvsignore
Normal file
2
faq/src/plugin-test/.cvsignore
Normal file
@ -0,0 +1,2 @@
|
||||
*.log
|
||||
target
|
||||
26
faq/src/plugin-test/maven.xml
Normal file
26
faq/src/plugin-test/maven.xml
Normal file
@ -0,0 +1,26 @@
|
||||
<project xmlns:util="jelly:util"
|
||||
xmlns:j="jelly:core">
|
||||
|
||||
<goal name="testPlugin" prereqs="clean,test-faq">
|
||||
<!-- bad xdoc leaves files open <attainGoal name="clean"/> -->
|
||||
</goal>
|
||||
|
||||
<goal name="test-faq">
|
||||
<attainGoal name="site"/>
|
||||
|
||||
<j:set var="expectedFile"
|
||||
value="${maven.docs.dest}/faq.html"/>
|
||||
<util:file var="file" name="${expectedFile}" />
|
||||
<j:if test="${!(file.exists())}">
|
||||
<fail>${expectedFile} not generated</fail>
|
||||
</j:if>
|
||||
|
||||
<j:set var="expectedFile"
|
||||
value="${maven.docs.dest}/faq2.html"/>
|
||||
<util:file var="file" name="${expectedFile}" />
|
||||
<j:if test="${!(file.exists())}">
|
||||
<fail>${expectedFile} not generated</fail>
|
||||
</j:if>
|
||||
|
||||
</goal>
|
||||
</project>
|
||||
43
faq/src/plugin-test/project.xml
Normal file
43
faq/src/plugin-test/project.xml
Normal file
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project>
|
||||
<pomVersion>3</pomVersion>
|
||||
<id>test-maven-faq-plugin</id>
|
||||
<name>Test project for Maven Faq Plugin</name>
|
||||
<groupId>maven</groupId>
|
||||
<currentVersion>1.0-SNAPSHOT</currentVersion>
|
||||
<organization>
|
||||
<name>Apache Software Foundation</name>
|
||||
<url>http://www.apache.org/</url>
|
||||
<logo>http://maven.apache.org/images/jakarta-logo-blue.gif</logo>
|
||||
</organization>
|
||||
<inceptionYear>2001</inceptionYear>
|
||||
<package>org.apache.maven</package>
|
||||
<logo>http://maven.apache.org/images/maven.jpg</logo>
|
||||
<description>Test for Maven Faq plugin</description>
|
||||
<shortDescription>Test for Maven Faq plugin</shortDescription>
|
||||
<url>http://maven.apache.org/reference/plugins/faq/</url>
|
||||
<siteDirectory>/www/maven.apache.org/reference/plugins/faq/</siteDirectory>
|
||||
<repository>
|
||||
<connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:maven/src/plugins-build/faq/</connection>
|
||||
<url>http://cvs.apache.org/viewcvs/maven/src/plugins-build/faq/</url>
|
||||
</repository>
|
||||
<developers>
|
||||
<developer>
|
||||
<name>dIon Gillard</name>
|
||||
<id>dion</id>
|
||||
<email>dion@multitask.com.au</email>
|
||||
<organization>Multitask Consulting</organization>
|
||||
<roles>
|
||||
<role>Documentation</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<build>
|
||||
</build>
|
||||
|
||||
<reports>
|
||||
<report>maven-faq-plugin</report>
|
||||
</reports>
|
||||
</project>
|
||||
42
faq/src/plugin-test/xdocs/faq.fml
Normal file
42
faq/src/plugin-test/xdocs/faq.fml
Normal file
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faqs title="Frequently Asked Questions">
|
||||
|
||||
<part id="general">
|
||||
<title>General</title>
|
||||
|
||||
<faq id="whats-foo">
|
||||
<question>
|
||||
What is Foo?
|
||||
</question>
|
||||
<answer>
|
||||
<p>some markup goes here</p>
|
||||
|
||||
<source>some source code</source>
|
||||
|
||||
<p>some markup goes here</p>
|
||||
</answer>
|
||||
</faq>
|
||||
|
||||
<faq id="whats-bar">
|
||||
<question>
|
||||
What is Bar?
|
||||
</question>
|
||||
<answer>
|
||||
<p>some markup goes here</p>
|
||||
</answer>
|
||||
</faq>
|
||||
</part>
|
||||
|
||||
<part id="install">
|
||||
<title>Installation</title>
|
||||
|
||||
<faq id="how-install">
|
||||
<question>
|
||||
How do I install Foo?
|
||||
</question>
|
||||
<answer>
|
||||
<p>some markup goes here</p>
|
||||
</answer>
|
||||
</faq>
|
||||
</part>
|
||||
</faqs>
|
||||
42
faq/src/plugin-test/xdocs/faq2.fml
Normal file
42
faq/src/plugin-test/xdocs/faq2.fml
Normal file
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faqs title="Frequently Asked Questions">
|
||||
|
||||
<part id="general">
|
||||
<title>General</title>
|
||||
|
||||
<faq id="whats-foo">
|
||||
<question>
|
||||
What is Foo?
|
||||
</question>
|
||||
<answer>
|
||||
<p>some markup goes here</p>
|
||||
|
||||
<source>some source code</source>
|
||||
|
||||
<p>some markup goes here</p>
|
||||
</answer>
|
||||
</faq>
|
||||
|
||||
<faq id="whats-bar">
|
||||
<question>
|
||||
What is Bar?
|
||||
</question>
|
||||
<answer>
|
||||
<p>some markup goes here</p>
|
||||
</answer>
|
||||
</faq>
|
||||
</part>
|
||||
|
||||
<part id="install">
|
||||
<title>Installation</title>
|
||||
|
||||
<faq id="how-install">
|
||||
<question>
|
||||
How do I install Foo?
|
||||
</question>
|
||||
<answer>
|
||||
<p>some markup goes here</p>
|
||||
</answer>
|
||||
</faq>
|
||||
</part>
|
||||
</faqs>
|
||||
Loading…
x
Reference in New Issue
Block a user