maven-plugins/pdf/plugin.jelly

265 lines
13 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!--
/*
* Copyright 2001-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.
*/
-->
<project xmlns:j="jelly:core" xmlns:u="jelly:util" xmlns:ant="jelly:ant" xmlns:maven="jelly:maven" xmlns:doc="doc">
<goal name="maven-pdf-plugin:register" description="Register the pdf generation during site goal.">
<doc:registerReport name="PDF" pluginName="maven-pdf-plugin" target="_blank" description="Documentation in PDF format."/>
</goal>
<goal name="maven-pdf-plugin:deregister" description="Deregister the pdf generation.">
<doc:deregisterReport name="PDF"/>
</goal>
<goal name="maven-pdf-plugin:report" description="Called by xdoc to execute the pdf goal.">
<!--
using a postgoal so that maven generated reports are on place
(xdoc:generate-from-pom is called after report generation)
-->
<postGoal name="site">
<attainGoal name="pdf"/>
</postGoal>
</goal>
<goal name="pdf:init" prereqs="xdoc:init">
<!-- xdoc plugin properties -->
<maven:get var="maven.xdoc.src" plugin="maven-xdoc-plugin" property="maven.docs.src"/>
<maven:get var="maven.xdoc.dest" plugin="maven-xdoc-plugin" property="maven.docs.dest"/>
<maven:get var="maven.xdoc.gen" plugin="maven-xdoc-plugin" property="maven.gen.docs"/>
<maven:get var="maven.xdoc.date.format" plugin="maven-xdoc-plugin" property="maven.xdoc.date.format"/>
<maven:get var="maven.xdoc.date.locale" plugin="maven-xdoc-plugin" property="maven.xdoc.date.locale"/>
<tstamp>
<format property="maven.pdf.cover.date" pattern="${maven.xdoc.date.format}" locale="${maven.xdoc.date.locale}"/>
<format property="mavenCurrentYear" pattern="yyyy"/>
</tstamp>
<j:set var="image" value="${maven.pdf.projectLogo}"/>
<j:if test="${!image.startsWith('http://') and !image.startsWith('https://')}">
<j:if test="${image.startsWith('/')}" trim="yes">
<j:set var="image" value="${image.substring(1)}"/>
</j:if>
<j:set var="maven.pdf.projectLogo" value="${image}"/>
</j:if>
<j:set var="image" value="${maven.pdf.companyLogo}"/>
<j:if test="${!image.startsWith('http://') and !image.startsWith('https://')}">
<j:if test="${image.startsWith('/')}" trim="yes">
<j:set var="image" value="${image.substring(1)}"/>
</j:if>
<j:set var="maven.pdf.companyLogo" value="${image}"/>
</j:if>
<!-- internal variables -->
<j:set var="internal_pdf_workingDir" value="${maven.build.dir}/pdf"/>
<j:set var="java_version" value="${java.specification.version}"/>
<j:set var="maven_version" value="${maven.application.version}"/>
<j:if test="${maven.pdf.debug}">
<ant:echo>
### Debug mode is on ###
==============================
=== xdoc plugin properties ===
==============================
maven.docs.src = [${maven.xdoc.src}]
maven.docs.dest = [${maven.xdoc.dest}]
maven.gen.docs = [${maven.xdoc.gen}]
maven.xdoc.date.format = [${maven.xdoc.date.format}]
maven.xdoc.date.locale = [${maven.xdoc.date.locale}]
==============================
=== pdf plugin properties ===
==============================
maven.pdf.confidential = [${maven.pdf.confidential}]
maven.pdf.paperType = [${maven.pdf.paperType}]
maven.pdf.companyIncName = [${maven.pdf.companyIncName}]
maven.pdf.copyrightYear = [${maven.pdf.copyrightYear}]
maven.pdf.imageDpi = [${maven.pdf.imageDpi}]
maven.pdf.debug = [${maven.pdf.debug}]
maven.pdf.navigationFile = [${maven.pdf.navigationFile}]
maven.pdf.navigationFilePath = [${maven.pdf.navigationFilePath}]
maven.pdf.pdfName = [${maven.pdf.pdfName}]
maven.pdf.cover.projectCompany = [${maven.pdf.cover.projectCompany}]
maven.pdf.cover.projectName = [${maven.pdf.cover.projectName}]
maven.pdf.cover.type = [${maven.pdf.cover.type}]
maven.pdf.cover.version = [${maven.pdf.cover.version}]
maven.pdf.cover.date = [${maven.pdf.cover.date}]
maven.pdf.projectLogo = [${maven.pdf.projectLogo}]
maven.pdf.companyLogo = [${maven.pdf.companyLogo}]
maven.jar.jimi = [${maven.jar.jimi}]
maven.jar.jaicore = [${maven.jar.jaicore}]
maven.jar.jaicodec = [${maven.jar.jaicodec}]
==============================
=== pdf internal variables ===
==============================
internal_pdf_workingDir = [${internal_pdf_workingDir}]
java_version = [${java_version}]
maven_version = [${maven_version}]
</ant:echo>
</j:if>
<j:if test="not ${maven.pdf.debug}">
<ant:echo>
### Debug mode is off ###
</ant:echo>
</j:if>
<!-- Create working directory -->
<mkdir dir="${internal_pdf_workingDir}"/>
</goal>
<goal name="fo" prereqs="fo:fo" description="This simply pre-requisites the fo:fo goal. "/>
<goal name="fo:fo" prereqs="pdf:prepare" description="Generates an fo xml document from the ${maven.pdf.navigationFile} file supplied as part of the documentation.">
<echo>Generating ${internal_pdf_workingDir}/project.fo from ${maven.pdf.navigationFilePath}/${maven.pdf.navigationFile} ...</echo>
<available file="${maven.pdf.navigationFilePath}/${maven.pdf.navigationFile}" property="maven.fo.navigation.available"/>
<fail message="PDF generation cannot complete as ${maven.pdf.navigationFilePath}/${maven.pdf.navigationFile} is missing" unless="maven.fo.navigation.available"/>
<j:if test="${empty(maven.pdf.copyrightYear)}">
<j:set var="maven.pdf.copyrightYear">
<j:if test="${!empty(pom.organization.name)}">
<j:if test="${!empty(pom.inceptionYear)}">
<j:if test="${pom.inceptionYear == mavenCurrentYear}">${mavenCurrentYear}</j:if>
<j:if test="${pom.inceptionYear != mavenCurrentYear}">${pom.inceptionYear}-${mavenCurrentYear}</j:if>
</j:if>
<j:if test="${empty(pom.inceptionYear)}">${mavenCurrentYear}</j:if>
</j:if>
</j:set>
</j:if>
<java classname="org.apache.xalan.xslt.Process" dir="${internal_pdf_workingDir}" fork="true" failonerror="true">
<arg value="-IN"/>
<arg value="${maven.pdf.navigationFilePath}/${maven.pdf.navigationFile}"/>
<arg value="-XSL"/>
<arg value="${plugin.resources}/project2fo.xslt"/>
<arg value="-OUT"/>
<arg value="${internal_pdf_workingDir}/project.fo"/>
<arg value="-PARAM"/>
<arg value="basePath"/>
<arg value="${internal_pdf_workingDir}"/>
<arg value="-PARAM"/>
<arg value="confidential"/>
<arg value="${maven.pdf.confidential}"/>
<arg value="-PARAM"/>
<arg value="paperType"/>
<arg value="${maven.pdf.paperType}"/>
<arg value="-PARAM"/>
<arg value="companyIncName"/>
<arg value="${maven.pdf.companyIncName}"/>
<arg value="-PARAM"/>
<arg value="publicationYear"/>
<arg value="${maven.pdf.copyrightYear}"/>
<arg value="-PARAM"/>
<arg value="-PARAM coverProjectCompany ${maven.pdf.cover.projectCompany}"/>
<arg value="${maven.pdf.cover.projectCompany}"/>
<arg value="-PARAM"/>
<arg value="coverProjectName"/>
<arg value="${maven.pdf.cover.projectName}"/>
<arg value="-PARAM"/>
<arg value="coverType"/>
<arg value="${maven.pdf.cover.type}"/>
<arg value="-PARAM"/>
<arg value="coverVersion"/>
<arg value="${maven.pdf.cover.version}"/>
<arg value="-PARAM"/>
<arg value="coverDate"/>
<arg value="${maven.pdf.cover.date}"/>
<arg value="-PARAM"/>
<arg value="companyLogo"/>
<arg value="${maven.pdf.companyLogo}"/>
<arg value="-PARAM"/>
<arg value="projectLogo"/>
<arg value="${maven.pdf.projectLogo}"/>
<arg value="-PARAM"/>
<arg value="imageDpi"/>
<arg value="${maven.pdf.imageDpi}"/>
<arg value="-PARAM"/>
<arg value="debug"/>
<arg value="${maven.pdf.debug}"/>
<classpath>
<pathelement location="${plugin.getDependencyPath('xerces')}"/>
<pathelement location="${plugin.getDependencyPath('xalan')}"/>
<j:if test="${java_version.compareTo('1.4') lt 0}">
<pathelement location="${plugin.getDependencyPath('xml-apis')}"/>
</j:if>
</classpath>
</java>
</goal>
<goal name="pdf" prereqs="fo:fo,pdf:prepare,pdf:pdf" description="This is the default goal of the plugin and simply pre-requisites the pdf:pdf goal. "/>
<goal name="pdf:prepare" prereqs="pdf:init" description="Stages all files needed to generate the PDF">
<!-- First, copy all of the generated xdocs -->
<copy todir="${internal_pdf_workingDir}" force="true" overwrite="true">
<fileset dir="${maven.xdoc.gen}">
<include name="**/*.*"/>
</fileset>
</copy>
<!-- Copy all of the user-supplied xdocs -->
<copy todir="${internal_pdf_workingDir}" force="true" overwrite="true">
<fileset dir="${maven.xdoc.src}">
<include name="**/*.*"/>
</fileset>
</copy>
<!-- Then, copy all of images generated -->
<copy todir="${internal_pdf_workingDir}" force="true" overwrite="true">
<fileset dir="${maven.xdoc.dest}">
<include name="**/*.gif"/>
<include name="**/*.jpg"/>
<include name="**/*.png"/>
</fileset>
</copy>
<!-- Finally, copy the FOP config file and all of the fonts -->
<copy todir="${internal_pdf_workingDir}" force="true" overwrite="true">
<fileset dir="${plugin.resources}">
<include name="userconfig.xml"/>
<include name="fonts/*.*"/>
</fileset>
</copy>
</goal>
<goal name="pdf:pdf" description="Generates a PDF document containing all project documentation. The PDF is generated from the .fo file generated in the fo:fo goal." prereqs="pdf:prepare">
<echo>Generating ${internal_pdf_workingDir}/${maven.pdf.pdfName} ...</echo>
<echo>Config file: ${internal_pdf_workingDir}/userconfig.xml</echo>
<java classname="org.apache.fop.apps.Fop" fork="true" failonerror="true">
<sysproperty key="javax.xml.parsers.SAXParserFactory" value="org.apache.xerces.jaxp.SAXParserFactoryImpl"/>
<sysproperty key="javax.xml.transform.TransformerFactory" value="org.apache.xalan.processor.TransformerFactoryImpl"/>
<!-- System proxies for jdk 1.5+ -->
<sysproperty key="java.net.useSystemProxies" value="true"/>
<!-- Proxy settings -->
<j:if test="${!empty(maven.proxy.host)}">
<jvmarg value="-DproxySet=true"/>
<jvmarg value="-DproxyHost=${maven.proxy.host}"/>
<jvmarg value="-DproxyPort=${maven.proxy.port}"/>
<jvmarg value="-Dhttp.proxyHost=${maven.proxy.host}"/>
<jvmarg value="-Dhttp.proxyPort=${maven.proxy.port}"/>
<jvmarg value="-Dhttp.proxyUser=${maven.proxy.username}"/>
<jvmarg value="-Dhttp.proxyPassword=${maven.proxy.password}"/>
<jvmarg value="-Dhttps.proxyHost=${maven.proxy.host}"/>
<jvmarg value="-Dhttps.proxyPort=${maven.proxy.port}"/>
<jvmarg value="-Dftp.proxyHost=${maven.proxy.host}"/>
<jvmarg value="-Dftp.proxyPort=${maven.proxy.port}"/>
</j:if>
<arg value="-c"/>
<arg value="${internal_pdf_workingDir}/userconfig.xml"/>
<j:if test="${maven.pdf.debug}">
<arg value="-d"/>
</j:if>
<arg value="-fo"/>
<arg value="${internal_pdf_workingDir}/project.fo"/>
<arg value="-pdf"/>
<arg value="${internal_pdf_workingDir}/${maven.pdf.pdfName}"/>
<classpath>
<pathelement location="${plugin.getDependencyPath('fop')}"/>
<j:if test="${java_version.compareTo('1.4') lt 0}">
<pathelement location="${plugin.getDependencyPath('xml-apis')}"/>
</j:if>
<pathelement location="${plugin.getDependencyPath('xerces')}"/>
<pathelement location="${plugin.getDependencyPath('xalan')}"/>
<pathelement location="${plugin.getDependencyPath('batik')}"/>
<pathelement location="${plugin.getDependencyPath('avalon-framework')}"/>
<pathelement location="${maven.jar.jimi}"/>
<pathelement location="${maven.jar.jaicore}"/>
<pathelement location="${maven.jar.jaicodec}"/>
</classpath>
</java>
<copy todir="${maven.xdoc.dest}" file="${internal_pdf_workingDir}/${maven.pdf.pdfName}"/>
</goal>
</project>