[jboss-svn-commits] JBL Code SVN: r13024 - in labs/jbossbuild/maven-plugins/trunk: maven-jdocbook-plugin and 21 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Jul 2 22:04:15 EDT 2007
Author: steve.ebersole at jboss.com
Date: 2007-07-02 22:04:15 -0400 (Mon, 02 Jul 2007)
New Revision: 13024
Added:
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/pom.xml
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/AbstractDocBookMojo.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/DocBookSupportResourcesMojo.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/Format.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/GenerationMojo.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/Options.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/PackageMojo.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/ResourceMojo.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/TestIt.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/TranslationDiffReport.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/RenderingException.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/XSLTException.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/BasicFormatHandler.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/FormatHandler.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/FormatHandlerFactory.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/PdfFormatHandler.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/Formatting.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/NoOpWriter.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/ResourceHelper.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/StaleSourceChecker.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/StandardDocBookFormatSpecification.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/TransformerType.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/TransformerFactory.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/catalog/
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/catalog/AbstractCatalogManager.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/catalog/ExplicitCatalogManager.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/catalog/ImplicitCatalogManager.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/BasicUrnResolver.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/CurrentVersionResolver.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/ExplicitUrnResolver.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/RelativeJarUriResolver.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/ResolverChain.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/VersionResolver.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/BaselineHandler.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/ContentItem.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/ContentItemDescriptor.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/Diff.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/DiffCreator.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/GenerationException.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/IndexReportGenerator.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/TranslationHandler.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/TranslationReportGenerator.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/resources/
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/resources/META-INF/
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/resources/META-INF/plexus/
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/resources/META-INF/plexus/components.xml
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/resources/translation-diff-report.properties
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/docbook-support.apt
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/examples/
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/examples/custom-xslt.apt
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/examples/resource-staging.apt
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/index.apt
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/usage.apt
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/site.xml
Log:
moving jdocbook plugin over to jboss svn repo
Property changes on: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin
___________________________________________________________________
Name: svn:ignore
+ target
*.ipr
*.iws
*.iml
.classpath
.project
.nbattrs
*.log
.clover
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/pom.xml
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/pom.xml (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/pom.xml 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,227 @@
+<?xml version="1.0"?>
+<!--
+ ~ Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, v. 2.1. This program is distributed in the
+ ~ hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ ~ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details. You should have received a
+ ~ copy of the GNU Lesser General Public License, v.2.1 along with this
+ ~ distribution; if not, write to the Free Software Foundation, Inc.,
+ ~ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ ~
+ ~ Red Hat Author(s): Steve Ebersole
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jdocbook-plugin</artifactId>
+ <packaging>maven-plugin</packaging>
+ <version>2.0-SNAPSHOT</version>
+ <name>Maven Docbook Plugin</name>
+ <description>This plugin adds support for Docbook transformations to Maven.</description>
+
+ <inceptionYear>2007</inceptionYear>
+ <organization>
+ <name>JBoss, a division of Red Hat, Inc</name>
+ <url>http://jboss.org/</url>
+ </organization>
+
+ <developers>
+ <developer>
+ <name>Steve Ebersole</name>
+ <email>steve at hibernate.org</email>
+ <organization>JBoss, a division of Red Hat, Inc</organization>
+ <organizationUrl>http://jboss.org</organizationUrl>
+ <timezone>-5</timezone>
+ </developer>
+ </developers>
+
+ <licenses>
+ <license>
+ <name>GNU Lesser General Public License</name>
+ <url>http://www.gnu.org/copyleft/lesser.html</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/labs/labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin</connection>
+ <developerConnection>scm:svn:https://svn.labs.jboss.org/labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin</developerConnection>
+ <url>http://anonsvn.jboss.org/repos/labs/labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin</url>
+ </scm>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.4</source>
+ <target>1.4</target>
+ <encoding>UTF-8</encoding>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <minmemory>128m</minmemory>
+ <maxmemory>512</maxmemory>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jxr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <dependencies>
+ <!-- todo : can we remove this and rely on the user project defining which docbook to use? -->
+ <dependency>
+ <groupId>net.sf.docbook</groupId>
+ <artifactId>docbook</artifactId>
+ <version>1.72.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.reporting</groupId>
+ <artifactId>maven-reporting-api</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.reporting</groupId>
+ <artifactId>maven-reporting-impl</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>1.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-archiver</artifactId>
+ <version>1.0-alpha-7</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-compiler-api</artifactId>
+ <version>1.5.3</version>
+ </dependency>
+ <dependency>
+ <groupId>avalon-framework</groupId>
+ <artifactId>avalon-framework</artifactId>
+ <version>4.1.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.doxia</groupId>
+ <artifactId>doxia-core</artifactId>
+ <version>${doxiaVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.doxia</groupId>
+ <artifactId>doxia-decoration-model</artifactId>
+ <version>${doxiaSiteVersion}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.doxia</groupId>
+ <artifactId>doxia-site-renderer</artifactId>
+ <version>${doxiaSiteVersion}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>xml-resolver</groupId>
+ <artifactId>xml-resolver</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.8.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xmlParserAPIs</artifactId>
+ <version>2.6.2</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>saxon</groupId>
+ <artifactId>saxon</artifactId>
+ <version>6.5.3</version>
+ </dependency>
+
+ <!-- todo : upgrade this to 0.93 or later once the fox: extension element issues are fixed -->
+ <dependency>
+ <groupId>fop</groupId>
+ <artifactId>fop</artifactId>
+ <version>0.20.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>batik</groupId>
+ <artifactId>batik-1.5-fop</artifactId>
+ <version>0.20-5</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.media</groupId>
+ <artifactId>jai-core</artifactId>
+ <version>1.1.3</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.media</groupId>
+ <artifactId>jai-codec</artifactId>
+ <version>1.1.3</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ </dependencies>
+
+ <properties>
+ <doxiaVersion>1.0-alpha-8</doxiaVersion>
+ <doxiaSiteVersion>1.0-alpha-8</doxiaSiteVersion>
+ </properties>
+
+</project>
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/AbstractDocBookMojo.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/AbstractDocBookMojo.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/AbstractDocBookMojo.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,255 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.doxia.siterenderer.Renderer;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectHelper;
+import org.codehaus.plexus.archiver.manager.ArchiverManager;
+import org.jboss.maven.plugins.jdocbook.gen.RenderingException;
+import org.jboss.maven.plugins.jdocbook.gen.XSLTException;
+import org.jboss.maven.plugins.jdocbook.gen.util.Formatting;
+import org.jboss.maven.plugins.jdocbook.gen.util.StandardDocBookFormatSpecification;
+
+/**
+ * Basic support for the various DocBook mojos in this package. Mainly, we are
+ * defining common configuration attributes of the packaging.
+ * <p/>
+ * todo : I'd much prefer to see the "partial artifact coord" stuff go away
+ * and use custom package types to convey this information. This frees the
+ * user from duplicate entry of the information.
+ *
+ * @author Steve Ebersole
+ */
+public abstract class AbstractDocBookMojo extends AbstractMojo {
+ public static final String PLUGIN_NAME = "jboss-docbook";
+
+ /**
+ * INTERNAL : The project being built
+ *
+ * @parameter expression="${project}"
+ * @required
+ * @readonly
+ */
+ protected MavenProject project;
+
+ /**
+ * INTERNAL : The artifacts associated with the dependencies defined as part
+ * of the project to which we are being attached.
+ *
+ * @parameter expression="${project.artifacts}"
+ * @required
+ * @readonly
+ */
+ protected Set projectArtifacts;
+
+ /**
+ * INTERNAL : The artifacts associated to the dependencies defined as part
+ * of our configuration within the project to which we are being attached.
+ *
+ * @parameter expression="${plugin.artifacts}"
+ * @required
+ * @readonly
+ */
+ protected List pluginArtifacts;
+
+ /**
+ * INTERNAL : used to get reference to environemtn Archiver/UnArchiver.
+ *
+ * @parameter expression="${component.org.codehaus.plexus.archiver.manager.ArchiverManager}"
+ * @required
+ * @readonly
+ */
+ protected ArchiverManager archiverManager;
+
+ /**
+ * INTERNAL : used in the translation diff report
+ *
+ * @parameter expression="${component.org.apache.maven.doxia.siterenderer.Renderer}"
+ * @required
+ * @readonly
+ */
+ protected Renderer siteRenderer;
+
+ /**
+ * INTERNAL : used during packaging to attach produced artifacts
+ *
+ * @parameter expression="${component.org.apache.maven.project.MavenProjectHelper}"
+ * @required
+ * @readonly
+ */
+ protected MavenProjectHelper projectHelper;
+
+ /**
+ * The name of the document (relative to sourceDirectory) which is the
+ * document to be rendered.
+ *
+ * @parameter
+ * @required
+ */
+ protected String sourceDocumentName;
+
+ /**
+ * The directory where the sources are located.
+ *
+ * @parameter expression="${basedir}/src/main/docbook"
+ */
+ protected File sourceDirectory;
+
+ /**
+ * The directory containing local images
+ *
+ * @parameter expression="${basedir}/src/main/images"
+ */
+ protected File imagesDirectory;
+
+ /**
+ * The directory containing local css
+ *
+ * @parameter expression="${basedir}/src/main/css"
+ */
+ protected File cssDirectory;
+
+ /**
+ * The directory containing local fonts
+ *
+ * @parameter expression="${basedir}/src/main/fonts"
+ */
+ protected File fontsDirectory;
+
+ /**
+ * The directory where the output will be written.
+ *
+ * @parameter expression="${basedir}/target/docbook"
+ */
+ protected File targetDirectory;
+
+ /**
+ * The directory where "docbook resource" staging occurs. Mainly this is
+ * used for (1) image/css staging for html-based output; (2) base directory
+ * for value of <tt>img.src.path</tt> DocBook XSLT parameter for fop-based
+ * formattings.
+ *
+ * @parameter expression="${basedir}/target/staging"
+ * @required
+ * @readonly
+ */
+ protected File stagingDirectory;
+
+ /**
+ * The formats in which to perform rendering.
+ *
+ * @parameter
+ * @required
+ */
+ protected Format[] formats;
+
+ /**
+ * The artifactId of the master translation (unless, of course, this is the
+ * master translation). It is assumed that the master translation:<ol>
+ * <li>is part of the same groupId</li>
+ * <li>has its source defined as a dependency (classifier = source)</li>
+ * </ol>
+ *
+ * @parameter
+ */
+ protected String masterTranslationArtifactId;
+
+ /**
+ * Local path to the master translation to use for diff reporting.
+ *
+ * @parameter
+ */
+ protected File masterTranslationFile;
+
+ /**
+ * The relative path font configuration to use.
+ *
+ * @parameter
+ */
+ protected String fontConfig;
+
+ /**
+ * Configurable options
+ *
+ * @parameter
+ */
+ protected Options options;
+
+
+ /**
+ * The override method to perform the actual processing of the
+ * mojo.
+ *
+ * @param formattings The fomattings configured for render
+ * @throws RenderingException Indicates problem performing rendering
+ * @throws XSLTException Indicates problem building or executing XSLT transformer
+ */
+ protected abstract void process(Formatting[] formattings) throws RenderingException, XSLTException;
+
+ public final void execute() throws MojoExecutionException, MojoFailureException {
+ try {
+ process( buildFormattings() );
+ }
+ catch ( XSLTException e ) {
+ throw new MojoExecutionException( "XSLT problem", e );
+ }
+ catch ( RenderingException e ) {
+ throw new MojoExecutionException( "Rendering problem", e );
+ }
+ }
+
+ private Formatting[] buildFormattings() {
+ Formatting[] formattings = new Formatting[ formats.length ];
+ for ( int i = 0; i < formats.length; i++ ) {
+ formattings[i] = new Formatting( StandardDocBookFormatSpecification.parse( formats[i].getFormatName() ), formats[i] );
+ }
+ return formattings;
+ }
+
+ protected static interface ArtifactProcessor {
+ public void process(org.apache.maven.artifact.Artifact artifact);
+ }
+
+ protected void processArtifacts(ArtifactProcessor processor) {
+ processProjectArtifacts( processor );
+ processPluginArtifacts( processor );
+ }
+
+ protected void processProjectArtifacts(ArtifactProcessor processor) {
+ processArtifacts( processor, projectArtifacts );
+ }
+
+ protected void processPluginArtifacts(ArtifactProcessor processor) {
+ processArtifacts( processor, pluginArtifacts );
+ }
+
+ private void processArtifacts(ArtifactProcessor processor, Collection artifacts) {
+ Iterator itr = artifacts.iterator();
+ while ( itr.hasNext() ) {
+ processor.process( ( org.apache.maven.artifact.Artifact ) itr.next() );
+ }
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/DocBookSupportResourcesMojo.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/DocBookSupportResourcesMojo.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/DocBookSupportResourcesMojo.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,103 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.codehaus.plexus.util.FileUtils;
+
+/**
+ * Defines resources-like processing for docbook-support files such
+ * as XSLT, fonts, resources (images/css/etc), moving them to specific locations
+ * within the output directory for inclusion in the final package.
+ *
+ * @goal support-resources
+ * @phase process-resources
+ * @requiresDependencyResolution
+ *
+ * @author Steve Ebersole
+ */
+public class DocBookSupportResourcesMojo extends AbstractMojo {
+
+ /**
+ * The directory containing the XSLT sources.
+ *
+ * @parameter expression="${basedir}/src/main/styles"
+ */
+ protected File xsltSourceDirectory;
+
+ /**
+ * The directory containing fonts to be included in package.
+ *
+ * @parameter expression="${basedir}/src/main/fonts"
+ */
+ protected File fontSourceDirectory;
+
+ /**
+ * The directory containing images to be included in package.
+ *
+ * @parameter expression="${basedir}/src/main/images"
+ */
+ protected File imagesSourceDirectory;
+
+ /**
+ * The directory containing css to be included in package.
+ *
+ * @parameter expression="${basedir}/src/main/css"
+ */
+ protected File cssSourceDirectory;
+
+ /**
+ * The directory from which packaging is staged.
+ *
+ * @parameter expression="${project.build.outputDirectory}"
+ */
+ protected File outputDirectory;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ copySource( xsltSourceDirectory, new File( outputDirectory, "styles" ) );
+ copySource( fontSourceDirectory, new File( outputDirectory, "fonts" ) );
+ copySource( imagesSourceDirectory, new File( outputDirectory, "images" ) );
+ copySource( cssSourceDirectory, new File( outputDirectory, "css" ) );
+ }
+
+ private void copySource(File sourceDirectory, File targetDirectory)
+ throws MojoExecutionException {
+ getLog().info( "attempting to copy directory : " + sourceDirectory.getAbsolutePath() );
+ if ( !sourceDirectory.exists() ) {
+ return;
+ }
+ String[] list = sourceDirectory.list();
+ if ( list == null || list.length == 0 ) {
+ return;
+ }
+
+ if ( !targetDirectory.exists() ) {
+ targetDirectory.mkdirs();
+ }
+
+ try {
+ FileUtils.copyDirectoryStructure( sourceDirectory, targetDirectory );
+ }
+ catch ( IOException e ) {
+ throw new MojoExecutionException( "unable to copy source directory [" + sourceDirectory.getAbsolutePath() + "]", e );
+ }
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/Format.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/Format.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/Format.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,80 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook;
+
+/**
+ * Represents a user format specification.
+ *
+ * @author Steve Ebersole
+ */
+public class Format {
+ private String formatName;
+
+ private String targetFileExtension;
+ private String finalName;
+ private String stylesheetResource;
+ private Boolean imagePathSettingRequired;
+ private Boolean imageCopyingRequired;
+ private Boolean doingChunking;
+
+ public Format() {
+ }
+
+ public Format(
+ String formatName,
+ String targetFileExtension,
+ String finalName,
+ String stylesheetResource,
+ Boolean imagePathSettingRequired,
+ Boolean imageCopyingRequired,
+ Boolean doingChunking) {
+ this.formatName = formatName;
+ this.targetFileExtension = targetFileExtension;
+ this.finalName = finalName;
+ this.stylesheetResource = stylesheetResource;
+ this.imagePathSettingRequired = imagePathSettingRequired;
+ this.imageCopyingRequired = imageCopyingRequired;
+ this.doingChunking = doingChunking;
+ }
+
+ public String getFormatName() {
+ return formatName;
+ }
+
+ public String getTargetFileExtension() {
+ return targetFileExtension;
+ }
+
+ public String getFinalName() {
+ return finalName;
+ }
+
+ public String getStylesheetResource() {
+ return stylesheetResource;
+ }
+
+ public Boolean getImagePathSettingRequired() {
+ return imagePathSettingRequired;
+ }
+
+ public Boolean getImageCopyingRequired() {
+ return imageCopyingRequired;
+ }
+
+ public Boolean getDoingChunking() {
+ return doingChunking;
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/GenerationMojo.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/GenerationMojo.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/GenerationMojo.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,99 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook;
+
+import java.io.File;
+
+import org.codehaus.plexus.util.FileUtils;
+import org.jboss.maven.plugins.jdocbook.gen.util.Formatting;
+import org.jboss.maven.plugins.jdocbook.gen.format.FormatHandlerFactory;
+import org.jboss.maven.plugins.jdocbook.gen.RenderingException;
+import org.jboss.maven.plugins.jdocbook.gen.XSLTException;
+import org.apache.maven.artifact.Artifact;
+
+/**
+ * This mojo's responsibility within the plugin/packaging is actually performing
+ * the DocBook transformations. At the highest level, it takes the source and
+ * process it via the specified DocBook XSLT to produce output.
+ *
+ * @goal generate
+ * @phase compile
+ * @requiresDependencyResolution
+ *
+ * @author Steve Ebersole
+ */
+public class GenerationMojo extends AbstractDocBookMojo {
+
+ protected void process(Formatting[] formattings) throws XSLTException, RenderingException {
+ if ( !sourceDirectory.exists() ) {
+ getLog().info( "sourceDirectory [" + sourceDirectory.getAbsolutePath() + "] did not exist" );
+ return;
+ }
+ File source = new File( sourceDirectory, sourceDocumentName );
+ if ( !source.exists() ) {
+ getLog().info( "source [" + source.getAbsolutePath() + "] did not exist" );
+ return;
+ }
+
+ if ( !targetDirectory.exists() ) {
+ FileUtils.mkdir( targetDirectory.getAbsolutePath() );
+ }
+
+ if ( options.getDocbookVersion() == null ) {
+ processArtifacts(
+ new ArtifactProcessor() {
+ public void process(Artifact artifact) {
+ if ( "net.sf.docbook".equals( artifact.getGroupId() ) &&
+ "docbook".equals( artifact.getArtifactId() ) ) {
+ getLog().debug( "Found docbook version : " + artifact.getVersion() );
+ if ( options.getDocbookVersion() != null ) {
+ getLog().warn( "found multiple docbook versions" );
+ }
+ options.setDocbookVersion( artifact.getVersion() );
+ }
+ }
+ }
+ );
+ }
+
+ File fontConfigFile = null;
+ if ( fontConfig != null ) {
+ getLog().debug( "checking for fontConfig existence [" + fontConfig + "]" );
+ if ( stagingDirectory != null ) {
+ File tmp = new File( stagingDirectory, fontConfig );
+ if ( tmp.exists() ) {
+ getLog().info( "using font configuration : " + tmp.getAbsolutePath() );
+ fontConfigFile = tmp;
+ }
+ }
+ }
+
+ FormatHandlerFactory formatHandlerFactory = new FormatHandlerFactory(
+ options,
+ source,
+ targetDirectory,
+ stagingDirectory,
+ fontConfigFile,
+ project,
+ getLog()
+ );
+
+ for ( int i = 0; i < formattings.length; i++ ) {
+ formatHandlerFactory.buildFormatHandler( formattings[i] ).render( source );
+ }
+ }
+
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/Options.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/Options.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/Options.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,78 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook;
+
+import java.util.Properties;
+
+/**
+ * A (detachable) representation of the user configuration.
+ *
+ * @author Steve Ebersole
+ */
+public class Options {
+ private boolean xincludeSupported;
+ private String[] catalogs;
+ private String xmlTransformerType;
+ private Properties transformerParameters;
+ private boolean useRelativeImageUris = true;
+ private String docbookVersion;
+
+ public Options() {
+ }
+
+ public Options(
+ boolean xincludeSupported,
+ String[] catalogs,
+ String xmlTransformerType,
+ Properties transformerParameters,
+ boolean useRelativeImageUris,
+ String docBookVersion) {
+ this.xincludeSupported = xincludeSupported;
+ this.catalogs = catalogs;
+ this.xmlTransformerType = xmlTransformerType;
+ this.transformerParameters = transformerParameters;
+ this.useRelativeImageUris = useRelativeImageUris;
+ this.docbookVersion = docBookVersion;
+ }
+
+ public boolean isXincludeSupported() {
+ return xincludeSupported;
+ }
+
+ public String[] getCatalogs() {
+ return catalogs;
+ }
+
+ public String getXmlTransformerType() {
+ return xmlTransformerType;
+ }
+
+ public Properties getTransformerParameters() {
+ return transformerParameters;
+ }
+
+ public boolean isUseRelativeImageUris() {
+ return useRelativeImageUris;
+ }
+
+ public String getDocbookVersion() {
+ return docbookVersion;
+ }
+
+ void setDocbookVersion(String docbookVersion) {
+ this.docbookVersion = docbookVersion;
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/PackageMojo.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/PackageMojo.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/PackageMojo.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,56 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook;
+
+import java.io.File;
+
+import org.jboss.maven.plugins.jdocbook.gen.util.Formatting;
+import org.jboss.maven.plugins.jdocbook.gen.RenderingException;
+import org.jboss.maven.plugins.jdocbook.gen.format.FormatHandlerFactory;
+
+/**
+ * This mojo's responsibility within the plugin/packaging is to bundle the
+ * individual formats into deployable formats. The desicion Note that some formats (PDF, e.g.) are
+ * already deployable.
+ * <p/>
+ * After bundling, each bundle is then attached to the project
+ *
+ * @goal bundle
+ * @phase package
+ * @requiresDependencyResolution
+ *
+ * @author Steve Ebersole
+ */
+public class PackageMojo extends AbstractDocBookMojo {
+ protected void process(Formatting[] formattings) throws RenderingException {
+ File source = new File( sourceDirectory, sourceDocumentName );
+ FormatHandlerFactory formatHandlerFactory = new FormatHandlerFactory(
+ options,
+ source,
+ targetDirectory,
+ stagingDirectory,
+ null,
+ project,
+ getLog()
+ );
+
+ project.getArtifact().setFile( project.getFile() );
+
+ for ( int i = 0; i < formattings.length; i++ ) {
+ formatHandlerFactory.buildFormatHandler( formattings[i] ).attachOutput( source, projectHelper );
+ }
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/ResourceMojo.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/ResourceMojo.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/ResourceMojo.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,128 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.codehaus.plexus.archiver.ArchiverException;
+import org.codehaus.plexus.archiver.UnArchiver;
+import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
+import org.codehaus.plexus.util.FileUtils;
+import org.jboss.maven.plugins.jdocbook.gen.util.Formatting;
+import org.jboss.maven.plugins.jdocbook.gen.RenderingException;
+import org.jboss.maven.plugins.jdocbook.gen.XSLTException;
+
+/**
+ * This mojo's responsibility within the plugin/packaging is to process resources
+ * defined by various inputs, moving them into a staging directory for use
+ * during XSLT processing. This is needed because the DocBook XSLT only allow
+ * defining a single <tt>img.src.path</tt> value; FOP only allows a single
+ * <tt>fontBaseDir</tt> value; etc.
+ *
+ * @goal resources
+ * @phase process-resources
+ * @requiresDependencyResolution
+ *
+ * @author Steve Ebersole
+ */
+public class ResourceMojo extends AbstractDocBookMojo {
+
+ protected void process(Formatting[] formattings) throws RenderingException, XSLTException {
+ processProjectResources();
+ processDependencySupportArtifacts( collectDocBookSupportDependentArtifacts() );
+ }
+
+ // project local resources ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ private void processProjectResources() throws RenderingException {
+ copySource( imagesDirectory, new File( stagingDirectory, "images" ) );
+ copySource( cssDirectory, new File( stagingDirectory, "css" ) );
+ copySource( fontsDirectory, new File( stagingDirectory, "fonts" ) );
+ }
+
+ private void copySource(File sourceDirectory, File targetDirectory)
+ throws RenderingException {
+ getLog().info( "attempting to copy directory : " + sourceDirectory.getAbsolutePath() );
+ if ( !sourceDirectory.exists() ) {
+ return;
+ }
+ String[] list = sourceDirectory.list();
+ if ( list == null || list.length == 0 ) {
+ return;
+ }
+
+ if ( !targetDirectory.exists() ) {
+ targetDirectory.mkdirs();
+ }
+
+ try {
+ FileUtils.copyDirectoryStructure( sourceDirectory, targetDirectory );
+ }
+ catch ( IOException e ) {
+ throw new RenderingException( "unable to copy source directory [" + sourceDirectory.getAbsolutePath() + "]", e );
+ }
+ }
+
+
+ // dependency support resources ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ private List collectDocBookSupportDependentArtifacts() {
+ final ArrayList rtn = new ArrayList();
+ processArtifacts(
+ new ArtifactProcessor() {
+ public void process(Artifact artifact) {
+ if ( "docbook-support".equals( artifact.getType() ) ) {
+ rtn.add( artifact );
+ }
+ }
+ }
+ );
+ return rtn;
+ }
+
+ private void processDependencySupportArtifacts(List artifacts) throws RenderingException {
+ Iterator itr = artifacts.iterator();
+ while ( itr.hasNext() ) {
+ final Artifact supportArtifact = ( Artifact ) itr.next();
+ processDependencySupportArtifact( supportArtifact.getFile(), stagingDirectory );
+ }
+ }
+
+ protected void processDependencySupportArtifact(File file, File target) throws RenderingException {
+ getLog().info( "unpacking dependency resource [" + file.getAbsolutePath() + "] to staging-dir [" + target.getAbsolutePath() + "]" );
+ try {
+ target.mkdirs();
+ UnArchiver unArchiver = archiverManager.getUnArchiver( "jar" );
+ unArchiver.setSourceFile( file );
+ unArchiver.setDestDirectory( target );
+ unArchiver.extract();
+ }
+ catch ( NoSuchArchiverException e ) {
+ throw new RenderingException( "Unknown archiver type", e );
+ }
+ catch ( ArchiverException e ) {
+ throw new RenderingException( "Error unpacking file [" + file + "] to [" + target + "]", e );
+ }
+ catch ( IOException e ) {
+ throw new RenderingException( "Error unpacking file [" + file + "] to [" + target + "]", e );
+ }
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/TestIt.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/TestIt.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/TestIt.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class TestIt {
+ public static void main(String[] args) {
+ String name = "//hola.txt";
+ name = parse( name );
+ System.out.println( "Parsed name : [" + name + "]");
+
+ name = "classpath:" + name;
+ name = parse( name.substring( 10 ) );
+ System.out.println( "Parsed name : [" + name + "]");
+ }
+
+ private static String parse(String name) {
+ while ( name.startsWith( "/" ) ) {
+ name = name.substring( 1 );
+ }
+ return name;
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/TranslationDiffReport.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/TranslationDiffReport.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/TranslationDiffReport.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,187 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Christian Bauer, Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.reporting.MavenReport;
+import org.apache.maven.reporting.MavenReportException;
+import org.jboss.maven.plugins.jdocbook.gen.util.Formatting;
+import org.jboss.maven.plugins.jdocbook.gen.RenderingException;
+import org.jboss.maven.plugins.jdocbook.revdiff.Diff;
+import org.jboss.maven.plugins.jdocbook.revdiff.DiffCreator;
+import org.jboss.maven.plugins.jdocbook.revdiff.GenerationException;
+import org.jboss.maven.plugins.jdocbook.revdiff.TranslationReportGenerator;
+
+/**
+ * A plugin for generating a "translation diff" report across different
+ * translations of the same document. This is useful for the translators to
+ * know what changes exist between their translation and the master.
+ * <p/>
+ * Eventually, there is a possibility this will not be needed as we move
+ * forward if it is decided to move to the xliff format for translations.
+ *
+ * @goal diff
+ * @phase site
+ * @requiresDependencyResolution
+ *
+ * @author Christian Bauer
+ * @author Steve Ebersole
+ */
+public class TranslationDiffReport extends AbstractDocBookMojo implements MavenReport {
+
+ public static final String NAME = "translation-diff-report";
+ private File reportOutputDirectory;
+
+ private ResourceBundle getBundle(Locale locale) {
+ return ResourceBundle.getBundle( NAME, locale, this.getClass().getClassLoader() );
+ }
+
+ private String buildReportFileName() {
+ return getOutputName() + ".html";
+ }
+
+ // AbstractDocBookMojo impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Copied nearly verbatim from {@link org.apache.maven.reporting.AbstractMavenReport#execute()}
+ *
+ * {@inheritDoc}
+ */
+ protected void process(Formatting[] formattings) throws RenderingException {
+ try {
+ generateReport( Locale.getDefault() );
+ }
+ catch (GenerationException t) {
+ throw new RenderingException( "An error has occurred in " + NAME + " report generation.", t );
+ }
+ }
+
+
+ // MavenReport impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public String getOutputName() {
+ return NAME;
+ }
+
+ public String getName(Locale locale) {
+ return getBundle( locale ).getString( "report.name" );
+ }
+
+ public String getDescription(Locale locale) {
+ return getBundle( locale ).getString( "report.description" );
+ }
+
+ public String getCategoryName() {
+ return CATEGORY_PROJECT_REPORTS;
+ }
+
+ public void setReportOutputDirectory(File dir) {
+ this.reportOutputDirectory = dir;
+ }
+
+ public File getReportOutputDirectory() {
+ if ( reportOutputDirectory == null ) {
+ reportOutputDirectory = new File( project.getReporting().getOutputDirectory() );
+ }
+ return reportOutputDirectory;
+ }
+
+ public boolean isExternalReport() {
+ return false;
+ }
+
+ public boolean canGenerateReport() {
+ return masterTranslationArtifactId != null ||
+ ( masterTranslationFile != null && masterTranslationFile.exists() );
+ }
+
+ public void generate(org.codehaus.doxia.sink.Sink sink, Locale locale) throws MavenReportException {
+ try {
+ generateReport( locale );
+ }
+ catch ( GenerationException e ) {
+ throw new MavenReportException( "error generating report", e );
+ }
+ }
+
+
+ // report generation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ private void generateReport(Locale locale) throws GenerationException {
+ getLog().debug( "starting " + PLUGIN_NAME + ":diff goal execution" );
+
+ if ( !canGenerateReport() ) {
+ getLog().info( "project is documentation master (or no master defined)" );
+ return;
+ }
+
+ File master = masterTranslationFile;
+ if ( master == null ) {
+ MasterTranslationLocator locator = new MasterTranslationLocator();
+ processArtifacts( locator );
+ master = locator.located.getFile();
+ }
+ if ( master == null ) {
+ throw new GenerationException( "unable to locate master source" );
+ }
+
+ File translation = new File( sourceDirectory, sourceDocumentName );
+
+ getLog().debug( " master : " + master.getAbsolutePath() );
+ getLog().debug( " translation : " + translation.getAbsolutePath() );
+
+ File output = new File( getReportOutputDirectory(), buildReportFileName() );
+ prepReportFile( output );
+
+ DiffCreator diffCreator = new DiffCreator( options.isXincludeSupported(), getLog() );
+ Diff diff = diffCreator.findDiff( master, translation );
+
+ TranslationReportGenerator generator = new TranslationReportGenerator( sourceDirectory, getBundle( locale ), getLog() );
+ generator.generate( diff, output, locale.toString() );
+ }
+
+ class MasterTranslationLocator implements ArtifactProcessor {
+ private final String groupId = project.getGroupId();
+ private Artifact located;
+ public void process(Artifact artifact) {
+ if ( groupId.equals( artifact.getGroupId() ) && masterTranslationArtifactId.equals( artifact.getArtifactId() ) ) {
+ if ( located != null ) {
+ getLog().warn( "duplicate matching master found" );
+ }
+ located = artifact;
+ }
+ }
+ }
+
+ private void prepReportFile(File reportFile) throws GenerationException {
+ if ( reportFile.exists() ) {
+ reportFile.delete();
+ }
+ if ( !reportFile.exists() ) {
+ try {
+ reportFile.createNewFile();
+ }
+ catch ( IOException e ) {
+ throw new GenerationException( "unable to prep report file [" + reportFile.getAbsolutePath() + "]" );
+ }
+ }
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/RenderingException.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/RenderingException.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/RenderingException.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,31 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.gen;
+
+/**
+ * Indicates issues performing rendering.
+ *
+ * @author Steve Ebersole
+ */
+public class RenderingException extends Exception {
+ public RenderingException(String message) {
+ super( message );
+ }
+
+ public RenderingException(String message, Throwable cause) {
+ super( message, cause );
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/XSLTException.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/XSLTException.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/XSLTException.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,32 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.gen;
+
+/**
+ * Indicates problems either building XSLT transformers or performing
+ * transformations.
+ *
+ * @author Steve Ebersole
+ */
+public class XSLTException extends Exception {
+ public XSLTException(String message) {
+ super( message );
+ }
+
+ public XSLTException(String message, Throwable cause) {
+ super( message, cause );
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/BasicFormatHandler.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/BasicFormatHandler.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/BasicFormatHandler.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,215 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.gen.format;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stream.StreamResult;
+
+import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProjectHelper;
+import org.codehaus.plexus.archiver.ArchiverException;
+import org.codehaus.plexus.archiver.jar.JarArchiver;
+import org.codehaus.plexus.util.FileUtils;
+import org.jboss.maven.plugins.jdocbook.gen.RenderingException;
+import org.jboss.maven.plugins.jdocbook.gen.XSLTException;
+import org.jboss.maven.plugins.jdocbook.gen.util.Formatting;
+import org.jboss.maven.plugins.jdocbook.gen.util.ResourceHelper;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+/**
+ * Provides basic support for renderers, mainly in the form of templating.
+ *
+ * @author Steve Ebersole
+ */
+public class BasicFormatHandler implements FormatHandler {
+ public static final String DTD_VALIDATION_FEATURE = "http://xml.org/sax/features/validation";
+ public static final String DTD_LOADING_FEATURE = "http://apache.org/xml/features/nonvalidating/load-external-dtd";
+
+ protected final FormatHandlerFactory factory;
+ protected final Formatting formatting;
+
+ public BasicFormatHandler(FormatHandlerFactory factory, Formatting formatting) {
+ this.factory = factory;
+ this.formatting = formatting;
+ }
+
+ public File prepareDirectory() throws RenderingException {
+ File target = new File( factory.getTargetDirectory(), formatting.getFormatName() );
+ if ( ! target.exists() ) {
+ FileUtils.mkdir( target.getAbsolutePath() );
+ }
+ if ( formatting.isImageCopyingRequired() ) {
+ if ( factory.getStagingDirectory().exists() ) {
+ File imageBase = new File( factory.getStagingDirectory(), "images" );
+ if ( imageBase.exists() ) {
+ try {
+ FileUtils.copyDirectoryStructure( imageBase, target );
+ }
+ catch ( IOException e ) {
+ throw new RenderingException( "unable to copy images", e );
+ }
+ }
+ }
+ }
+ return target;
+ }
+
+ public void attachOutput(File sourceFile, MavenProjectHelper projectHelper) throws RenderingException {
+ File rawOutputDir = new File( factory.getTargetDirectory(), formatting.getFormatName() );
+
+ String warName = factory.getMavenProject().getBuild().getFinalName() +
+ "-" + formatting.getFormatName() + ".war";
+ File war = new File( factory.getTargetDirectory(), warName );
+
+ JarArchiver archiver = new JarArchiver();
+ archiver.setDestFile( war );
+ try {
+ archiver.addDirectory( rawOutputDir );
+ archiver.createArchive();
+ }
+ catch ( IOException e ) {
+ throw new RenderingException( "Unable to create archive [" + war.getAbsolutePath() + "]", e );
+ }
+ catch ( ArchiverException e ) {
+ throw new RenderingException( "Unable to populate archive [" + war.getAbsolutePath() + "]", e );
+ }
+
+ projectHelper.attachArtifact( factory.getMavenProject(), "war", formatting.getFormatName(), war );
+ }
+
+ public final void render(File sourceFile) throws RenderingException, XSLTException {
+ getLog().debug( "starting formatting [" + formatting.getFormatName() + "]" );
+
+ File target = prepareTarget( prepareDirectory(), sourceFile );
+
+ Transformer transformer = buildTransformer( target );
+ Source transformationSource = buildSource( sourceFile );
+ Result transformationResult = buildResult( target );
+ try {
+ transformer.transform( transformationSource, transformationResult );
+ }
+ catch ( TransformerException e ) {
+ throw new XSLTException( "unable to perform transformation", e );
+ }
+ finally {
+ releaseResult( transformationResult );
+ }
+ }
+
+ private File prepareTarget(File directory, File sourceFile) throws RenderingException {
+ String targetFileName = deduceTargetFileName( sourceFile );
+ getLog().debug( "preparing target file [" + targetFileName + "]" );
+ File target = new File( directory, targetFileName );
+ if ( target.exists() ) {
+ if ( !target.delete() ) {
+ getLog().warn( "unable to clean up previous output file [" + target.getAbsolutePath() + "]" );
+ }
+ }
+ if ( !target.exists() ) {
+ try {
+ target.createNewFile();
+ }
+ catch ( IOException e ) {
+ throw new RenderingException( "unable to create output file [" + target.getAbsolutePath() + "]", e );
+ }
+ }
+ return target;
+ }
+
+ private String deduceTargetFileName(File source) {
+ return formatting.getNamingStrategy().deduceTargetFileName( source );
+ }
+
+ protected Transformer buildTransformer(File targetFile) throws RenderingException, XSLTException {
+ final URL transformationStylesheet = resolveTransformationStylesheet();
+ Transformer transformer = factory.getTransformerFactory()
+ .buildTransformer( formatting, transformationStylesheet );
+ if ( formatting.isImagePathSettingRequired() ) {
+ String imgSrcPath = factory.getStagingDirectory().getAbsolutePath() + "/images/";
+ getLog().debug( "setting 'img.src.path' [" + imgSrcPath + "]" );
+ transformer.setParameter( "img.src.path", imgSrcPath );
+ }
+ if ( factory.getOptions().isUseRelativeImageUris() ) {
+ getLog().debug( "enforcing retention of relative image URIs" );
+ transformer.setParameter( "keep.relative.image.uris", "0" );
+ }
+ if ( formatting.isDoingChunking() ) {
+ getLog().debug( "Chunking output." );
+ String rootFilename = targetFile.getName();
+ rootFilename = rootFilename.substring( 0, rootFilename.lastIndexOf( '.' ) );
+ transformer.setParameter( "root.filename", rootFilename );
+ transformer.setParameter( "base.dir", targetFile.getParent() + File.separator );
+ transformer.setParameter( "manifest.in.base.dir", "1" );
+ }
+ return transformer;
+ }
+
+ protected final URL resolveTransformationStylesheet() throws RenderingException {
+ return ResourceHelper.requireResource( formatting.getStylesheetResource() );
+ }
+
+ private Source buildSource(File sourceFile) throws RenderingException {
+ try {
+ EntityResolver resolver = factory.getCatalogResolver();
+ SAXParserFactory factory = createParserFactory();
+ XMLReader reader = factory.newSAXParser().getXMLReader();
+ reader.setEntityResolver( resolver );
+
+ // Disable DTD loading and validation
+ reader.setFeature( DTD_LOADING_FEATURE, false );
+ reader.setFeature( DTD_VALIDATION_FEATURE, false );
+
+ return new SAXSource( reader, new InputSource( sourceFile.getAbsolutePath() ) );
+ }
+ catch ( ParserConfigurationException e ) {
+ throw new RenderingException( "unable to build SAX Parser", e );
+ }
+ catch ( SAXException e ) {
+ throw new RenderingException( "unable to build SAX Parser", e );
+ }
+ }
+
+ protected final SAXParserFactory createParserFactory() {
+ SAXParserFactory parserFactory = new SAXParserFactoryImpl();
+ parserFactory.setXIncludeAware( factory.getOptions().isXincludeSupported() );
+ return parserFactory;
+ }
+
+ protected Result buildResult(File targetFile) throws RenderingException, XSLTException {
+ return new StreamResult( targetFile );
+ }
+
+ protected void releaseResult(Result transformationResult) {
+ // typically nothing to do...
+ }
+
+ protected Log getLog() {
+ return factory.getLog();
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/FormatHandler.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/FormatHandler.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/FormatHandler.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,60 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.gen.format;
+
+import java.io.File;
+
+import org.apache.maven.project.MavenProjectHelper;
+import org.jboss.maven.plugins.jdocbook.gen.RenderingException;
+import org.jboss.maven.plugins.jdocbook.gen.XSLTException;
+
+/**
+ * Handles format-specific processing steps.
+ *
+ * @author Steve Ebersole
+ */
+public interface FormatHandler {
+ /**
+ * This is used during the prepare-resources phase to create and prepare
+ * the format specific output directory for rendering. Generally,
+ * preparation might mean copying any format-specific resources to the
+ * format output directory.
+ *
+ * @return The format output directory
+ * @throws RenderingException Indicates problem preparing output directory
+ */
+ public File prepareDirectory() throws RenderingException;
+
+ /**
+ * Performs the actual rendering or transforming of the DocBook sources into
+ * the respective output format.
+ *
+ * @param source The source DocBook file.
+ * @throws RenderingException Problem writing the output file(s).
+ * @throws XSLTException Problem performing XSL transformation.
+ */
+ public void render(File source) throws RenderingException, XSLTException;
+
+ /**
+ * Attaches the formatting output (after possibly bundling it into an archive)
+ * to the maven project.
+ *
+ * @param sourceFile The source DocBook file.
+ * @param projectHelper The project helper (used to attach produced artifact)
+ * @throws RenderingException Indicates problem performing attaching
+ */
+ public void attachOutput(File sourceFile, MavenProjectHelper projectHelper) throws RenderingException;
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/FormatHandlerFactory.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/FormatHandlerFactory.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/FormatHandlerFactory.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,128 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.gen.format;
+
+import java.io.File;
+
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.xml.resolver.CatalogManager;
+import org.apache.xml.resolver.tools.CatalogResolver;
+import org.jboss.maven.plugins.jdocbook.Options;
+import org.jboss.maven.plugins.jdocbook.gen.util.TransformerType;
+import org.jboss.maven.plugins.jdocbook.gen.util.StandardDocBookFormatSpecification;
+import org.jboss.maven.plugins.jdocbook.gen.util.Formatting;
+import org.jboss.maven.plugins.jdocbook.gen.xslt.TransformerFactory;
+import org.jboss.maven.plugins.jdocbook.gen.xslt.catalog.ExplicitCatalogManager;
+import org.jboss.maven.plugins.jdocbook.gen.xslt.catalog.ImplicitCatalogManager;
+
+/**
+ * Builds a renderer for the given format
+ *
+ * @author Steve Ebersole
+ */
+public class FormatHandlerFactory {
+ private final Options options;
+ private final File source;
+ private final File targetDirectory;
+ private final File stagingDirectory;
+ private final File fontConfig;
+ private final MavenProject mavenProject;
+ private final Log log;
+
+ private CatalogResolver catalogResolver;
+ private TransformerFactory transformerFactory;
+
+ public FormatHandlerFactory(
+ Options options,
+ File source,
+ File targetDirectory,
+ File stagingDirectory,
+ File fontConfig,
+ MavenProject mavenProject,
+ Log log) {
+ this.options = options;
+ this.source = source;
+ this.targetDirectory = targetDirectory;
+ this.stagingDirectory = stagingDirectory;
+ this.fontConfig = fontConfig;
+ this.mavenProject = mavenProject;
+ this.log = log;
+ }
+
+ public Options getOptions() {
+ return options;
+ }
+
+ public File getSource() {
+ return source;
+ }
+
+ public File getTargetDirectory() {
+ return targetDirectory;
+ }
+
+ public File getStagingDirectory() {
+ return stagingDirectory;
+ }
+
+ public File getFontConfig() {
+ return fontConfig;
+ }
+
+ public MavenProject getMavenProject() {
+ return mavenProject;
+ }
+
+ public Log getLog() {
+ return log;
+ }
+
+ public CatalogResolver getCatalogResolver() {
+ if ( catalogResolver == null ) {
+ CatalogManager catalogManager;
+ if ( options.getCatalogs() == null || options.getCatalogs().length == 0 ) {
+ catalogManager = new ImplicitCatalogManager();
+ }
+ else {
+ catalogManager = new ExplicitCatalogManager( options.getCatalogs() );
+ }
+ catalogResolver = new CatalogResolver( catalogManager );
+ }
+ return catalogResolver;
+ }
+
+ public TransformerFactory getTransformerFactory() {
+ if ( transformerFactory == null ) {
+ transformerFactory = new TransformerFactory(
+ TransformerType.parse( options.getXmlTransformerType() ),
+ options.getTransformerParameters(),
+ getCatalogResolver(),
+ options.getDocbookVersion()
+ );
+ }
+ return transformerFactory;
+ }
+
+ public FormatHandler buildFormatHandler(Formatting formatting) {
+ if ( formatting.getFormatName().equals( StandardDocBookFormatSpecification.PDF.getName() ) ) {
+ return new PdfFormatHandler( this, formatting );
+ }
+ else {
+ return new BasicFormatHandler( this, formatting );
+ }
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/PdfFormatHandler.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/PdfFormatHandler.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/format/PdfFormatHandler.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,175 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.gen.format;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import javax.xml.transform.Result;
+import javax.xml.transform.sax.SAXResult;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.fop.apps.Driver;
+import org.apache.fop.apps.FOPException;
+import org.apache.maven.plugin.logging.Log;
+import org.jboss.maven.plugins.jdocbook.gen.util.Formatting;
+import org.jboss.maven.plugins.jdocbook.gen.RenderingException;
+
+/**
+ * Special handling for pdf rendering
+ *
+ * @author Steve Ebersole
+ */
+public class PdfFormatHandler extends BasicFormatHandler {
+
+ public PdfFormatHandler(FormatHandlerFactory factory, Formatting formatting) {
+ super( factory, formatting );
+ }
+
+ protected Result buildResult(File targetFile) throws RenderingException {
+ getLog().info( "building formatting result [" + targetFile.getAbsolutePath() + "]" );
+ prepareFonts();
+ return new ResultImpl( targetFile );
+ }
+
+ private void prepareFonts() throws RenderingException {
+ // if fonts were specified, then prepare the FOP font metrics configuration
+ // : this is the piece that improved dramatically after fop-0.25,
+ // which unfortunately we are stuck with for other reasons :(
+ if ( factory.getFontConfig() != null ) {
+ org.apache.fop.configuration.Configuration.put( "fontBaseDir", new File( factory.getStagingDirectory(), "fonts" ) );
+ try {
+ new org.apache.fop.apps.Options( factory.getFontConfig() );
+ }
+ catch ( FOPException e ) {
+ throw new RenderingException( "unable to properly prepare FOP fonts", e );
+ }
+ org.apache.fop.configuration.Configuration.put( "fontBaseDir", new File( factory.getStagingDirectory(), "fonts" ) );
+ }
+ }
+
+ protected void releaseResult(Result transformationResult) {
+ ( ( ResultImpl ) transformationResult ).release();
+ }
+
+ private class ResultImpl extends SAXResult {
+ private OutputStream outputStream;
+
+ public ResultImpl(File targetFile) throws RenderingException {
+ Driver driver = new Driver();
+ driver.setLogger( new LoggingBridge( getLog() ) );
+ driver.setRenderer( Driver.RENDER_PDF );
+
+ try {
+ outputStream = new BufferedOutputStream( new FileOutputStream( targetFile ) );
+ driver.setOutputStream( outputStream );
+ setHandler( driver.getContentHandler() );
+ }
+ catch ( Throwable t ) {
+ throw new RenderingException( "error building transformation result [" + targetFile.getAbsolutePath() + "]", t );
+ }
+ }
+
+ private void release() {
+ try {
+ outputStream.flush();
+ outputStream.close();
+ }
+ catch ( IOException e ) {
+ getLog().warn( "error releasing I/O resources", e );
+ }
+ }
+ }
+
+ private static class LoggingBridge implements Logger {
+
+ private Log mavenLog;
+
+ public LoggingBridge(Log mavenLog) {
+ this.mavenLog = mavenLog;
+ }
+
+ public Logger getChildLogger(String arg0) {
+ return null;
+ }
+
+ public void debug(String arg0) {
+ mavenLog.debug( arg0 );
+ }
+
+ public void debug(String arg0, Throwable arg1) {
+ mavenLog.debug( arg0, arg1 );
+ }
+
+ // todo : info logging from FOP is excessively verbose...
+
+ public void info(String arg0) {
+ mavenLog.info( arg0 );
+ }
+
+ public void info(String arg0, Throwable arg1) {
+ mavenLog.info( arg0, arg1 );
+ }
+
+ public void warn(String arg0) {
+ mavenLog.warn( arg0 );
+ }
+
+ public void warn(String arg0, Throwable arg1) {
+ mavenLog.warn( arg0, arg1 );
+ }
+
+ public void error(String arg0) {
+ mavenLog.error( arg0 );
+ }
+
+ public void error(String arg0, Throwable arg1) {
+ mavenLog.error( arg0, arg1 );
+ }
+
+ public void fatalError(String arg0) {
+ mavenLog.error( arg0 );
+ }
+
+ public void fatalError(String arg0, Throwable arg1) {
+ mavenLog.error( arg0, arg1 );
+ }
+
+ public boolean isDebugEnabled() {
+ return mavenLog.isDebugEnabled();
+ }
+
+ public boolean isErrorEnabled() {
+ return mavenLog.isErrorEnabled();
+ }
+
+ public boolean isFatalErrorEnabled() {
+ return mavenLog.isErrorEnabled();
+ }
+
+ public boolean isInfoEnabled() {
+ return mavenLog.isInfoEnabled();
+ }
+
+ public boolean isWarnEnabled() {
+ return mavenLog.isWarnEnabled();
+ }
+
+ }
+
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/Formatting.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/Formatting.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/Formatting.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,117 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.gen.util;
+
+import java.io.File;
+
+import org.codehaus.plexus.util.FileUtils;
+import org.jboss.maven.plugins.jdocbook.Format;
+
+/**
+ * Defined formatting information. Basically stuff to either pass into the xsl
+ * transformer or stuff needed to prepare for transformation.
+ *
+ * @author Steve Ebersole
+ */
+public class Formatting {
+ private final String formatName;
+ private final String stylesheetResource;
+ private final boolean imagePathSettingRequired;
+ private final boolean imageCopyingRequired;
+ private final boolean doingChunking;
+ private final StandardDocBookFormatSpecification standardDocBookSpec;
+ private final TargetNamingStrategy namingStrategy;
+
+ public Formatting(StandardDocBookFormatSpecification standardDocBookSpec, Format userSpec) {
+ // todo : there may not be a matching standard docbook format spec...
+ if ( ! standardDocBookSpec.getName().equals( userSpec.getFormatName() ) ) {
+ throw new IllegalArgumentException( "formatting type mismatch" );
+ }
+
+ this.standardDocBookSpec = standardDocBookSpec;
+ this.formatName = userSpec.getFormatName();
+
+ this.stylesheetResource = userSpec.getStylesheetResource() == null
+ ? standardDocBookSpec.getStylesheetResource()
+ : userSpec.getStylesheetResource();
+
+ this.imageCopyingRequired = userSpec.getImageCopyingRequired() == null
+ ? standardDocBookSpec.isImageCopyingRequired()
+ : userSpec.getImageCopyingRequired().booleanValue();
+
+ this.imagePathSettingRequired = userSpec.getImagePathSettingRequired() == null
+ ? standardDocBookSpec.isImagePathSettingRequired()
+ : userSpec.getImagePathSettingRequired().booleanValue();
+
+ this.doingChunking =userSpec.getDoingChunking() == null
+ ? standardDocBookSpec.isDoingChunking()
+ : userSpec.getDoingChunking().booleanValue();
+
+ this.namingStrategy = new TargetNamingStrategy( standardDocBookSpec, userSpec );
+ }
+
+ public String getFormatName() {
+ return formatName;
+ }
+
+ public StandardDocBookFormatSpecification getStandardDocBookSpec() {
+ return standardDocBookSpec;
+ }
+
+ public String getStylesheetResource() {
+ return stylesheetResource;
+ }
+
+ public boolean isImagePathSettingRequired() {
+ return imagePathSettingRequired;
+ }
+
+ public boolean isImageCopyingRequired() {
+ return imageCopyingRequired;
+ }
+
+ public boolean isDoingChunking() {
+ return doingChunking;
+ }
+
+ public TargetNamingStrategy getNamingStrategy() {
+ return namingStrategy;
+ }
+
+ public static class TargetNamingStrategy {
+ private String targetFileExtension;
+ private String finalName;
+
+ public TargetNamingStrategy(StandardDocBookFormatSpecification standardDocBookSpec, Format userSpec) {
+ if ( userSpec.getFinalName() != null ) {
+ this.targetFileExtension = null;
+ this.finalName = userSpec.getFinalName();
+ }
+ else {
+ this.targetFileExtension = userSpec.getTargetFileExtension() == null
+ ? standardDocBookSpec.getStandardFileExtension()
+ : userSpec.getTargetFileExtension();
+ this.finalName = null;
+ }
+ }
+
+ public String deduceTargetFileName(File source) {
+ return finalName == null
+ ? FileUtils.basename( source.getAbsolutePath() ) + targetFileExtension
+ : finalName;
+ }
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/NoOpWriter.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/NoOpWriter.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/NoOpWriter.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,35 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.gen.util;
+
+import java.io.Writer;
+
+/**
+ * A writer which does no writing :)
+ *
+ * @author Steve Ebersole
+ */
+public class NoOpWriter extends Writer {
+
+ public void write(char cbuf[], int off, int len) {
+ }
+
+ public void flush() {
+ }
+
+ public void close() {
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/ResourceHelper.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/ResourceHelper.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/ResourceHelper.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,68 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.gen.util;
+
+import java.net.URL;
+import java.net.MalformedURLException;
+
+/**
+ * Simple helpers for locating and handling classpath and file URL resource
+ * lookups.
+ *
+ * @author Steve Ebersole
+ */
+public class ResourceHelper {
+ public static URL requireResource(String name) {
+ URL resource = locateResource( name );
+ if ( resource == null ) {
+ throw new IllegalArgumentException( "could not locate resource [" + name + "]" );
+ }
+ return resource;
+ }
+
+ public static URL locateResource(String name) {
+ if ( name.startsWith( "classpath:" ) ) {
+ return locateClassPathResource( name.substring( 10 ) );
+ }
+ else if ( name.startsWith( "file:" ) ) {
+ try {
+ return new URL( name );
+ }
+ catch ( MalformedURLException e ) {
+ throw new IllegalArgumentException( "malformed explicit file url [" + name + "]", e );
+ }
+ }
+ else {
+ // assume a classpath resource (backwards compatibility)
+ return locateClassPathResource( name );
+ }
+ }
+
+ private static URL locateClassPathResource(String name) {
+ while ( name.startsWith( "/" ) ) {
+ name = name.substring( 1 );
+ }
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if ( loader == null ) {
+ loader = ResourceHelper.class.getClassLoader();
+ }
+ URL result = loader.getResource( name );
+ if ( result == null ) {
+ result = loader.getResource( "/" + name );
+ }
+ return result;
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/StaleSourceChecker.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/StaleSourceChecker.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/StaleSourceChecker.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,30 @@
+package org.jboss.maven.plugins.jdocbook.gen.util;
+
+import java.io.File;
+import java.util.Collections;
+
+import org.codehaus.plexus.compiler.util.scan.StaleSourceScanner;
+import org.codehaus.plexus.compiler.util.scan.InclusionScanException;
+import org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping;
+
+/**
+ * Delegate used for checking sources for staleness.
+ *
+ * @author Steve Ebersole
+ */
+public class StaleSourceChecker {
+ public static boolean hasStaleSources(File sourceDirectory, File databaseDirectory) {
+ try {
+ StaleSourceScanner scanner = new StaleSourceScanner(
+ 0,
+ Collections.singleton( "**/*.xml" ),
+ Collections.EMPTY_SET
+ );
+ scanner.addSourceMapping( new SuffixMapping( ".xml", ".xml.db" ) );
+ return ! scanner.getIncludedSources( sourceDirectory, databaseDirectory ).isEmpty();
+ }
+ catch ( InclusionScanException e ) {
+ throw new RuntimeException( "Error scanning sources in " + sourceDirectory, e );
+ }
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/StandardDocBookFormatSpecification.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/StandardDocBookFormatSpecification.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/StandardDocBookFormatSpecification.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,148 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.gen.util;
+
+/**
+ * The basic definition of the standard docbook formats.
+ *
+ * @author Steve Ebersole
+ */
+public class StandardDocBookFormatSpecification {
+ public static final StandardDocBookFormatSpecification ECLIPSE =
+ new HtmlBasedStandardDocBookFormat( "eclipse", "/eclipse/eclipse.xsl" );
+
+ public static final StandardDocBookFormatSpecification HTML =
+ new HtmlBasedStandardDocBookFormat( "html", "/html/chunk.xsl" );
+
+ public static final StandardDocBookFormatSpecification HTML_SINGLE =
+ new HtmlBasedStandardDocBookFormat( "html_single", "/html/docbook.xsl", false );
+
+ public static final StandardDocBookFormatSpecification HTMLHELP =
+ new HtmlBasedStandardDocBookFormat( "htmlhelp", "/htmlhelp/htmlhelp.xsl" );
+
+ public static final StandardDocBookFormatSpecification JAVAHELP =
+ new HtmlBasedStandardDocBookFormat( "javahelp", "/javahelp/javahelp.xsl" );
+
+ public static final StandardDocBookFormatSpecification MAN =
+ new HtmlBasedStandardDocBookFormat( "man", "/manpages/docbook.xsl", false );
+
+ public static final StandardDocBookFormatSpecification PDF =
+ new StandardDocBookFormatSpecification( "pdf", "pdf", "/fo/docbook.xsl", true, false, false );
+
+ public static final StandardDocBookFormatSpecification WEBSITE =
+ new HtmlBasedStandardDocBookFormat( "website", "/website/website.xsl", false );
+
+// I'd rather not support this...
+// public static final FormatType WORDML =
+// new FormatType( "wordml", "doc", "/wordml/wordml.xsl", ?, ?, ? );
+
+ public static final StandardDocBookFormatSpecification XHTML =
+ new StandardDocBookFormatSpecification( "xhtml", "xhtml", "/xhtml/docbook.xsl", false, true, false );
+
+ private final String name;
+ private final String standardFileExtension;
+ private final String stylesheetResource;
+ private final boolean imagePathSettingRequired;
+ private final boolean imageCopyingRequired;
+ private final boolean doingChunking;
+
+ public StandardDocBookFormatSpecification(
+ String name,
+ String standardFileExtension,
+ String stylesheetResource,
+ boolean imagePathSettingRequired,
+ boolean imageCopyingRequired,
+ boolean doingChunking) {
+ this.name = name;
+ this.standardFileExtension = standardFileExtension;
+ this.stylesheetResource = stylesheetResource;
+ this.imagePathSettingRequired = imagePathSettingRequired;
+ this.imageCopyingRequired = imageCopyingRequired;
+ this.doingChunking = doingChunking;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getStandardFileExtension() {
+ return standardFileExtension;
+ }
+
+ public String getStylesheetResource() {
+ return stylesheetResource;
+ }
+
+ public boolean isImagePathSettingRequired() {
+ return imagePathSettingRequired;
+ }
+
+ public boolean isImageCopyingRequired() {
+ return imageCopyingRequired;
+ }
+
+ public boolean isDoingChunking() {
+ return doingChunking;
+ }
+
+ public static StandardDocBookFormatSpecification parse(String name) {
+ if ( ECLIPSE.name.equals( name ) ) {
+ return ECLIPSE;
+ }
+ else if ( HTML.name.equals( name ) ) {
+ return HTML;
+ }
+ else if ( HTML_SINGLE.name.equals( name ) ) {
+ return HTML_SINGLE;
+ }
+ else if ( HTMLHELP.name.equals( name ) ) {
+ return HTMLHELP;
+ }
+ else if ( JAVAHELP.name.equals( name ) ) {
+ return JAVAHELP;
+ }
+ else if ( MAN.name.equals( name ) ) {
+ return MAN;
+ }
+ else if ( PDF.name.equals( name ) ) {
+ return PDF;
+ }
+ else if ( WEBSITE.name.equals( name ) ) {
+ return WEBSITE;
+ }
+// else if ( WORDML.name.equals( name ) ) {
+// return WORDML;
+// }
+ else if ( XHTML.name.equals( name ) ) {
+ return XHTML;
+ }
+ else {
+ return null;
+ }
+ }
+
+
+ // convenience for html based formats to simplify ctors ~~~~~~~~~~~~~~~~~~~
+
+ private static class HtmlBasedStandardDocBookFormat extends StandardDocBookFormatSpecification {
+ private HtmlBasedStandardDocBookFormat(String name, String stylesheetResource) {
+ this( name, stylesheetResource, true );
+ }
+ private HtmlBasedStandardDocBookFormat(String name, String stylesheetResource, boolean doingChunking) {
+ super( name, "html", stylesheetResource, false, true, doingChunking );
+ }
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/TransformerType.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/TransformerType.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/util/TransformerType.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,52 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.gen.util;
+
+/**
+ * Enumeration of supported XSLT transformers.
+ *
+ * @author Steve Ebersole
+ */
+public class TransformerType {
+ public static final TransformerType SAXON = new TransformerType( "saxon", false );
+ public static final TransformerType XALAN = new TransformerType( "xalan", true );
+
+ private final String name;
+ private final boolean supportsReset;
+
+ private TransformerType(String name, boolean supportsReset) {
+ this.name = name;
+ this.supportsReset = supportsReset;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public boolean supportsReset() {
+ return supportsReset;
+ }
+
+ public static TransformerType parse(String name) {
+ if ( XALAN.name.equals( name ) ) {
+ return XALAN;
+ }
+ else {
+ // default
+ return SAXON;
+ }
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/TransformerFactory.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/TransformerFactory.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/TransformerFactory.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,139 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.gen.xslt;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.stream.StreamSource;
+
+import com.icl.saxon.Controller;
+import org.apache.xml.resolver.tools.CatalogResolver;
+import org.jboss.maven.plugins.jdocbook.gen.XSLTException;
+import org.jboss.maven.plugins.jdocbook.gen.util.ResourceHelper;
+import org.jboss.maven.plugins.jdocbook.gen.util.TransformerType;
+import org.jboss.maven.plugins.jdocbook.gen.util.Formatting;
+import org.jboss.maven.plugins.jdocbook.gen.util.NoOpWriter;
+import org.jboss.maven.plugins.jdocbook.gen.util.StandardDocBookFormatSpecification;
+import org.jboss.maven.plugins.jdocbook.gen.xslt.resolve.CurrentVersionResolver;
+import org.jboss.maven.plugins.jdocbook.gen.xslt.resolve.ResolverChain;
+import org.jboss.maven.plugins.jdocbook.gen.xslt.resolve.VersionResolver;
+import org.jboss.maven.plugins.jdocbook.gen.xslt.resolve.ExplicitUrnResolver;
+import org.jboss.maven.plugins.jdocbook.gen.xslt.resolve.RelativeJarUriResolver;
+
+/**
+ * A factory for {@link javax.xml.transform.Transformer} instances, configurable
+ * to return either SAXON or XALAN based transformers.
+ *
+ * @author Steve Ebersole
+ */
+public class TransformerFactory {
+ private final TransformerType transformerType;
+ private final Properties transformerParameters;
+ private final CatalogResolver catalogResolver;
+ private final String docbookVersion;
+
+ public TransformerFactory(
+ TransformerType transformerType,
+ Properties transformerParameters,
+ CatalogResolver catalogResolver,
+ String docbookVersion) {
+ this.transformerType = transformerType;
+ this.transformerParameters = transformerParameters;
+ this.catalogResolver = catalogResolver;
+ this.docbookVersion = docbookVersion;
+ }
+
+ public Transformer buildTransformer(Formatting formatting, URL customStylesheet) throws XSLTException {
+ URIResolver uriResolver = buildUriResolver( formatting.getStandardDocBookSpec() );
+
+ javax.xml.transform.TransformerFactory transformerFactory = buildTransformerFactory();
+ transformerFactory.setURIResolver( uriResolver );
+
+ URL xsltStylesheet = customStylesheet == null
+ ? ResourceHelper.requireResource( formatting.getStylesheetResource() )
+ : customStylesheet;
+
+ Transformer transformer;
+ try {
+ Source source = new StreamSource( xsltStylesheet.openStream(), xsltStylesheet.toExternalForm() );
+ transformer = transformerFactory.newTransformer( source );
+ }
+ catch ( IOException e ) {
+ throw new XSLTException( "problem opening stylesheet", e );
+ }
+ catch ( TransformerConfigurationException e ) {
+ throw new XSLTException( "unable to build transformer", e );
+ }
+
+ transformer.setURIResolver( uriResolver );
+ applyParameters( transformer );
+
+ if ( transformer instanceof Controller ) {
+ Controller controller = ( Controller ) transformer;
+ try {
+ controller.makeMessageEmitter();
+ controller.getMessageEmitter().setWriter( new NoOpWriter() );
+ }
+ catch ( TransformerException te ) {
+ // intentionally empty
+ }
+ }
+ return transformer;
+ }
+
+ private javax.xml.transform.TransformerFactory buildTransformerFactory() {
+ if ( transformerType == TransformerType.XALAN ) {
+ return new com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl();
+ }
+ else {
+ // saxon as default...
+ return new com.icl.saxon.TransformerFactoryImpl();
+ }
+ }
+
+ private void applyParameters(Transformer transformer) {
+ if ( transformerParameters == null ) {
+ return;
+ }
+ Iterator itr = transformerParameters.entrySet().iterator();
+ while ( itr.hasNext() ) {
+ final Map.Entry entry = ( Map.Entry ) itr.next();
+ transformer.setParameter( ( String ) entry.getKey(), entry.getValue() );
+ }
+ }
+
+ public URIResolver buildUriResolver(StandardDocBookFormatSpecification formatType) throws XSLTException {
+ ResolverChain resolverChain = new ResolverChain();
+ if ( formatType != null ) {
+ resolverChain.addResolver( new ExplicitUrnResolver( formatType ) );
+ }
+ resolverChain.addResolver( new CurrentVersionResolver() );
+ if ( docbookVersion != null ) {
+ resolverChain.addResolver( new VersionResolver( docbookVersion ) );
+ }
+ resolverChain.addResolver( new RelativeJarUriResolver() );
+ resolverChain.addResolver( catalogResolver );
+ return resolverChain;
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/catalog/AbstractCatalogManager.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/catalog/AbstractCatalogManager.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/catalog/AbstractCatalogManager.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,46 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.gen.xslt.catalog;
+
+import org.apache.xml.resolver.CatalogManager;
+
+/**
+ * Basic support for our notion of CatalogManagers.
+ *
+ * @author Steve Ebersole
+ */
+public abstract class AbstractCatalogManager extends CatalogManager {
+ public AbstractCatalogManager(String[] catalogNames) {
+ super();
+ setIgnoreMissingProperties( true );
+ if ( catalogNames != null && catalogNames.length != 0 ) {
+ StringBuffer buffer = new StringBuffer();
+ boolean first = true;
+ for ( int i = 0; i < catalogNames.length; i++ ) {
+ if ( catalogNames[i] != null ) {
+ if ( first ) {
+ first = false;
+ }
+ else {
+ buffer.append( ';' );
+ }
+ }
+ buffer.append( catalogNames[i] );
+ }
+ setCatalogFiles( buffer.toString() );
+ }
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/catalog/ExplicitCatalogManager.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/catalog/ExplicitCatalogManager.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/catalog/ExplicitCatalogManager.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,28 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.gen.xslt.catalog;
+
+/**
+ * Utilizes explicit, user-supplied catalog names to build a
+ * CatalogManager.
+ *
+ * @author Steve Ebersole
+ */
+public class ExplicitCatalogManager extends AbstractCatalogManager {
+ public ExplicitCatalogManager(String[] catalogNames) {
+ super( catalogNames );
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/catalog/ImplicitCatalogManager.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/catalog/ImplicitCatalogManager.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/catalog/ImplicitCatalogManager.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,56 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.gen.xslt.catalog;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+
+/**
+ * CatalogManager which resolves its catalogs internally via classpath
+ * resource lookups. Its looks for resources named '/catalog.xml' on the
+ * classpath.
+ *
+ * @author Steve Ebersole
+ */
+public class ImplicitCatalogManager extends AbstractCatalogManager {
+ public ImplicitCatalogManager() {
+ super( resolveCatalogNames() );
+ }
+
+ private static String[] resolveCatalogNames() {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ if ( classLoader == null ) {
+ classLoader = ImplicitCatalogManager.class.getClassLoader();
+ }
+ ArrayList names = new ArrayList();
+ try {
+ Enumeration enumeration = classLoader.getResources( "/catalog.xml" );
+ while ( enumeration.hasMoreElements() ) {
+ final URL resource = ( URL ) enumeration.nextElement();
+ final String resourcePath = resource.toExternalForm();
+ if ( resourcePath != null ) {
+ names.add( resourcePath );
+ }
+ }
+ }
+ catch ( IOException ignore ) {
+ // intentionally empty
+ }
+ return ( String[] ) names.toArray( new String[ names.size() ] );
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/BasicUrnResolver.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/BasicUrnResolver.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/BasicUrnResolver.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,44 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.gen.xslt.resolve;
+
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
+
+/**
+ * Basic support for URIResolvers which map a URN unto a single replacement
+ * {@link Source}.
+ *
+ * @author Steve Ebersole
+ */
+public class BasicUrnResolver implements URIResolver {
+ private final String urn;
+ private final Source source;
+
+ public BasicUrnResolver(String urn, Source source) {
+ this.urn = urn;
+ this.source = source;
+ }
+
+ public Source resolve(String href, String base) throws TransformerException {
+ return urn.equals( href ) ? source : null;
+ }
+
+ public String toString() {
+ return super.toString() + " [URN:" + urn + "]";
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/CurrentVersionResolver.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/CurrentVersionResolver.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/CurrentVersionResolver.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,28 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.gen.xslt.resolve;
+
+/**
+ * Map hrefs starting with <tt>http://docbook.sourceforge.net/release/xsl/current/</tt>
+ * to classpath resource lookups.
+ *
+ * @author Steve Ebersole
+ */
+public class CurrentVersionResolver extends VersionResolver {
+ public CurrentVersionResolver() {
+ super( "current" );
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/ExplicitUrnResolver.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/ExplicitUrnResolver.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/ExplicitUrnResolver.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,55 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.gen.xslt.resolve;
+
+import java.io.IOException;
+import java.net.URL;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+
+import org.jboss.maven.plugins.jdocbook.gen.XSLTException;
+import org.jboss.maven.plugins.jdocbook.gen.util.ResourceHelper;
+import org.jboss.maven.plugins.jdocbook.gen.util.StandardDocBookFormatSpecification;
+
+
+/**
+ * Resolves an explicit <tt>urn:docbook:stylesheet</tt> URN against the standard
+ * DocBook stylesheets.
+ *
+ * @author Steve Ebersole
+ */
+public class ExplicitUrnResolver extends BasicUrnResolver {
+ private final StandardDocBookFormatSpecification formatType;
+
+ public ExplicitUrnResolver(StandardDocBookFormatSpecification type) throws XSLTException {
+ super( "urn:docbook:stylesheet", createSource( type ) );
+ this.formatType = type;
+ }
+
+ private static Source createSource(StandardDocBookFormatSpecification type) throws XSLTException {
+ URL stylesheet = ResourceHelper.requireResource( type.getStylesheetResource() );
+ try {
+ return new StreamSource( stylesheet.openStream(), stylesheet.toExternalForm() );
+ }
+ catch ( IOException e ) {
+ throw new XSLTException( "could not locate DocBook stylesheet [" + type.getName() + "]", e );
+ }
+ }
+
+ public String toString() {
+ return super.toString() + " [" + formatType.getName() + "]";
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/RelativeJarUriResolver.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/RelativeJarUriResolver.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/RelativeJarUriResolver.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,51 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.gen.xslt.resolve;
+
+import java.net.URL;
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.stream.StreamSource;
+
+/**
+ * Responsible for resolving relative references from jar base urls.
+ *
+ * @author Steve Ebersole
+ */
+public class RelativeJarUriResolver implements URIResolver {
+ public Source resolve(String href, String base) throws TransformerException {
+ // href need to be relative
+ if ( href.indexOf( "://" ) > 0 || href.startsWith( "/" ) ) {
+ return null;
+ }
+
+ // base would need to start with jar:
+ if ( !base.startsWith( "jar:" ) ) {
+ return null;
+ }
+
+ String fullHref = base.substring( 4, base.lastIndexOf( '/' ) + 1 )
+ + href;
+ try {
+ URL url = new URL( fullHref );
+ return new StreamSource( url.openStream(), url.toExternalForm() );
+ }
+ catch ( Throwable t ) {
+ return null;
+ }
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/ResolverChain.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/ResolverChain.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/ResolverChain.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,71 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.gen.xslt.resolve;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
+
+/**
+ * Allows chaining a series of {@link URIResolver resolvers} together.
+ * <p/>
+ * "Precedence" of the resolvers is determined by the order in which
+ * they are {@link #addResolver added}.
+ *
+ * @author Steve Ebersole
+ */
+public class ResolverChain implements URIResolver {
+ private List resolvers = new ArrayList();
+
+ public ResolverChain() {
+ }
+
+ public ResolverChain(URIResolver resolver) {
+ this();
+ addResolver( resolver );
+ }
+
+ /**
+ * Adds a resolver to the chain.
+ *
+ * @param resolver The resolver to add.
+ */
+ public void addResolver(URIResolver resolver) {
+ resolvers.add( resolver );
+ }
+
+ /**
+ * Here we iterate over all the chained resolvers and delegate to them
+ * until we find one which can handle the resolve request (if any).
+ *
+ * {@inheritDoc}
+ */
+ public Source resolve(String href, String base) throws TransformerException {
+ Source result = null;
+ Iterator itr = resolvers.iterator();
+ while ( itr.hasNext() ) {
+ final URIResolver resolver = ( URIResolver ) itr.next();
+ result = resolver.resolve( href, base );
+ if ( result != null ) {
+ break;
+ }
+ }
+ return result;
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/VersionResolver.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/VersionResolver.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/gen/xslt/resolve/VersionResolver.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,70 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.gen.xslt.resolve;
+
+import java.io.IOException;
+import java.net.URL;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.stream.StreamSource;
+
+import org.jboss.maven.plugins.jdocbook.gen.util.ResourceHelper;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class VersionResolver implements URIResolver {
+ public static final String BASE_HREF = "http://docbook.sourceforge.net/release/xsl/";
+
+ private final String version;
+ private final String versionHref;
+
+ public VersionResolver(String version) {
+ this.version = version;
+ this.versionHref = BASE_HREF + version;
+ }
+
+ public Source resolve(String href, String base) throws TransformerException {
+ if ( href.startsWith( versionHref ) ) {
+ return resolve( href );
+ }
+ else if ( base.startsWith( versionHref ) ) {
+ return resolve( base + "/" + href );
+ }
+ return null;
+ }
+
+ private Source resolve(String href) {
+ String resource = href.substring( versionHref.length() );
+ try {
+ URL resourceURL = ResourceHelper.requireResource( resource );
+ return new StreamSource( resourceURL.openStream(), resourceURL.toExternalForm() );
+ }
+ catch ( IllegalArgumentException e ) {
+ return null;
+ }
+ catch ( IOException e ) {
+ return null;
+ }
+ }
+
+ public String toString() {
+ return super.toString() + " [version=" + version + "]";
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/BaselineHandler.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/BaselineHandler.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/BaselineHandler.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,74 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Christian Bauer, Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.revdiff;
+
+import java.util.Map;
+
+import org.xml.sax.helpers.DefaultHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * An XML parse handler used to create a catalog of baseline elements.
+ * <p/>
+ * Typically this would be used against the master translation to create
+ * a baseline against which particular translations would be checked.
+ *
+ * @author Christian Bauer
+ * @author Steve Ebersole
+ */
+public class BaselineHandler extends DefaultHandler {
+ private final Map catalog;
+ private Locator docLocator;
+
+ public void setDocumentLocator(Locator locator) {
+ this.docLocator = locator;
+ }
+
+ public BaselineHandler(Map catalog) {
+ this.catalog = catalog;
+ }
+
+ public void startElement(
+ String namespaceURI,
+ String localName,
+ String qualifiedName,
+ Attributes atts) throws SAXException {
+
+ // Only add ModuleElements that have an identifier
+ String identifier = atts.getValue( "id" );
+ if ( identifier != null ) {
+ // The default revision is 0
+ int revision = 0;
+ if ( atts.getValue( "revision" ) != null ) {
+ revision = Integer.parseInt( atts.getValue( "revision" ) );
+ }
+
+ // Generate new ContentItem and new original state
+ ContentItem contentItem = new ContentItem( identifier );
+ ContentItemDescriptor descriptor = new ContentItemDescriptor(
+ docLocator.getSystemId(),
+ qualifiedName,
+ revision,
+ docLocator.getLineNumber(),
+ docLocator.getColumnNumber()
+ );
+ contentItem.setMasterDescriptor( descriptor );
+ catalog.put( identifier, contentItem );
+ }
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/ContentItem.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/ContentItem.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/ContentItem.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,71 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Christian Bauer
+ */
+package org.jboss.maven.plugins.jdocbook.revdiff;
+
+/**
+ * Describes a particular piece of content, including descriptors
+ * from both the master and a particular translation
+ *
+ * @author Christian Bauer
+ */
+public class ContentItem {
+ private final String identifier;
+ private ContentItemDescriptor masterDescriptor;
+ private ContentItemDescriptor translationDescriptor;
+
+ public ContentItem(String identifier) {
+ this.identifier = identifier;
+ }
+
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ public ContentItemDescriptor getMasterDescriptor() {
+ return masterDescriptor;
+ }
+
+ public void setMasterDescriptor(ContentItemDescriptor masterDescriptor) {
+ this.masterDescriptor = masterDescriptor;
+ }
+
+ public ContentItemDescriptor getTranslationDescriptor() {
+ return translationDescriptor;
+ }
+
+ public void setTranslationDescriptor(ContentItemDescriptor translationDescriptor) {
+ this.translationDescriptor = translationDescriptor;
+ }
+
+
+ public boolean equals(Object o) {
+ if ( this == o ) {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() ) {
+ return false;
+ }
+
+ ContentItem that = ( ContentItem ) o;
+
+ return identifier.equals( that.identifier );
+
+ }
+
+ public int hashCode() {
+ return identifier.hashCode();
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/ContentItemDescriptor.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/ContentItemDescriptor.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/ContentItemDescriptor.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,58 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Christian Bauer
+ */
+package org.jboss.maven.plugins.jdocbook.revdiff;
+
+/**
+ *
+ * @author Christian Bauer
+ */
+public class ContentItemDescriptor {
+ public static int REVISION_IGNORE = -1;
+
+ private final String sourceSystemId;
+ private final String elementName;
+ private final int revision;
+ private final int row;
+ private final int column;
+
+ public ContentItemDescriptor(String sourceSystemId, String elementName, int revision, int row, int column) {
+ this.sourceSystemId = sourceSystemId;
+ this.elementName = elementName;
+ this.revision = revision;
+ this.row = row;
+ this.column = column;
+ }
+
+ public int getRevision() {
+ return revision;
+ }
+
+ public String getElementName() {
+ return elementName;
+ }
+
+ public String getSourceSystemId() {
+ return sourceSystemId;
+ }
+
+ public int getRow() {
+ return row;
+ }
+
+ public int getColumn() {
+ return column;
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/Diff.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/Diff.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/Diff.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,54 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.revdiff;
+
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Iterator;
+
+/**
+ * Represents the difference between two sources.
+ *
+ * @author Steve Ebersole
+ */
+public class Diff {
+ private Set elementsOnlyInMaster = new HashSet();
+ private Set elementsOnlyInTranslation = new HashSet();
+ private Set elementsDiffRevision = new HashSet();
+
+ public void addOnlyInMaster(ContentItem element) {
+ elementsOnlyInMaster.add( element );
+ }
+
+ public void addOnlyInTranslation(ContentItem element) {
+ elementsOnlyInTranslation.add( element );
+ }
+
+ public void addDiffRevision(ContentItem element) {
+ elementsDiffRevision.add( element );
+ }
+
+ public Iterator getElementsOnlyInMaster() {
+ return elementsOnlyInMaster.iterator();
+ }
+
+ public Iterator getElementsOnlyInTranslation() {
+ return elementsOnlyInTranslation.iterator();
+ }
+ public Iterator getElementsDiffRevision() {
+ return elementsDiffRevision.iterator();
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/DiffCreator.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/DiffCreator.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/DiffCreator.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,115 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.revdiff;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
+
+import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+import org.xml.sax.XMLReader;
+import org.apache.maven.plugin.logging.Log;
+
+/**
+ * Responsible for creating a diff description.
+ *
+ * @author Steve Ebersole
+ */
+public class DiffCreator {
+
+ private final XMLReader parser;
+ private final Log log;
+
+ public DiffCreator(boolean xincludeSupport, Log log) throws GenerationException {
+ this.parser = generateParser( xincludeSupport );
+ this.log = log;
+ }
+
+ public synchronized Diff findDiff(File master, File translation) throws GenerationException {
+ Map catalog = new HashMap();
+
+ // Parse master file
+ BaselineHandler baselineHandler = new BaselineHandler( catalog );
+ parser.setContentHandler( baselineHandler );
+ try {
+ parser.parse( master.getAbsolutePath() );
+ }
+ catch( IOException e ) {
+ throw new GenerationException( "unable to locate specified master [" + master.getAbsolutePath() + "]", e );
+ }
+ catch ( SAXException e ) {
+ throw new GenerationException( "error parsing master [" + master.getAbsolutePath() + "]", e );
+ }
+
+ log.debug( "encountered [" + catalog.size() + "] master content elements" );
+
+ Diff diff = new Diff();
+
+ // Parse translation
+ TranslationHandler translationHandler = new TranslationHandler( catalog, diff );
+ parser.setContentHandler( translationHandler );
+ try {
+ parser.parse( translation.getAbsolutePath() );
+ }
+ catch ( IOException e ) {
+ throw new GenerationException( "unable to locate specified translation [" + translation.getAbsolutePath() + "]", e );
+ }
+ catch ( SAXException e ) {
+ throw new GenerationException( "error parsing translation [" + translation.getAbsolutePath() + "]", e );
+ }
+
+ // as a final step, allow translation handler to finish up
+ translationHandler.finish();
+
+ return diff;
+ }
+
+ private XMLReader generateParser(boolean xincludeSupport) throws GenerationException {
+ try {
+ XMLReader parser = createParserFactory( xincludeSupport ).newSAXParser().getXMLReader();
+// SAXParser parser = new SAXParser();
+ // Disable validation against DTD
+ parser.setFeature( "http://xml.org/sax/features/validation", false );
+ // Disable DTD loading in Xerces
+ parser.setFeature( "http://apache.org/xml/features/nonvalidating/load-external-dtd", false );
+ return parser;
+ }
+ catch ( SAXNotSupportedException e ) {
+ throw new GenerationException( "unable to generate SAX Parser", e );
+ }
+ catch ( SAXNotRecognizedException e ) {
+ throw new GenerationException( "unable to generate SAX Parser", e );
+ }
+ catch ( ParserConfigurationException e ) {
+ throw new GenerationException( "unable to generate SAX Parser", e );
+ }
+ catch ( SAXException e ) {
+ throw new GenerationException( "unable to generate SAX Parser", e );
+ }
+ }
+
+ private SAXParserFactory createParserFactory(boolean xincludeSupport) {
+ SAXParserFactory factory = new SAXParserFactoryImpl();
+ factory.setXIncludeAware( xincludeSupport );
+ return factory;
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/GenerationException.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/GenerationException.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/GenerationException.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,31 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.revdiff;
+
+/**
+ * Indicates problems generating the diff report
+ *
+ * @author Steve Ebersole
+ */
+public class GenerationException extends Exception {
+ public GenerationException(String message) {
+ super( message );
+ }
+
+ public GenerationException(String message, Throwable cause) {
+ super( message, cause );
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/IndexReportGenerator.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/IndexReportGenerator.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/IndexReportGenerator.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,84 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.revdiff;
+
+import java.util.Locale;
+import java.util.List;
+import java.util.Iterator;
+import java.util.ResourceBundle;
+
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.reporting.MavenReportException;
+
+/**
+ *
+ * @author Steve Ebersole
+ */
+public class IndexReportGenerator {
+ private final ResourceBundle bundle;
+ private final Sink sink;
+ private final Log log;
+
+ public static class TranslationReportDescriptor {
+ private final Locale translation;
+ private final String reportPath;
+
+ public TranslationReportDescriptor(Locale translation, String reportPath) {
+ this.translation = translation;
+ this.reportPath = reportPath;
+ }
+ }
+
+ public IndexReportGenerator(ResourceBundle bundle, Sink sink, Log log) {
+ this.bundle = bundle;
+ this.sink = sink;
+ this.log = log;
+ }
+
+ public void generate(List reportDescriptors) throws MavenReportException {
+ log.debug( "writing index report via provided sink" );
+ sink.head();
+ sink.text( bundle.getString( "report.name" ) );
+ sink.head_();
+
+ sink.body();
+ sink.sectionTitle1();
+ sink.anchor( bundle.getString( "report.header" ) );
+ sink.anchor_();
+ sink.text( bundle.getString( "report.header" ) );
+ sink.sectionTitle1_();
+
+ sink.table();
+ Iterator itr = reportDescriptors.iterator();
+ while ( itr.hasNext() ) {
+ final TranslationReportDescriptor descriptor = ( TranslationReportDescriptor ) itr.next();
+ sink.tableRow();
+ sink.tableCell();
+ sink.link( descriptor.reportPath );
+ sink.text( descriptor.translation.getDisplayName( Locale.ENGLISH ) + " (" + descriptor.translation.toString() + ")" );
+ sink.link_();
+ sink.tableCell_();
+ sink.tableRow_();
+ }
+ sink.table_();
+
+ sink.body_();
+ sink.flush();
+ sink.close();
+ log.debug( "index report sink flushed and closed" );
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/TranslationHandler.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/TranslationHandler.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/TranslationHandler.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,106 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Christian Bauer, Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.revdiff;
+
+import java.util.Map;
+import java.util.Iterator;
+
+import org.xml.sax.helpers.DefaultHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * Handles actually discerning diffs between the translations based on the
+ * revision numbers of the content elements.
+ *
+ * @author Christian Bauer
+ * @author Steve Ebersole
+ */
+public class TranslationHandler extends DefaultHandler {
+ private final Map catalog;
+ private final Diff diff;
+ private Locator docLocator;
+
+ public TranslationHandler(Map catalog, Diff diff) {
+ this.catalog = catalog;
+ this.diff = diff;
+ }
+
+ public void setDocumentLocator(Locator locator) {
+ this.docLocator = locator;
+ }
+
+ public void startElement(
+ String namespaceURI,
+ String localName,
+ String qualifiedName,
+ Attributes atts) throws SAXException {
+
+ String identifier = atts.getValue( "id" );
+ if ( identifier != null ) {
+ int revision = 0;
+ if ( atts.getValue( "revision" ) != null ) {
+ revision = Integer.parseInt( atts.getValue( "revision" ) );
+ }
+
+ ContentItemDescriptor translationState = new ContentItemDescriptor(
+ docLocator.getSystemId(),
+ qualifiedName,
+ revision,
+ docLocator.getLineNumber(),
+ docLocator.getColumnNumber()
+ );
+
+ // Locate the corresponding ContentItem from the master
+ //
+ // NOTE: we use remove to keep track of the fact that the transation
+ // has used that element; that way, afterwards, we know all the
+ // "unused" ones which would indicate elements recently added to
+ // the master...
+ ContentItem contentItem = ( ContentItem ) catalog.remove( identifier );
+ if ( contentItem == null ) {
+ // we have encountered an element in the translation which
+ // is not present in the master. This *should indicate that we
+ // have a section that was removed from the master, but not yet
+ // removed from the translation...
+ if ( revision != ContentItemDescriptor.REVISION_IGNORE ) {
+ contentItem = new ContentItem( identifier );
+ contentItem.setTranslationDescriptor( translationState );
+ diff.addOnlyInTranslation( contentItem );
+ }
+ }
+ else {
+ // the element is present in both; check the revisions
+ if ( revision != contentItem.getMasterDescriptor().getRevision() && revision != ContentItemDescriptor.REVISION_IGNORE ) {
+ contentItem.setTranslationDescriptor( translationState );
+ diff.addDiffRevision( contentItem );
+ }
+ }
+ }
+ }
+
+ public void finish() {
+ // anything left in the catalog at this point is stuff that is present
+ // in the master but absent from the translation...
+ Iterator itr = catalog.entrySet().iterator();
+ while ( itr.hasNext() ) {
+ final ContentItem contentItem = ( ContentItem ) ( ( Map.Entry ) itr.next() ).getValue();
+ itr.remove();
+ diff.addOnlyInMaster( contentItem );
+ }
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/TranslationReportGenerator.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/TranslationReportGenerator.java (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/revdiff/TranslationReportGenerator.java 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,202 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Christian Bauer, Steve Ebersole
+ */
+package org.jboss.maven.plugins.jdocbook.revdiff;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.ResourceBundle;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.maven.plugin.logging.Log;
+import org.codehaus.plexus.util.FileUtils;
+
+/**
+ * Generate a diff report.
+ *
+ * @author Christian Bauer
+ * @author Steve Ebersole
+ */
+public class TranslationReportGenerator {
+ // todo : use templating...
+ private final String base;
+ private final ResourceBundle bundle;
+ private final Log log;
+
+ public TranslationReportGenerator(File basedir, ResourceBundle bundle, Log log) {
+ try {
+ this.base = basedir.toURL().toExternalForm();
+ }
+ catch ( MalformedURLException e ) {
+ throw new IllegalArgumentException( "basedir was a malformed url" );
+ }
+ log.debug( "constructing docbook diff report generator [base=" + base + "]" );
+ this.bundle = bundle;
+ this.log = log;
+ }
+
+ public void generate(Diff diff, File output, String translation) throws GenerationException {
+ if ( output.exists() ) {
+ log.debug( "cleaning up previous translation-diff report output [" + output.getAbsolutePath() + "]" );
+ output.delete();
+ }
+
+ File outputDirectory = output.getParentFile();
+ if ( !outputDirectory.exists() ) {
+ String outputDirectoryPath = outputDirectory.getAbsolutePath();
+ log.debug( "creating translation-diff report directory [" + outputDirectoryPath + "]" );
+ FileUtils.mkdir( outputDirectoryPath );
+ }
+
+ try {
+ output.createNewFile();
+ }
+ catch ( IOException e ) {
+ throw new GenerationException( "unable to create output file [" + output.getAbsolutePath() + "]", e );
+ }
+
+ try {
+ FileWriter writer = new FileWriter( output );
+ writer.write( pageHead( translation ) );
+
+ writer.write( "<table cellpadding=4>" );
+
+ writer.write( generateNewInMaster( diff ) );
+ writer.write( "<tr><td> </td></tr>" );
+ writer.write( generateDiffRevision( diff ) );
+ writer.write( "<tr><td> </td></tr>" );
+ writer.write( generateNewInTranslation( diff ) );
+
+ writer.write( "</table>" );
+ writer.write( pageFoot() );
+ writer.close();
+ }
+ catch ( IOException e ) {
+ throw new GenerationException( "error writing report [" + output.getAbsolutePath() + "]", e );
+ }
+ }
+
+ private String pageHead(String translation) {
+ StringBuffer buf = new StringBuffer( 256 );
+ buf.append( "<html><head><title>" ).append( bundle.getString( "report.name" ) ).append( "</title></head><body><div align=\"center\">" );
+ buf.append( "<h3>" ).append( bundle.getString( "report.header") ).append( " - " ).append( translation ).append( "</h3>" );
+ return buf.toString();
+ }
+
+ private String pageFoot() {
+ StringBuffer buf = new StringBuffer( 256 );
+ buf.append( "</div></body></html>" );
+ return buf.toString();
+ }
+
+ private String generateNewInMaster(Diff diff) {
+ StringBuffer buf = new StringBuffer();
+ Iterator itr = diff.getElementsOnlyInMaster();
+ while ( itr.hasNext() ) {
+ final ContentItem contentItem = ( ContentItem ) itr.next();
+ buf.append( "<tr><td bgcolor=#eeeeee>ID: " ).append( contentItem.getIdentifier() ).append( "</td></tr>" );
+ buf.append( "<tr><td>" );
+ buf.append( "<b>" ).append( formatReference( contentItem.getMasterDescriptor() ) ).append( "</b>" );
+ buf.append( "</td></tr>" );
+ }
+
+ String result = "";
+ if ( buf.length() > 0 ) {
+ result = "<tr bgcolor=#cccccc><td><b>New in master:</b></td></tr>";
+ }
+ return result + buf.toString();
+ }
+
+ private String generateDiffRevision(Diff diff) {
+ StringBuffer buf = new StringBuffer();
+ Iterator itr = diff.getElementsDiffRevision();
+ while ( itr.hasNext() ) {
+ final ContentItem contentItem = ( ContentItem ) itr.next();
+ buf.append( "<tr><td bgcolor=#eeeeee>ID: " ).append( contentItem.getIdentifier() ).append( "</td></tr>" );
+ if ( !contentItem.getMasterDescriptor().getElementName().equals( contentItem.getTranslationDescriptor().getElementName() ) ) {
+ buf.append( "<tr><td bgcolor=#ee6666>" );
+ buf.append( "Element names differ: " )
+ .append( contentItem.getMasterDescriptor().getElementName() )
+ .append( "/" )
+ .append( contentItem.getTranslationDescriptor().getElementName() );
+ buf.append( "</td></tr>" );
+ }
+ buf.append( "<tr><td>" );
+ buf.append( "Master: <b>" ).append( formatReference( contentItem.getMasterDescriptor() ) ).append( "</b>" );
+ buf.append( "</td></tr>" );
+ buf.append( "<tr><td>" );
+ buf.append( "Translation: <b>" ).append( formatReference( contentItem.getTranslationDescriptor() ) ).append( "</b>" );
+ buf.append( "</td></tr>" );
+ buf.append( "<tr><td>" );
+ buf.append( "Master Revision: " ).append( contentItem.getMasterDescriptor().getRevision() );
+ buf.append( "</td></tr>" );
+ buf.append( "<tr><td>" );
+ buf.append( "Translation Revision: " ).append( contentItem.getTranslationDescriptor().getRevision() );
+ buf.append( "</td></tr>" );
+ }
+
+ String result = "";
+ if ( buf.length() > 0 ) {
+ result = "<tr bgcolor=#cccccc><td><b>Translation needs update:</b></td></tr>";
+ }
+ return result + buf.toString();
+ }
+
+ private String generateNewInTranslation(Diff diff) {
+ StringBuffer buf = new StringBuffer();
+ Iterator itr = diff.getElementsOnlyInTranslation();
+ while ( itr.hasNext() ) {
+ final ContentItem contentItem = ( ContentItem ) itr.next();
+ buf.append( "<tr><td bgcolor=#eeeeee>ID: " ).append( contentItem.getIdentifier() ).append( "</td></tr>" );
+ buf.append( "<tr><td>" );
+ buf.append( "<b>" ).append( formatReference( contentItem.getTranslationDescriptor() ) ).append( "</b>" );
+ buf.append( "</td></tr>" );
+ }
+ String result = "";
+ if ( buf.length() > 0 ) {
+ result = "<tr bgcolor=#cccccc><td><b>Only present in translation:</b></td></tr>";
+ }
+ return result + buf.toString();
+ }
+
+ private String formatReference(ContentItemDescriptor descriptor) {
+ return makeSystemIdRelative( descriptor.getSourceSystemId() ) +
+ ":" + descriptor.getElementName() +
+ " (" + descriptor.getRow() + "," + descriptor.getColumn() + ")";
+ }
+
+ private String makeSystemIdRelative(String systemId) {
+ String systemIdUrl = toURL( systemId ).toExternalForm();
+ log.debug( "checking source [" + systemIdUrl + "] against base [" + base + "]" );
+ if ( systemIdUrl.startsWith( base ) ) {
+ return systemIdUrl.substring( base.length() );
+ }
+ else {
+ return systemIdUrl;
+ }
+ }
+
+ private URL toURL(String systemId) {
+ try {
+ return new URL( systemId );
+ }
+ catch ( MalformedURLException e ) {
+ throw new UnsupportedOperationException( "unable to parse systemId [" + systemId + "] as URL" );
+ }
+ }
+}
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/resources/META-INF/plexus/components.xml
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/resources/META-INF/plexus/components.xml (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/resources/META-INF/plexus/components.xml 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,35 @@
+<component-set>
+
+ <components>
+
+ <!-- Defines the lifecycle associated with the 'docbook' packaging -->
+
+ <component>
+ <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
+ <role-hint>jdocbook</role-hint>
+ <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
+ <configuration>
+ <phases>
+ <process-resources>org.jboss.maven.plugins:maven-jdocbook-plugin:resources</process-resources>
+ <compile>org.jboss.maven.plugins:maven-jdocbook-plugin:generate</compile>
+ <package>org.jboss.maven.plugins:maven-jdocbook-plugin:bundle</package>
+ <install>org.apache.maven.plugins:maven-install-plugin:install</install>
+ <deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
+ </phases>
+ </configuration>
+ </component>
+
+ <!-- Defines the 'diff' reporting goal -->
+
+ <component>
+ <role>org.apache.maven.reporting.MavenReport</role>
+ <role-hint>diff</role-hint>
+ <implementation>
+ org.jboss.maven.plugins.jdocbook.TranslationDiffReport
+ </implementation>
+ <instantiation-strategy>per-lookup</instantiation-strategy>
+ </component>
+
+ </components>
+
+</component-set>
\ No newline at end of file
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/resources/translation-diff-report.properties
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/resources/translation-diff-report.properties (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/resources/translation-diff-report.properties 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,3 @@
+report.name=Translation Diff Report
+report.description=Calculates differences between translation and master
+report.header=Translation Diff Report
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/docbook-support.apt
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/docbook-support.apt (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/docbook-support.apt 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,46 @@
+ ------
+ DocBook Support
+ ------
+ Steve Ebersole
+ ------
+ 2 July 2007
+ ------
+
+~~ Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+~~
+~~ This copyrighted material is made available to anyone wishing to use, modify,
+~~ copy, or redistribute it subject to the terms and conditions of the GNU
+~~ Lesser General Public License, v. 2.1. This program is distributed in the
+~~ hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+~~ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+~~ Lesser General Public License for more details. You should have received a
+~~ copy of the GNU Lesser General Public License, v.2.1 along with this
+~~ distribution; if not, write to the Free Software Foundation, Inc.,
+~~ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+~~
+~~ Red Hat Author(s): Steve Ebersole
+
+docbook-support integration
+
+ <docbook-support> is another maven packaging type, defined by the
+ org.jboss.maven.plugins:maven-docbook-support-plugin plugin. The goal
+ of the <docbook-support> is to define a common, resuable packaging bundle
+ for DocBook support resources such as XSLT, images, fonts and css.
+ The <jDocBook Plugin> can take advantage of a <docbook-support> dependency
+ in two ways:
+
+ [[1]] Because
+
+ [[a]] dependencies are added to the classpath
+
+ [[b]] the <jDocBook Plugin> can locate XSLT via classpath resources (see {{{examples/custom-xslt.html} example}})
+
+ []
+
+ users can reference XSLT stylesheets from a <docbook-support> dependency
+ as a custom stylesheet (see the {{{format.html}formats}} page).
+
+ [[2]] Given the {{{staging.html}staging}} approach taken by this plugin
+ for dealing with with resources (css, fonts and images) it automatically
+ stages any css, font or image resources found inside a dependency of
+ type <docbook-support>. See {{{examples/html-resource-staging.html}example}}.
\ No newline at end of file
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/examples/custom-xslt.apt
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/examples/custom-xslt.apt (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/examples/custom-xslt.apt 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,118 @@
+ ------
+ Custom XSLT
+ ------
+ Steve Ebersole
+ ------
+ 2 July 2007
+ ------
+
+~~ Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+~~
+~~ This copyrighted material is made available to anyone wishing to use, modify,
+~~ copy, or redistribute it subject to the terms and conditions of the GNU
+~~ Lesser General Public License, v. 2.1. This program is distributed in the
+~~ hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+~~ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+~~ Lesser General Public License for more details. You should have received a
+~~ copy of the GNU Lesser General Public License, v.2.1 along with this
+~~ distribution; if not, write to the Free Software Foundation, Inc.,
+~~ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+~~
+~~ Red Hat Author(s): Steve Ebersole
+
+Custom XSLT
+
+ The {{{../usage.html}usage}} page describes the formats understood by
+ the <jDocBook Plugin>. Each of those formats map to a format understood
+ by DocBook itself, in terms of its provided XSLT. Thus, by default each
+ format is processed by the standard DocBook XSLT for the specified
+ format. It is possible for a user to redefine how transformations occur
+ for a given format by specifying that a custom XSLT be used instead of the
+ standard DocBook XSLT for that particular format in the configuration.
+ There are two main ways to define the custom xslt that shouold be used...
+
+* file: URL
+
+ The first approach is to specify a <file://> style URL. This URL could point
+ to any valid file. For example, referring to a project-local file for XSLT
+ processing might look like:
+
++----+
+...
+<plugin>
+ ...
+ <configuration>
+ <formats>
+ <format>
+ ...
+ <stylesheetResource>file:${basedir}/src/custom/xslt/mycustom.xsl</stylesheetResource>
+ </format>
+ </formats>
+ </configuration>
+</plugin>
++----+
+
+
+* classpath: URL
+
+ The second approach is to specify a <classpath://> URL. These will be resolved
+ against the current classpath when the plugin executes. Typically, these
+ resources would come from a dependency (see {{{../docbook-support.html}}} for
+ example). Referring to a classpath resource for XSLT processing might look like:
+
++----+
+...
+<plugin>
+ ...
+ <configuration>
+ <formats>
+ <format>
+ ...
+ <stylesheetResource>classpath:/myproject/mycustom.xsl</stylesheetResource>
+ </format>
+ </formats>
+ </configuration>
+</plugin>
++----+
+
+
+* docbook-support classpath: URL
+
+ See {{{../docbook-support.html}here}} for background discussion.
+
+ As a specific example of using an XSLT defined in a <docbook-support> package,
+ consider the following docbook-support package distributed by the venerable
+ Acme Corporation:
+
++----+
+acmeskin.docbook-support/
+ xslt/
+ com/
+ acme/
+ fo.xslt
++----+
+
+Using that would be as simple as:
+
++----+
+<plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifacId>maven-jdocbook-plugin</artifactId>
+ <extensions>true</extensions>
+ <dependencies>
+ <dependency>
+ <groupId>com.acme</groupId>
+ <artifactId>acmeskin</artifactId>
+ <type>docbook-support</type>
+ </dependency>
+ </dependencies>
+ <configuration>
+ <formats>
+ <format>
+ <formatName>pdf</formatName>
+ <stylesheetResource>classpath:/xslt/com/acme/fo.xslt</stylesheetResource>
+ </format>
+ </formats>
+ </configuration>
+</plugin>
++----+
\ No newline at end of file
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/examples/resource-staging.apt
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/examples/resource-staging.apt (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/examples/resource-staging.apt 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,35 @@
+ ------
+ Resource Staging
+ ------
+ Steve Ebersole
+ ------
+ 2 July 2007
+ ------
+
+~~ Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+~~
+~~ This copyrighted material is made available to anyone wishing to use, modify,
+~~ copy, or redistribute it subject to the terms and conditions of the GNU
+~~ Lesser General Public License, v. 2.1. This program is distributed in the
+~~ hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+~~ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+~~ Lesser General Public License for more details. You should have received a
+~~ copy of the GNU Lesser General Public License, v.2.1 along with this
+~~ distribution; if not, write to the Free Software Foundation, Inc.,
+~~ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+~~
+~~ Red Hat Author(s): Steve Ebersole
+
+Resource Staging
+
+* Project local resources
+
+ todo
+
+* docbook-support resources
+
+ todo
+
+* Arbitrary resources
+
+ todo
\ No newline at end of file
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/index.apt
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/index.apt (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/index.apt 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,94 @@
+ ------
+ Introduction
+ ------
+ Steve Ebersole
+ ------
+ 2 July 2007
+ ------
+
+~~ Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+~~
+~~ This copyrighted material is made available to anyone wishing to use, modify,
+~~ copy, or redistribute it subject to the terms and conditions of the GNU
+~~ Lesser General Public License, v. 2.1. This program is distributed in the
+~~ hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+~~ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+~~ Lesser General Public License for more details. You should have received a
+~~ copy of the GNU Lesser General Public License, v.2.1 along with this
+~~ distribution; if not, write to the Free Software Foundation, Inc.,
+~~ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+~~
+~~ Red Hat Author(s): Steve Ebersole
+
+jDocBook Plugin
+
+ DocBook is, in part, "an XML vocabulary that lets you create documents in a
+ presentation-neutral form that captures the logical structure of your
+ content". Another aspect of DocBook is the rendering of that content into
+ various formats using DocBook-supplied (or custom) XSLT stylesheets.
+ Basically, DocBook allows you to write and maintain a single source for
+ documentation, and to then render that single source into multiple formats
+ such as PDF or HTML.
+
+ The purpose of the <jDocBook Plugin> is to allow these DocBook
+ transformations to occur as a natural part of the users Maven build. The
+ main difficulty with this has always been the fact that DocBook
+ transformations are usually very closely tied to the user's local
+ environment. The design goal with writing this plugin was to utilize Maven's
+ dependency mechanism to bring all the pieces together on demand. Those
+ pieces are:
+
+ [[1]] the DocBook distribution;
+
+ [[2]] custom XSLT;
+
+ [[3]] custom fonts;
+
+ [[4]] custom images;
+
+ [[5]] custom css.
+
+ []
+
+ These are the ingredients that when mixed with the source file(s) and
+ stirred with an XSLT transformer produce the desired output(s).
+
+ Currently, only SAXON is supported as the transformer factory. I have
+ had issues getting XALAN to work properly.
+
+* Goals Overview
+
+ The <jDocBook Plugin> defines a dedicated project packaging ("jdocbook").
+ In part, this packaging is used to redefine a suitable set of lifecycle
+ phases pertinent to performing DocBook transformations. Below are the
+ defined lifecycle phases, with the goals attached to them:
+
+ [process-resources] binds the {{{resources-mojo.html}jdocbook:resources}}
+ goal which "stages" the resources need for the XSLT transformations such as
+ fonts, images and css.
+
+ [compile] binds the {{{generate-mojo.html}jdocbook:generate}} goal
+ which performs the actual XSLT transformations.
+
+ [package] binds the {{{bundle-mojo.html}jdocbook:bundle}} goal
+ which takes all the output formats, archives them as WARs and attaches the
+ WARs to the project with the format name as the artifact classifier.
+
+ [install] binds the standard install goal.
+
+ [deploy] binds the standard deploy goal.
+
+ []
+
+* Usage
+
+ Detailed usage instructions for the <jDocBook Plugin> can be found {{{usage.html}here}}.
+
+* Examples
+
+ To provide you with better understanding of some usages of the <jDocBook Plugin>,
+ you can take a look at the following examples:
+
+ * {{{examples/example-one.html}Example Description One}}
+
+ * {{{examples/example-two.html}Example Description Two}}
\ No newline at end of file
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/usage.apt
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/usage.apt (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/usage.apt 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,165 @@
+ ------
+ Usage
+ ------
+ Steve Ebersole
+ ------
+ 2 July 2007
+ ------
+
+~~ Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+~~
+~~ This copyrighted material is made available to anyone wishing to use, modify,
+~~ copy, or redistribute it subject to the terms and conditions of the GNU
+~~ Lesser General Public License, v. 2.1. This program is distributed in the
+~~ hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+~~ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+~~ Lesser General Public License for more details. You should have received a
+~~ copy of the GNU Lesser General Public License, v.2.1 along with this
+~~ distribution; if not, write to the Free Software Foundation, Inc.,
+~~ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+~~
+~~ Red Hat Author(s): Steve Ebersole
+
+Usage
+
+* Formats
+
+ Format is the term used to describe a particular output option for
+ a DocBook transformation. For example, we might talk about the PDF
+ output format, or the HTML output format.
+
+ * Supported formats
+
+ The <jDocBook Plugin> has support for most of the standard DocBook defined
+ formats as (as of DocBook version 1.70.1 and later). For completeness,
+ here is the full list of supported formats (as defined by the
+ {{{xref/org/jboss/maven/plugins/jdocbook/gen/util/StandardDocBookFormatSpecification.html}StandardDocBookFormatSpecification}}
+ class):
+
+ * HTML-based
+
+ [eclipse] generates an eclipse documentation bundle
+
+ [html] generates chunked HTML
+
+ [html_single] generated non-chunked HTML
+
+ [htmlhelp] generates HTMLHelp style documentation
+
+ [javahelp] generates JavaHelp style documentation
+
+ [man] generates HTML-based *nix man pages
+
+ [website] generates a website (?)
+
+ [xhtml] generates XHTML-compliant documentation
+
+ []
+
+ * FO-based
+
+ [pdf] generates a PDF document
+
+ []
+
+ []
+
+ * Configuring formats
+
+ Configuration of formats occurs via the {{{xref/org/jboss/maven/plugins/jdocbook/Format.html}Format}}
+ class. The list of configurable properties defined by the Format config
+ class include:
+
+ [formatName] This is the name of the output format. At least as of this
+ moment, this <<must>> map to one of the standard DocBook formats
+ detailed above; these values, then, simply act as overrides for the
+ values defined by the standard DocBook formats. This may change in
+ the future to allow arbitrary formats.
+
+ [targetFileExtension] The extension of the target output file.
+
+ [finalName] The final name of the output.
+
+ [stylesheetResource] URL to a custom style sheet. See {{{examples/custom-xslt.html}here}}
+ for examples of various URLs understood.
+
+ [imagePathSettingRequired] Does this format require the DocBook XSLT parameter
+ <img.src.path> to be set? Generally this is true only for output formats
+ which embed the images (i.e. PDF); HTML, for example, sets this to false.
+
+ [imageCopyingRequired] Does this format require copying of the image (and
+ css) resources to the format output directory? Generally, this and
+ the <imagePathSettingRequired> parameter should be mutually exclusive.
+ <Any situations where that is not the case?>
+
+ [doingChunking] Is this format performing chunking?
+
+ []
+
+ These {{{xref/org/jboss/maven/plugins/jdocbook/Format.html}Format}} values
+ are combined with the corresponding
+ {{{xref/org/jboss/maven/plugins/jdocbook/gen/util/StandardDocBookFormatSpecification.html}StandardDocBookFormatSpecification}}
+ values to determine the options used for that output format, with the
+ {{{xref/org/jboss/maven/plugins/jdocbook/Format.html}Format}} values given
+ precedence.
+
+ * Minimal format configuragtion:
+
+ Here is a minimal configuration defining PFD and HTML output formats:
+
++----+
+<plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifacId>maven-jdocbook-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <formats>
+ <format>
+ <formatName>pdf</formatName>
+ </format>
+ <format>
+ <formatName>html</formatName>
+ </format>
+ </formats>
+ </configuration>
+</plugin>
++----+
+
+* Staging
+
+ The <jDocBook Plugin> uses staging for handling of images, css and fonts in
+ a consistent manner. All of these resources miight come from multiple sources
+ and DocBook, generally speaking, only allows defining a single path for
+ resources. To get around that, the <jDocBook Plugin> collects all those
+ resources together under a single staging directory. By default, this directory
+ is <target/staging> directory, and each type of resource is under that. In
+ general there is not much to configure here, although you can point at alternate
+ source directories for css, fonts and images:
+
++----+
+<plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifacId>maven-jdocbook-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ ...
+ <imagesDirectory>path/to/alternate/image/dir</imagesDirectory>
+ <cssDirectory>path/to/alternate/css/dir</cssDirectory>
+ <fontsDirectory>path/to/alternate/fonts/dir</fontsDirectory>
+ </configuration>
+</plugin>
++----+
+
+ Or to an alternate location to use for staging:
+
++----+
+<plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifacId>maven-jdocbook-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ ...
+ <stagingDirectory>path/to/alternate/staging/dir</stagingDirectory>
+ </configuration>
+</plugin>
++----+
Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/site.xml
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/site.xml (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/site.xml 2007-07-03 02:04:15 UTC (rev 13024)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, v. 2.1. This program is distributed in the
+ ~ hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ ~ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details. You should have received a
+ ~ copy of the GNU Lesser General Public License, v.2.1 along with this
+ ~ distribution; if not, write to the Free Software Foundation, Inc.,
+ ~ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ ~
+ ~ Red Hat Author(s): Steve Ebersole
+ -->
+<project name="Maven">
+
+ <body>
+ <links>
+ <item name="DocBook" href="http://docbook.sourceforge.net/"/>
+ <item name="JBoss" href="http://jboss.org/" />
+ <item name="Maven" href="http://maven.apache.org/"/>
+ </links>
+
+ <menu name="Overview">
+ <item name="Introduction" href="index.html"/>
+ <item name="Goals" href="plugin-info.html"/>
+ <item name="Usage" href="usage.html"/>
+ <item name="docbook-support" href="docbook-support.html"/>
+ </menu>
+
+ <menu name="Examples">
+ <item name="Custom XSLT" href="examples/custom-xslt.html"/>
+ <item name="Resource Staging" href="examples/resource-staging.html"/>
+ </menu>
+
+ ${reports}
+ </body>
+
+</project>
More information about the jboss-svn-commits
mailing list