[jbpm-commits] JBoss JBPM SVN: r2239 - in jbpm4/docbook: src and 28 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Sep 15 04:25:23 EDT 2008
Author: tom.baeyens at jboss.com
Date: 2008-09-15 04:25:22 -0400 (Mon, 15 Sep 2008)
New Revision: 2239
Added:
jbpm4/docbook/.classpath
jbpm4/docbook/.project
jbpm4/docbook/pom.xml
jbpm4/docbook/src/
jbpm4/docbook/src/main/
jbpm4/docbook/src/main/java/
jbpm4/docbook/src/main/java/org/
jbpm4/docbook/src/main/java/org/jboss/
jbpm4/docbook/src/main/java/org/jboss/jdocbook/
jbpm4/docbook/src/main/java/org/jboss/jdocbook/JDocBookProcessException.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/Log.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/Options.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/
jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/Factory.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/PoSynchronizer.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/PotSynchronizer.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/TranslationBuilder.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/actions/
jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/gettext/
jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/gettext/PoSynchronizerImpl.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/gettext/PotSynchronizerImpl.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/gettext/TranslationBuilderImpl.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/profile/
jbpm4/docbook/src/main/java/org/jboss/jdocbook/profile/Profiler.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/profile/ProfilerFactory.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/profile/ProfilerImpl.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/
jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/Renderer.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/RenderingException.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/format/
jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/format/FormatPlan.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/format/StandardDocBookFormatDescriptor.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/format/StandardDocBookFormatDescriptors.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/format/TargetNamingStrategy.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/format/UserFormatConfiguration.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/impl/
jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/impl/BasicRenderer.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/impl/PDFRenderer.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/impl/RendererFactory.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/
jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/Constants.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/DocBookProfilingStrategy.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/FileUtils.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/I18nUtils.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/LocaleUtils.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/NoOpWriter.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/ResourceHelper.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/TransformerType.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/VCSDirectoryExclusionFilter.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/XIncludeHelper.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/
jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/TransformerBuilder.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/XSLTException.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/catalog/
jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/catalog/AbstractCatalogManager.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/catalog/ExplicitCatalogManager.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/catalog/ImplicitCatalogManager.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/
jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/BasicUrnResolver.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/ClasspathResolver.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/CurrentVersionResolver.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/ExplicitUrnResolver.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/RelativeJarUriResolver.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/ResolverChain.java
jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/VersionResolver.java
jbpm4/docbook/src/main/java/org/jboss/maven/
jbpm4/docbook/src/main/java/org/jboss/maven/plugins/
jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/
jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/AbstractDocBookMojo.java
jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/CleanPoMojo.java
jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/CleanPotMojo.java
jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/Format.java
jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/GenerationMojo.java
jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/Options.java
jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/PackageMojo.java
jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/ResourceMojo.java
jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/TranslationMojo.java
jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/UpdatePoMojo.java
jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/UpdatePotMojo.java
jbpm4/docbook/src/main/java/org/jboss/maven/shared/
jbpm4/docbook/src/main/java/org/jboss/maven/shared/process/
jbpm4/docbook/src/main/java/org/jboss/maven/shared/process/ExecutionException.java
jbpm4/docbook/src/main/java/org/jboss/maven/shared/process/Executor.java
jbpm4/docbook/src/main/java/org/jboss/maven/shared/process/ProcessOutputManager.java
jbpm4/docbook/src/main/java/org/jboss/maven/shared/process/StreamBridge.java
jbpm4/docbook/src/main/java/org/jboss/maven/shared/properties/
jbpm4/docbook/src/main/java/org/jboss/maven/shared/properties/CompositeMavenProjectProperties.java
jbpm4/docbook/src/main/java/org/jboss/maven/shared/properties/PropertiesException.java
jbpm4/docbook/src/main/java/org/jboss/maven/shared/properties/PropertiesHelper.java
jbpm4/docbook/src/main/java/org/jboss/maven/shared/resource/
jbpm4/docbook/src/main/java/org/jboss/maven/shared/resource/ResourceDelegate.java
jbpm4/docbook/src/main/java/org/jboss/maven/shared/resource/ResourceException.java
jbpm4/docbook/src/main/resources/
jbpm4/docbook/src/main/resources/META-INF/
jbpm4/docbook/src/main/resources/META-INF/plexus/
jbpm4/docbook/src/main/resources/META-INF/plexus/components.xml
jbpm4/docbook/src/site/
jbpm4/docbook/src/site/apt/
jbpm4/docbook/src/site/apt/examples/
jbpm4/docbook/src/site/apt/examples/arbitrary-styles.apt
jbpm4/docbook/src/site/apt/examples/custom-xslt.apt
jbpm4/docbook/src/site/apt/examples/docbook-version.apt
jbpm4/docbook/src/site/apt/examples/jdocbook-style.apt
jbpm4/docbook/src/site/apt/examples/project-local-style.apt
jbpm4/docbook/src/site/apt/formats.apt
jbpm4/docbook/src/site/apt/i18n.apt
jbpm4/docbook/src/site/apt/index.apt
jbpm4/docbook/src/site/apt/staging.apt
jbpm4/docbook/src/site/apt/style.apt
jbpm4/docbook/src/site/apt/usage.apt
jbpm4/docbook/src/site/site.xml
Log:
initial import: copy from jdocbook
Added: jbpm4/docbook/.classpath
===================================================================
--- jbpm4/docbook/.classpath (rev 0)
+++ jbpm4/docbook/.classpath 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: jbpm4/docbook/.project
===================================================================
--- jbpm4/docbook/.project (rev 0)
+++ jbpm4/docbook/.project 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>docbook</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: jbpm4/docbook/pom.xml
===================================================================
--- jbpm4/docbook/pom.xml (rev 0)
+++ jbpm4/docbook/pom.xml 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,229 @@
+<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/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-parent</artifactId>
+ <version>3</version>
+ </parent>
+
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jdocbook-plugin</artifactId>
+ <packaging>maven-plugin</packaging>
+ <version>2.1.3-SNAPSHOT</version>
+ <name>jDocBook Maven Plugin</name>
+ <description>This plugin adds support for DocBook handling 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>
+
+ <issueManagement>
+ <system>jira</system>
+ <url>http://jira.jboss.org/jira/browse/MPJDOCBOOK</url>
+ </issueManagement>
+
+ <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.jboss.org/repos/labs/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>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ <encoding>UTF-8</encoding>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-release-plugin</artifactId>
+ <version>2.0-beta-7</version>
+ <configuration>
+ <tagBase>https://svn.jboss.org/repos/labs/labs/jbossbuild/maven-plugins/tags</tagBase>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>2.3</version>
+ </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>
+ <!-- DocBook (this is the version used, unless user project imports one...) -->
+ <dependency>
+ <groupId>net.sf.docbook</groupId>
+ <artifactId>docbook</artifactId>
+ <version>1.72.0</version>
+ </dependency>
+
+ <!-- XML APIs -->
+ <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>
+ </dependency>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xmlParserAPIs</artifactId>
+ <version>2.6.2</version>
+ </dependency>
+
+ <!-- depending upon which transformer factory you want to use -->
+ <dependency>
+ <groupId>saxon</groupId>
+ <artifactId>saxon</artifactId>
+ <version>6.5.3</version>
+ </dependency>
+ <dependency>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ <version>2.7.0</version>
+ </dependency>
+
+ <!-- Maven Plugin deps -->
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>2.0.9</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.reporting</groupId>
+ <artifactId>maven-reporting-api</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>1.2</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>
+
+ <!-- FOP, used for FO (PDF) processing -->
+ <dependency>
+ <groupId>org.apache.xmlgraphics</groupId>
+ <artifactId>fop</artifactId>
+ <version>0.93</version>
+ </dependency>
+
+ <!-- Batik is used by FOP for SVG, PNG, and TIFF processing -->
+ <dependency>
+ <groupId>batik</groupId>
+ <artifactId>batik-css</artifactId>
+ <version>${batikVersion}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>batik</groupId>
+ <artifactId>batik-dom</artifactId>
+ <version>${batikVersion}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>batik</groupId>
+ <artifactId>batik-util</artifactId>
+ <version>${batikVersion}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>batik</groupId>
+ <artifactId>batik-xml</artifactId>
+ <version>${batikVersion}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- JAI is used by FOP for GIF and TIFF processing -->
+ <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>
+ <batikVersion>1.6</batikVersion>
+ </properties>
+
+</project>
\ No newline at end of file
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/JDocBookProcessException.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/JDocBookProcessException.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/JDocBookProcessException.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,40 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook;
+
+/**
+ * Indicates problem performing JDocBook-related processing.
+ *
+ * @author Steve Ebersole
+ */
+public class JDocBookProcessException extends RuntimeException {
+ public JDocBookProcessException(String message) {
+ super( message );
+ }
+
+ public JDocBookProcessException(String message, Throwable cause) {
+ super( message, cause );
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/Log.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/Log.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/Log.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,45 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook;
+
+/**
+ * A general 'log bridge' contract.
+ *
+ * @author Steve Ebersole
+ */
+public interface Log {
+ public void trace(String message);
+ public void trace(String message, Object... args);
+
+ public void info(String message);
+ public void info(String message, Object... args);
+ public void info(String message, Throwable exception);
+ public void info(String message, Throwable exception, Object... args);
+
+ public void error(String message);
+ public void error(String message, Object... args);
+ public void error(String message, Throwable exception);
+ public void error(String message, Throwable exception, Object... args);
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/Options.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/Options.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/Options.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,179 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook;
+
+import java.util.Properties;
+
+import org.apache.xml.resolver.CatalogManager;
+import org.apache.xml.resolver.tools.CatalogResolver;
+import org.jboss.jdocbook.util.TransformerType;
+import org.jboss.jdocbook.xslt.TransformerBuilder;
+import org.jboss.jdocbook.xslt.catalog.ExplicitCatalogManager;
+import org.jboss.jdocbook.xslt.catalog.ImplicitCatalogManager;
+
+/**
+ * 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;
+ private char localeSeparator = '-';
+
+ private CatalogResolver catalogResolver;
+ private TransformerBuilder transformerBuilder;
+
+ private Log log = new NoOpLog();
+
+ protected Options() {
+ }
+
+ public Options(char localeSeparator) {
+ this.localeSeparator = localeSeparator;
+ }
+
+ public Options(
+ boolean xincludeSupported,
+ String[] catalogs,
+ String xmlTransformerType,
+ Properties transformerParameters,
+ boolean useRelativeImageUris,
+ String docBookVersion,
+ char localeSeparator) {
+ this.xincludeSupported = xincludeSupported;
+ this.catalogs = catalogs;
+ this.xmlTransformerType = xmlTransformerType;
+ this.transformerParameters = transformerParameters;
+ this.useRelativeImageUris = useRelativeImageUris;
+ this.docbookVersion = docBookVersion;
+ this.localeSeparator = localeSeparator;
+ }
+
+ public boolean isXincludeSupported() {
+ return xincludeSupported;
+ }
+
+ public String[] getCatalogs() {
+ return catalogs;
+ }
+
+ public String getXmlTransformerType() {
+ return xmlTransformerType;
+ }
+
+ public TransformerType resolveXmlTransformerType() {
+ return TransformerType.parse( getXmlTransformerType() );
+ }
+
+ public Properties getTransformerParameters() {
+ if ( transformerParameters == null ) {
+ transformerParameters = new Properties();
+ }
+ return transformerParameters;
+ }
+
+ public boolean isUseRelativeImageUris() {
+ return useRelativeImageUris;
+ }
+
+ public String getDocbookVersion() {
+ return docbookVersion;
+ }
+
+ public void setDocbookVersion(String docbookVersion) {
+ this.docbookVersion = docbookVersion;
+ }
+
+ public char getLocaleSeparator() {
+ return localeSeparator;
+ }
+
+ public CatalogResolver getCatalogResolver() {
+ if ( catalogResolver == null ) {
+ CatalogManager catalogManager;
+ if ( getCatalogs() == null || getCatalogs().length == 0 ) {
+ catalogManager = new ImplicitCatalogManager();
+ }
+ else {
+ catalogManager = new ExplicitCatalogManager( getCatalogs() );
+ }
+ catalogResolver = new CatalogResolver( catalogManager );
+ }
+ return catalogResolver;
+ }
+
+ public TransformerBuilder getTransformerBuilder() {
+ if ( transformerBuilder == null ) {
+ transformerBuilder = new TransformerBuilder( this );
+ }
+ return transformerBuilder;
+ }
+
+ public void setLog(Log log) {
+ this.log = log;
+ }
+
+ public Log getLog() {
+ return log;
+ }
+
+ private static class NoOpLog implements Log {
+
+ public void trace(String message) {
+ }
+
+ public void trace(String message, Object... args) {
+ }
+
+ public void info(String message) {
+ }
+
+ public void info(String message, Object... args) {
+ }
+
+ public void info(String message, Throwable exception) {
+ }
+
+ public void info(String message, Throwable exception, Object... args) {
+ }
+
+ public void error(String message) {
+ }
+
+ public void error(String message, Object... args) {
+ }
+
+ public void error(String message, Throwable exception) {
+ }
+
+ public void error(String message, Throwable exception, Object... args) {
+ }
+ }
+}
\ No newline at end of file
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/Factory.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/Factory.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/Factory.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,59 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.jdocbook.i18n;
+
+import org.jboss.jdocbook.i18n.gettext.PoSynchronizerImpl;
+import org.jboss.jdocbook.i18n.gettext.PotSynchronizerImpl;
+import org.jboss.jdocbook.i18n.gettext.TranslationBuilderImpl;
+
+/**
+ * Factory for various i18n components. Statically bound to "gettext" versions.
+ *
+ * @author Steve Ebersole
+ */
+public class Factory {
+ private static final PotSynchronizer potSynchronizer = new PotSynchronizerImpl();
+ private static final PoSynchronizer poSynchronizer = new PoSynchronizerImpl();
+ private static final TranslationBuilder translationBuilder = new TranslationBuilderImpl();
+
+ /**
+ * Disallow instantiation
+ */
+ private Factory() {
+ }
+
+ public static PotSynchronizer getPotSynchronizer() {
+ return potSynchronizer;
+ }
+
+ public static PoSynchronizer getPoSynchronizer() {
+ return poSynchronizer;
+ }
+
+ public static TranslationBuilder getTranslationBuilder() {
+ return translationBuilder;
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/PoSynchronizer.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/PoSynchronizer.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/PoSynchronizer.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,53 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.jdocbook.i18n;
+
+import java.io.File;
+import java.util.Locale;
+
+import org.jboss.jdocbook.Options;
+import org.jboss.jdocbook.JDocBookProcessException;
+
+/**
+ * Contract for synchronizing (creating/updating) PortableObject (PO) file(s)
+ * for a given translation corresponding to the POT templates in the given
+ * POT-directory.
+ *
+ * @author Steve Ebersole
+ */
+public interface PoSynchronizer {
+ /**
+ * Perform the synchronization on the the PO files.
+ *
+ * @param potDirectory The directory containing the POT files.
+ * @param translationDirectory The directory containing the translation PO files.
+ * @param translationLocale The locale of the translation
+ * @param options The user options
+ * @throws JDocBookProcessException unable to synchronize POT files
+ */
+ public void synchronizePo(File potDirectory, File translationDirectory, Locale translationLocale, Options options)
+ throws JDocBookProcessException;
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/PotSynchronizer.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/PotSynchronizer.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/PotSynchronizer.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,54 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.jdocbook.i18n;
+
+import java.io.File;
+
+import org.jboss.jdocbook.JDocBookProcessException;
+import org.jboss.jdocbook.Options;
+
+/**
+ * Contract for synchronizing (creating/updating) PortableObjectTemplate (POT)
+ * file(s) from a given master source file.
+ * <p/>
+ * Any XIncludes contained in the master source file are followed and processed
+ * as well.
+ *
+ * @author Steve Ebersole
+ */
+public interface PotSynchronizer {
+ /**
+ * Perform the synchronization on the the POT files pertaining to the given
+ * master DocBook source.
+ *
+ * @param masterFile The DocBook source
+ * @param templateDirectory The directory where POT files are contained.
+ * @param options The user options
+ * @throws JDocBookProcessException unable to synchronize POT files
+ */
+ public void synchronizePot(File masterFile, File templateDirectory, Options options) throws JDocBookProcessException;
+
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/TranslationBuilder.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/TranslationBuilder.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/TranslationBuilder.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,50 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.jdocbook.i18n;
+
+import java.io.File;
+
+import org.jboss.jdocbook.Options;
+import org.jboss.jdocbook.JDocBookProcessException;
+
+/**
+ * Contract for applying the translators work (PO file) back into XML in
+ * preparation for XSLT processing.
+ *
+ * @author Steve Ebersole
+ */
+public interface TranslationBuilder {
+ /**
+ *
+ * @param masterFile The master DocBook source
+ * @param poDirectory The directory containing PO files
+ * @param targetDirectory The directory into which to generate the translated XML
+ * @param options The user options
+ * @throws JDocBookProcessException unable to apply PO translations
+ */
+ public void buildTranslation(File masterFile, File poDirectory, File targetDirectory, Options options)
+ throws JDocBookProcessException;
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/gettext/PoSynchronizerImpl.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/gettext/PoSynchronizerImpl.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/gettext/PoSynchronizerImpl.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,100 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.jdocbook.i18n.gettext;
+
+import java.io.File;
+import java.util.Locale;
+
+import org.jboss.jdocbook.JDocBookProcessException;
+import org.jboss.jdocbook.Options;
+import org.jboss.jdocbook.i18n.PoSynchronizer;
+import org.jboss.jdocbook.util.FileUtils;
+import org.jboss.jdocbook.util.I18nUtils;
+import org.jboss.jdocbook.util.VCSDirectoryExclusionFilter;
+import org.jboss.maven.shared.process.Executor;
+
+/**
+ * Implementation of the {@link PoSynchronizer} contract based on system calls
+ * to either the 'msgmerge' or the 'msginit' commands (both part of the GNU
+ * gettext package).
+ *
+ * @author Steve Ebersole
+ */
+public class PoSynchronizerImpl implements PoSynchronizer {
+ /**
+ * {@inheritDoc}
+ */
+ public void synchronizePo(File potDirectory, File translationDirectory, Locale translationLocale, Options options)
+ throws JDocBookProcessException {
+ if ( !potDirectory.exists() ) {
+ options.getLog().info( "skipping PO updates; POT directory did not exist : {0}", potDirectory );
+ return;
+ }
+ File[] files = potDirectory.listFiles( new VCSDirectoryExclusionFilter() );
+ for ( int i = 0, X = files.length; i < X; i++) {
+ if ( files[i].isDirectory() ) {
+ // recurse into the directory by calling back into ourselves with the sub-dir
+ synchronizePo(
+ new File( potDirectory, files[i].getName() ),
+ new File( translationDirectory, files[i].getName() ),
+ translationLocale,
+ options
+ );
+ }
+ else {
+ if ( I18nUtils.isPotFile( files[i] ) ) {
+ File translation = new File( translationDirectory, I18nUtils.determinePoFileName( files[i] ) );
+ updateTranslation( files[i], translation, translationLocale, options );
+ }
+ }
+ }
+ }
+
+ private void updateTranslation(File template, File translation, Locale translationLocale, Options options) {
+ if ( !template.exists() ) {
+ options.getLog().trace( "skipping PO updates; POT file did not exist : {0}", template );
+ return;
+ }
+
+ if ( translation.lastModified() >= template.lastModified() ) {
+ options.getLog().trace( "skipping PO updates; up-to-date : {0}", translation );
+ return;
+ }
+
+ final String cmd;
+ if ( translation.exists() ) {
+ cmd = "msgmerge --quiet --backup=none --update " + FileUtils.resolveFullPathName( translation )
+ + " " + FileUtils.resolveFullPathName( template );
+ }
+ else {
+ translation.getParentFile().mkdirs();
+ cmd = "msginit --no-translator -l " + translationLocale
+ + " -i " + FileUtils.resolveFullPathName( template )
+ + " -o " + FileUtils.resolveFullPathName( translation );
+ }
+ Executor.execute( cmd );
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/gettext/PotSynchronizerImpl.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/gettext/PotSynchronizerImpl.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/gettext/PotSynchronizerImpl.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,109 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.jdocbook.i18n.gettext;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import org.jboss.jdocbook.JDocBookProcessException;
+import org.jboss.jdocbook.Options;
+import org.jboss.jdocbook.i18n.PotSynchronizer;
+import org.jboss.jdocbook.util.FileUtils;
+import org.jboss.jdocbook.util.I18nUtils;
+import org.jboss.jdocbook.util.XIncludeHelper;
+import org.jboss.maven.shared.process.Executor;
+
+/**
+ * Implementation of the {@link PotSynchronizer} contract based on system calls
+ * to the xml2pot command (part of the KDE poxml package).
+ *
+ * @author Steve Ebersole
+ */
+public class PotSynchronizerImpl implements PotSynchronizer {
+ /**
+ * {@inheritDoc}
+ */
+ public void synchronizePot(File masterFile, File templateDirectory, Options options) throws JDocBookProcessException {
+ if ( !masterFile.exists() ) {
+ options.getLog().info( "skipping POT updates; master file did not exist : {0}", masterFile );
+ return;
+ }
+ final File sourceBasedir = masterFile.getParentFile();
+ final String potFileName = I18nUtils.determinePotFileName( masterFile );
+ final File potFile = new File( templateDirectory, potFileName );
+ updatePortableObjectTemplate( masterFile, potFile, options );
+
+ // Note : recursion below accounts for inclusions within inclusions
+ for ( File inclusion : XIncludeHelper.locateInclusions( masterFile ) ) {
+ final String relativity = FileUtils.determineRelativity( inclusion, sourceBasedir );
+ final File relativeTemplateDir = ( relativity == null ) ? templateDirectory : new File(
+ templateDirectory,
+ relativity
+ );
+ synchronizePot( inclusion, relativeTemplateDir, options );
+ }
+ }
+
+ private void updatePortableObjectTemplate(File masterFile, File potFile, Options options) {
+ if ( !masterFile.exists() ) {
+ options.getLog().trace( "skipping POT update; source file did not exist : {0}", masterFile );
+ return;
+ }
+
+ if ( potFile.exists() && potFile.lastModified() >= masterFile.lastModified() ) {
+ options.getLog().trace( "skipping POT update; up-to-date : {0}", potFile );
+ return;
+ }
+
+ potFile.getParentFile().mkdirs();
+ executeXml2pot( masterFile, potFile, options );
+ }
+
+ private void executeXml2pot(File masterFile, File potFile, Options options) {
+ final String cmd = "xml2pot " + FileUtils.resolveFullPathName( masterFile );
+
+ try {
+ final FileOutputStream xmlStream = new FileOutputStream( potFile );
+ try {
+ options.getLog().trace( "updating POT file {0}", potFile );
+ Executor.execute( cmd, xmlStream );
+ }
+ finally {
+ try {
+ xmlStream.flush();
+ xmlStream.close();
+ }
+ catch ( IOException ignore ) {
+ // intentionally empty...
+ }
+ }
+ }
+ catch ( IOException e ) {
+ throw new JDocBookProcessException( "unable to open output stream for POT file [" + potFile + "]" );
+ }
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/gettext/TranslationBuilderImpl.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/gettext/TranslationBuilderImpl.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/i18n/gettext/TranslationBuilderImpl.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,120 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.i18n.gettext;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import org.jboss.jdocbook.JDocBookProcessException;
+import org.jboss.jdocbook.Options;
+import org.jboss.jdocbook.i18n.TranslationBuilder;
+import org.jboss.jdocbook.util.FileUtils;
+import org.jboss.jdocbook.util.I18nUtils;
+import org.jboss.jdocbook.util.XIncludeHelper;
+import org.jboss.maven.shared.process.Executor;
+
+/**
+ * Implementation of the {@link org.jboss.jdocbook.i18n.TranslationBuilder} contract based on system calls
+ * to the 'po2xml' command (part of the KDE poxml package).
+ *
+ * @author Steve Ebersole
+ */
+public class TranslationBuilderImpl implements TranslationBuilder {
+ /**
+ * {@inheritDoc}
+ */
+ public void buildTranslation(File masterFile, File poDirectory, File targetDirectory, Options options)
+ throws JDocBookProcessException {
+ options.getLog().trace( "starting translation [" + masterFile + "]" );
+ if ( !masterFile.exists() ) {
+ options.getLog().info( "skipping translation; master file did not exist : {0}", masterFile );
+ return;
+ }
+
+ final String poFileName = I18nUtils.determinePoFileName( masterFile );
+ final File poFile = new File( poDirectory, poFileName );
+ if ( !poFile.exists() ) {
+ throw new JDocBookProcessException( "Unable to locate PO file for [" + masterFile.getName() + "] in [" + poDirectory.getName() + "]" );
+ }
+ final File translatedFile = new File( targetDirectory, masterFile.getName() );
+ generateTranslatedXML( masterFile, poFile, translatedFile, options );
+
+ // Note : recursion below accounts for inclusions within inclusions
+ final File sourceBasedir = masterFile.getParentFile();
+ for ( File inclusion : XIncludeHelper.locateInclusions( masterFile ) ) {
+ options.getLog().trace( "starting translation of inclusion [" + inclusion + "]" );
+ final String relativity = FileUtils.determineRelativity( inclusion, sourceBasedir );
+ options.getLog().trace( "determined relativity : " + relativity );
+ final File relativeTranslationDir = ( relativity == null )
+ ? poDirectory
+ : new File( poDirectory, relativity );
+ final File relativeWorkDir = ( relativity == null )
+ ? targetDirectory
+ : new File( targetDirectory, relativity );
+ buildTranslation( inclusion, relativeTranslationDir, relativeWorkDir, options );
+ }
+ }
+
+ private void generateTranslatedXML(File masterFile, File poFile, File translatedFile, Options options) {
+ if ( !masterFile.exists() ) {
+ options.getLog().trace( "skipping translation; source file did not exist : {0}", masterFile );
+ return;
+ }
+ if ( !poFile.exists() ) {
+ options.getLog().trace( "skipping translation; PO file did not exist : {0}", poFile );
+ return;
+ }
+
+ if ( translatedFile.exists()
+ && translatedFile.lastModified() >= masterFile.lastModified()
+ && translatedFile.lastModified() >= poFile.lastModified() ) {
+ options.getLog().trace( "skipping translation; up-to-date : {0}", translatedFile );
+ return;
+ }
+
+ translatedFile.getParentFile().mkdirs();
+ final String cmd = "po2xml " + FileUtils.resolveFullPathName( masterFile ) + " " + FileUtils.resolveFullPathName( poFile );
+ try {
+ final FileOutputStream xmlStream = new FileOutputStream( translatedFile );
+ try {
+ options.getLog().trace( "<execute>" + cmd + "</execution>" );
+ Executor.execute( cmd, xmlStream );
+ }
+ finally {
+ try {
+ xmlStream.flush();
+ xmlStream.close();
+ }
+ catch ( IOException ignore ) {
+ // intentionally empty...
+ }
+ }
+ }
+ catch ( IOException e ) {
+ throw new JDocBookProcessException( "unable to open output stream for translated XML file [" + translatedFile + "]" );
+ }
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/profile/Profiler.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/profile/Profiler.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/profile/Profiler.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,42 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.profile;
+
+import java.io.File;
+
+/**
+ * Contract for applying DocBook profiling based on the approach they term 'two-pass'.
+ *
+ * @author Steve Ebersole
+ */
+public interface Profiler {
+ /**
+ * Given a source file, create its profiled equivalent.
+ *
+ * @param source The source file to be profiled.
+ * @return The profiling output.
+ */
+ public File applyProfiling(File source);
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/profile/ProfilerFactory.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/profile/ProfilerFactory.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/profile/ProfilerFactory.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,61 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.profile;
+
+import java.io.File;
+
+import org.jboss.jdocbook.Options;
+
+/**
+ * A factory for {@link Profiler} instances.
+ *
+ * @author Steve Ebersole
+ */
+public class ProfilerFactory {
+
+ private final File outputDirectory;
+ private final Options options;
+
+ /**
+ * Constructs a factory capable of producing {@link Profiler} instances writing to the given directory.
+ *
+ * @param outputDirectory The directory where profiling output should be written.
+ * @param options The options.
+ */
+ public ProfilerFactory(File outputDirectory, Options options) {
+ this.options = options;
+ this.outputDirectory = outputDirectory;
+ }
+
+ /**
+ * Builds a profiler.
+ *
+ * @return The profiler.
+ */
+ public Profiler buildProfiler() {
+ return new ProfilerImpl( outputDirectory, options );
+ }
+
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/profile/ProfilerImpl.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/profile/ProfilerImpl.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/profile/ProfilerImpl.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,82 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.profile;
+
+import java.io.File;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.stream.StreamResult;
+
+import org.jboss.jdocbook.Options;
+import org.jboss.jdocbook.render.RenderingException;
+import org.jboss.jdocbook.util.Constants;
+import org.jboss.jdocbook.util.FileUtils;
+import org.jboss.jdocbook.xslt.XSLTException;
+
+/**
+ * Implementation of the {@link Profiler} contract.
+ *
+ * @author Steve Ebersole
+ */
+class ProfilerImpl implements Profiler {
+ private final File outputDirectory;
+ private final Options options;
+
+ ProfilerImpl(File outputDirectory, Options options) {
+ this.outputDirectory = outputDirectory;
+ this.options = options;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public File applyProfiling(File sourceFile) {
+ try {
+ if ( !outputDirectory.exists() ) {
+ outputDirectory.mkdirs();
+ }
+ File targetFile = new File( outputDirectory, sourceFile.getName() );
+ options.getLog().info( "applying DocBook profiling [" + targetFile.getAbsolutePath() + "]" );
+
+ Transformer xslt = options.getTransformerBuilder()
+ .buildStandardTransformer( Constants.MAIN_PROFILE_XSL_RESOURCE );
+ xslt.transform( buildSource( sourceFile ), buildResult( targetFile ) );
+ return targetFile;
+ }
+ catch ( TransformerException e ) {
+ throw new XSLTException( "error performing translation [" + e.getLocationAsString() + "] : " + e.getMessage(), e );
+ }
+ }
+
+ private Source buildSource(File sourceFile) throws RenderingException {
+ return FileUtils.createSAXSource( sourceFile, options.getCatalogResolver(), options.isXincludeSupported() );
+ }
+
+ protected Result buildResult(File targetFile) throws RenderingException, XSLTException {
+ return new StreamResult( targetFile );
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/Renderer.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/Renderer.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/Renderer.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,53 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.render;
+
+import java.io.File;
+
+import org.jboss.jdocbook.render.format.FormatPlan;
+import org.jboss.jdocbook.xslt.XSLTException;
+
+/**
+ * Renderer contract
+ *
+ * @author Steve Ebersole
+ */
+public interface Renderer {
+
+ /**
+ * Performs the actual rendering or transforming of the DocBook sources into
+ * the respective output format.
+ *
+ * @param source The source DocBook file.
+ * @param plan The formatting plan.
+ * @param renderingDirectory The directory into which to render
+ * @param stagingDirectory The directory where images resources were staged
+ * @throws RenderingException Problem writing the output file(s).
+ * @throws XSLTException Problem performing XSL transformation.
+ */
+ public void render(File source, FormatPlan plan, File renderingDirectory, File stagingDirectory) throws RenderingException, XSLTException;
+
+ public File getAttachableBundle(File source);
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/RenderingException.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/RenderingException.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/RenderingException.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,44 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.render;
+
+import org.jboss.jdocbook.JDocBookProcessException;
+
+/**
+ * Indicates issues performing rendering.
+ *
+ * @author Steve Ebersole
+ */
+public class RenderingException extends JDocBookProcessException {
+ private static final long serialVersionUID = -3442815604126090861L;
+
+ public RenderingException(String message) {
+ super( message );
+ }
+
+ public RenderingException(String message, Throwable cause) {
+ super( message, cause );
+ }
+}
\ No newline at end of file
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/format/FormatPlan.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/format/FormatPlan.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/format/FormatPlan.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,142 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.render.format;
+
+import java.io.File;
+
+import org.codehaus.plexus.util.FileUtils;
+import org.jboss.jdocbook.util.DocBookProfilingStrategy;
+
+/**
+ * Merging of DocBook standard information and user specifics. The combination represents the information that will
+ * control the format processing.
+ *
+ * @author Steve Ebersole
+ */
+public class FormatPlan {
+ private final String name;
+ private final String stylesheetResource;
+ private final String correspondingDocBookStylesheetResource;
+ private final boolean imagePathSettingRequired;
+ private final boolean imageCopyingRequired;
+ private final boolean doingChunking;
+ private final DocBookProfilingStrategy profiling;
+ private final TargetNamingStrategy targetNamingStrategy;
+
+ public FormatPlan(
+ final UserFormatConfiguration userFormatConfiguration,
+ final StandardDocBookFormatDescriptor docBookFormatDescriptor) {
+ this(
+ userFormatConfiguration,
+ docBookFormatDescriptor,
+ new TargetNamingStrategy() {
+ public String determineTargetFileName(File source) {
+ return userFormatConfiguration.getFinalName() == null
+ ? FileUtils.basename( source.getAbsolutePath() ) + docBookFormatDescriptor.getStandardFileExtension()
+ : userFormatConfiguration.getFinalName();
+ }
+ }
+ );
+ }
+
+ public FormatPlan(
+ UserFormatConfiguration userFormatConfiguration,
+ StandardDocBookFormatDescriptor docBookFormatDescriptor,
+ TargetNamingStrategy targetNamingStrategy) {
+ this.name = userFormatConfiguration.getFormatName();
+
+ this.profiling = DocBookProfilingStrategy.parse( userFormatConfiguration.getProfilingTypeName() );
+ this.stylesheetResource = userFormatConfiguration.getStylesheetResource() != null
+ ? userFormatConfiguration.getStylesheetResource()
+ : DocBookProfilingStrategy.SINGLE_PASS == profiling
+ ? docBookFormatDescriptor.getProfiledStylesheetResource()
+ : docBookFormatDescriptor.getStylesheetResource();
+ this.correspondingDocBookStylesheetResource = DocBookProfilingStrategy.SINGLE_PASS == profiling
+ ? docBookFormatDescriptor.getProfiledStylesheetResource()
+ : docBookFormatDescriptor.getStylesheetResource();
+
+ this.imagePathSettingRequired = userFormatConfiguration.getImagePathSettingRequired() == null
+ ? docBookFormatDescriptor.isImagePathSettingRequired()
+ : userFormatConfiguration.getImagePathSettingRequired();
+ this.imageCopyingRequired = userFormatConfiguration.getImageCopyingRequired() == null
+ ? docBookFormatDescriptor.isImageCopyingRequired()
+ : userFormatConfiguration.getImageCopyingRequired();
+ this.doingChunking = userFormatConfiguration.getDoingChunking() == null
+ ? docBookFormatDescriptor.isDoingChunking()
+ : userFormatConfiguration.getDoingChunking();
+ this.targetNamingStrategy = targetNamingStrategy;
+ }
+
+ public FormatPlan(
+ String name,
+ String stylesheetResource,
+ String correspondingDocBookStylesheetResource,
+ boolean imagePathSettingRequired,
+ boolean imageCopyingRequired,
+ boolean doingChunking,
+ DocBookProfilingStrategy profiling,
+ TargetNamingStrategy targetNamingStrategy) {
+ this.name = name;
+ this.stylesheetResource = stylesheetResource;
+ this.correspondingDocBookStylesheetResource = correspondingDocBookStylesheetResource;
+ this.imagePathSettingRequired = imagePathSettingRequired;
+ this.imageCopyingRequired = imageCopyingRequired;
+ this.doingChunking = doingChunking;
+ this.profiling = profiling;
+ this.targetNamingStrategy = targetNamingStrategy;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getStylesheetResource() {
+ return stylesheetResource;
+ }
+
+ public String getCorrespondingDocBookStylesheetResource() {
+ return correspondingDocBookStylesheetResource;
+ }
+
+ public boolean isImagePathSettingRequired() {
+ return imagePathSettingRequired;
+ }
+
+ public boolean isImageCopyingRequired() {
+ return imageCopyingRequired;
+ }
+
+ public boolean isDoingChunking() {
+ return doingChunking;
+ }
+
+ public TargetNamingStrategy getTargetNamingStrategy() {
+ return targetNamingStrategy;
+ }
+
+ public DocBookProfilingStrategy getProfiling() {
+ return profiling;
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/format/StandardDocBookFormatDescriptor.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/format/StandardDocBookFormatDescriptor.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/format/StandardDocBookFormatDescriptor.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,81 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.render.format;
+
+/**
+ * Contract for descriptors about standard DocBook formats.
+ *
+ * @author Steve Ebersole
+ */
+public interface StandardDocBookFormatDescriptor {
+ /**
+ * The name of this format.
+ *
+ * @return The format name.
+ */
+ public String getName();
+
+ /**
+ * The standard file extension used for this format.
+ *
+ * @return The file extension
+ */
+ public String getStandardFileExtension();
+
+ /**
+ * The standard DocBook stylesheet for this format (as a classpath-relative resource name).
+ *
+ * @return The DocBook stylesheet resource name
+ */
+ public String getStylesheetResource();
+
+ /**
+ * The standard DocBook stylesheet for this format for 'profiling' (as a classpath-relative resource name).
+ *
+ * @return The DocBook 'profiling' stylesheet resource name
+ */
+ public String getProfiledStylesheetResource();
+
+ /**
+ * Does this format require setting the 'img.src.path' DocBook XSLT parameter?
+ *
+ * @return Is setting 'img.src.path' required?
+ */
+ public boolean isImagePathSettingRequired();
+
+ /**
+ * Does this format require copying the images over to the target directory?
+ *
+ * @return Is copying images to the target directory required?
+ */
+ public boolean isImageCopyingRequired();
+
+ /**
+ * Is this format doing chunking?
+ *
+ * @return Doing chunking?
+ */
+ public boolean isDoingChunking();
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/format/StandardDocBookFormatDescriptors.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/format/StandardDocBookFormatDescriptors.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/format/StandardDocBookFormatDescriptors.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,209 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.render.format;
+
+/**
+ * Descriptors of the bundled DocBook styles in which we are interested.
+ *
+ * @author Steve Ebersole
+ */
+public class StandardDocBookFormatDescriptors {
+
+ public static final StandardDocBookFormatDescriptor PDF = new BasicDescriptor()
+ .setName( "pdf" )
+ .setStandardFileExtension( "pdf" )
+ .setImagePathSettingRequired( true )
+ .setImageCopyingRequired( false )
+ .setDoingChunking( false )
+ .setStylesheetResource( "/fo/docbook.xsl" )
+ .setProfiledStylesheetResource( "/fo/profile-docbook.xsl" );
+
+ public static final StandardDocBookFormatDescriptor XHTML = new BasicDescriptor()
+ .setName( "xhtml" )
+ .setStandardFileExtension( "xhtml" )
+ .setImagePathSettingRequired( false )
+ .setImageCopyingRequired( true )
+ .setDoingChunking( false )
+ .setStylesheetResource( "/xhtml/docbook.xsl" )
+ .setProfiledStylesheetResource( "/xhtml/profile-docbook.xsl" );
+
+ public static final StandardDocBookFormatDescriptor ECLIPSE = new HtmlBasedDescriptor()
+ .setName( "eclipse" )
+ .setStylesheetResource( "/eclipse/eclipse.xsl" );
+
+ public static final StandardDocBookFormatDescriptor HTML = new HtmlBasedDescriptor()
+ .setName( "html" )
+ .setStylesheetResource( "/html/chunk.xsl" )
+ .setProfiledStylesheetResource( "/html/profile-chunk.xsl" );
+
+ public static final StandardDocBookFormatDescriptor HTML_SINGLE = new HtmlBasedDescriptor()
+ .setName( "html_single" )
+ .setDoingChunking( false )
+ .setStylesheetResource( "/html/docbook.xsl" )
+ .setProfiledStylesheetResource( "/html/profile-docbook.xsl" );
+
+ public static final StandardDocBookFormatDescriptor HTMLHELP = new HtmlBasedDescriptor()
+ .setName( "htmlhelp" )
+ .setStylesheetResource( "/htmlhelp/htmlhelp.xsl" )
+ .setProfiledStylesheetResource( "/htmlhelp/profile-htmlhelp.xsl" );
+
+ public static final StandardDocBookFormatDescriptor JAVAHELP = new HtmlBasedDescriptor()
+ .setName( "javahelp" )
+ .setStylesheetResource( "/javahelp/javahelp.xsl" )
+ .setProfiledStylesheetResource( "/javahelp/profile-javahelp.xsl" );
+
+ public static final StandardDocBookFormatDescriptor MAN = new HtmlBasedDescriptor()
+ .setName( "man" )
+ .setDoingChunking( false )
+ .setStylesheetResource( "/manpages/docbook.xsl" );
+
+ public static final StandardDocBookFormatDescriptor WEBSITE = new HtmlBasedDescriptor()
+ .setName( "website" )
+ .setDoingChunking( false )
+ .setStylesheetResource( "/website/website.xsl" );
+
+ private static class HtmlBasedDescriptor extends BasicDescriptor {
+ private HtmlBasedDescriptor() {
+ doingChunking = true;
+ standardFileExtension = "html";
+ imagePathSettingRequired = false;
+ imageCopyingRequired = true;
+ }
+ }
+
+ private static class BasicDescriptor implements StandardDocBookFormatDescriptor {
+ protected String name;
+ protected String standardFileExtension;
+ protected String stylesheetResource;
+ protected String profiledStylesheetResource;
+ protected boolean imagePathSettingRequired;
+ protected boolean imageCopyingRequired;
+ protected boolean doingChunking;
+
+ public String getName() {
+ return name;
+ }
+
+ public BasicDescriptor setName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ public String getStandardFileExtension() {
+ return standardFileExtension;
+ }
+
+ public BasicDescriptor setStandardFileExtension(String standardFileExtension) {
+ this.standardFileExtension = standardFileExtension;
+ return this;
+ }
+
+ public String getStylesheetResource() {
+ return stylesheetResource;
+ }
+
+ public BasicDescriptor setStylesheetResource(String stylesheetResource) {
+ this.stylesheetResource = stylesheetResource;
+ // default :
+ this.profiledStylesheetResource = stylesheetResource;
+ return this;
+ }
+
+ public String getProfiledStylesheetResource() {
+ return profiledStylesheetResource;
+ }
+
+ public BasicDescriptor setProfiledStylesheetResource(String profiledStylesheetResource) {
+ this.profiledStylesheetResource = profiledStylesheetResource;
+ return this;
+ }
+
+ public boolean isImagePathSettingRequired() {
+ return imagePathSettingRequired;
+ }
+
+ public BasicDescriptor setImagePathSettingRequired(boolean imagePathSettingRequired) {
+ this.imagePathSettingRequired = imagePathSettingRequired;
+ return this;
+ }
+
+ public boolean isImageCopyingRequired() {
+ return imageCopyingRequired;
+ }
+
+ public BasicDescriptor setImageCopyingRequired(boolean imageCopyingRequired) {
+ this.imageCopyingRequired = imageCopyingRequired;
+ return this;
+ }
+
+ public boolean isDoingChunking() {
+ return doingChunking;
+ }
+
+ public BasicDescriptor setDoingChunking(boolean doingChunking) {
+ this.doingChunking = doingChunking;
+ return this;
+ }
+ }
+
+ public static StandardDocBookFormatDescriptor getDescriptor(String name) {
+ if ( ECLIPSE.getName().equals( name ) ) {
+ return ECLIPSE;
+ }
+ else if ( HTML.getName().equals( name ) ) {
+ return HTML;
+ }
+ else if ( HTML_SINGLE.getName().equals( name ) ) {
+ return HTML_SINGLE;
+ }
+ else if ( HTMLHELP.getName().equals( name ) ) {
+ return HTMLHELP;
+ }
+ else if ( JAVAHELP.getName().equals( name ) ) {
+ return JAVAHELP;
+ }
+ else if ( MAN.getName().equals( name ) ) {
+ return MAN;
+ }
+ else if ( PDF.getName().equals( name ) ) {
+ return PDF;
+ }
+ else if ( WEBSITE.getName().equals( name ) ) {
+ return WEBSITE;
+ }
+ else if ( XHTML.getName().equals( name ) ) {
+ return XHTML;
+ }
+ else {
+ return null;
+ }
+ }
+
+ /**
+ * Disallow external instantiation of StandardDocBookFormatDescriptors.
+ */
+ private StandardDocBookFormatDescriptors() {
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/format/TargetNamingStrategy.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/format/TargetNamingStrategy.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/format/TargetNamingStrategy.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,42 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.render.format;
+
+import java.io.File;
+
+/**
+ * Strategy for naming target files based on the source file.
+ *
+ * @author Steve Ebersole
+ */
+public interface TargetNamingStrategy {
+ /**
+ * Give a source file, determine the appropriate target file name.
+ *
+ * @param source The source file.
+ * @return The target file name.
+ */
+ public String determineTargetFileName(File source);
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/format/UserFormatConfiguration.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/format/UserFormatConfiguration.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/format/UserFormatConfiguration.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,99 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.render.format;
+
+/**
+ * Models configuration choices of a user in regards to a particular rendering format.
+ *
+ * @author Steve Ebersole
+ */
+public class UserFormatConfiguration {
+ protected String formatName;
+
+ protected String targetFileExtension;
+ protected String finalName;
+ protected String stylesheetResource;
+ protected Boolean imagePathSettingRequired;
+ protected Boolean imageCopyingRequired;
+ protected Boolean doingChunking;
+ protected String profilingTypeName;
+
+ /**
+ * Do not use! Needed by Maven :(
+ */
+ public UserFormatConfiguration() {
+ }
+
+ public UserFormatConfiguration(
+ String formatName,
+ String targetFileExtension,
+ String finalName,
+ String stylesheetResource,
+ Boolean imagePathSettingRequired,
+ Boolean imageCopyingRequired,
+ Boolean doingChunking,
+ String profilingTypeName) {
+ this.formatName = formatName;
+ this.targetFileExtension = targetFileExtension;
+ this.finalName = finalName;
+ this.stylesheetResource = stylesheetResource;
+ this.imagePathSettingRequired = imagePathSettingRequired;
+ this.imageCopyingRequired = imageCopyingRequired;
+ this.doingChunking = doingChunking;
+ this.profilingTypeName = profilingTypeName;
+ }
+
+ 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;
+ }
+
+ public String getProfilingTypeName() {
+ return profilingTypeName;
+ }
+}
\ No newline at end of file
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/impl/BasicRenderer.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/impl/BasicRenderer.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/impl/BasicRenderer.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,175 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.render.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.stream.StreamResult;
+
+import org.jboss.jdocbook.Options;
+import org.jboss.jdocbook.render.Renderer;
+import org.jboss.jdocbook.render.RenderingException;
+import org.jboss.jdocbook.render.format.FormatPlan;
+import org.jboss.jdocbook.util.FileUtils;
+import org.jboss.jdocbook.util.ResourceHelper;
+import org.jboss.jdocbook.xslt.XSLTException;
+
+/**
+ * The basic implementation of the {@link Renderer} contract.
+ *
+ * @author Steve Ebersole
+ */
+public class BasicRenderer implements Renderer {
+ protected final Options options;
+
+ /**
+ * Construct a renderer instance using the given <tt>options</tt>.
+ *
+ * @param options The options.
+ */
+ public BasicRenderer(Options options) {
+ this.options = options;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public File getAttachableBundle(File source) {
+ // todo : we need to figure out how we are going to handle attachments...
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void render(File sourceFile, FormatPlan formatPlan, File renderingDirectory, File stagingDirectory) throws RenderingException, XSLTException {
+ File targetDirectory = new File( renderingDirectory, formatPlan.getName() );
+ if ( ! targetDirectory.exists() ) {
+ FileUtils.mkdir( targetDirectory.getAbsolutePath() );
+ }
+
+ if ( formatPlan.isImageCopyingRequired() ) {
+ if ( stagingDirectory.exists() ) {
+ File imageBase = new File( stagingDirectory, "images" );
+ if ( imageBase.exists() ) {
+ try {
+ FileUtils.copyDirectoryStructure( imageBase, targetDirectory );
+ }
+ catch ( IOException e ) {
+ throw new RenderingException( "unable to copy images", e );
+ }
+ }
+ File cssBase = new File( stagingDirectory, "css" );
+ if ( cssBase.exists() ) {
+ try {
+ FileUtils.copyDirectoryStructure( cssBase, targetDirectory );
+ }
+ catch ( IOException e ) {
+ throw new RenderingException( "unable to copy css", e );
+ }
+ }
+ }
+ }
+
+ File targetFile = new File( targetDirectory, deduceTargetFileName( sourceFile, formatPlan ) );
+ if ( targetFile.exists() ) {
+ targetFile.delete();
+ }
+ if ( !targetFile.exists() ) {
+ try {
+ targetFile.createNewFile();
+ }
+ catch ( IOException e ) {
+ throw new RenderingException( "unable to create output file [" + targetFile.getAbsolutePath() + "]", e );
+ }
+ }
+
+ performRendering( sourceFile, formatPlan, stagingDirectory, targetFile );
+ }
+
+ private void performRendering(File sourceFile, FormatPlan formatPlan, File stagingDirectory, File targetFile) {
+ Transformer transformer = buildTransformer( targetFile, formatPlan, stagingDirectory );
+ Source transformationSource = buildSource( sourceFile );
+ Result transformationResult = buildResult( targetFile );
+ try {
+ transformer.transform( transformationSource, transformationResult );
+ }
+ catch ( TransformerException e ) {
+ throw new XSLTException( "error performing translation [" + e.getMessageAndLocation() + "]", e );
+ }
+ finally {
+ releaseResult( transformationResult );
+ }
+ }
+
+ private String deduceTargetFileName(File source, FormatPlan formatPlan) {
+ return formatPlan.getTargetNamingStrategy().determineTargetFileName( source );
+ }
+
+ protected Transformer buildTransformer(File targetFile, FormatPlan formatPlan, File stagingDirectory) throws RenderingException, XSLTException {
+ final URL transformationStylesheet = ResourceHelper.requireResource( formatPlan.getStylesheetResource() );
+ Transformer transformer = options.getTransformerBuilder().buildTransformer( formatPlan, transformationStylesheet );
+ if ( formatPlan.isImagePathSettingRequired() ) {
+ try {
+ String imgSrcPath = new File( stagingDirectory, "images" ).toURL().toString();
+ if ( !imgSrcPath.endsWith( "/" ) ) {
+ imgSrcPath += '/';
+ }
+ options.getLog().trace( "setting 'img.src.path' xslt parameter [" + imgSrcPath + "]" );
+ transformer.setParameter( "img.src.path", imgSrcPath );
+ }
+ catch ( MalformedURLException e ) {
+ throw new XSLTException( "unable to prepare 'img.src.path' xslt parameter", e );
+ }
+ }
+ transformer.setParameter( "keep.relative.image.uris", options.isUseRelativeImageUris() ? "1" : "0" );
+ if ( formatPlan.isDoingChunking() ) {
+ 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;
+ }
+
+ private Source buildSource(File sourceFile) throws RenderingException {
+ return FileUtils.createSAXSource( sourceFile, options.getCatalogResolver(), options.isXincludeSupported() );
+ }
+
+ protected Result buildResult(File targetFile) throws RenderingException, XSLTException {
+ return new StreamResult( targetFile );
+ }
+
+ protected void releaseResult(Result transformationResult) {
+ // typically nothing to do...
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/impl/PDFRenderer.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/impl/PDFRenderer.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/impl/PDFRenderer.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,104 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.render.impl;
+
+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.fop.apps.FOUserAgent;
+import org.apache.fop.apps.Fop;
+import org.apache.fop.apps.FopFactory;
+import org.apache.fop.apps.MimeConstants;
+import org.jboss.jdocbook.Options;
+import org.jboss.jdocbook.render.RenderingException;
+
+/**
+ * Implementation of the {@link org.jboss.jdocbook.render.Renderer} contract specifically for dealing with PDF generation.
+ *
+ * @author Steve Ebersole
+ */
+public class PDFRenderer extends BasicRenderer {
+ public PDFRenderer(Options options) {
+ super( options );
+ }
+
+ protected Result buildResult(File targetFile) throws RenderingException {
+ return new ResultImpl( targetFile );
+ }
+
+ protected void releaseResult(Result transformationResult) {
+ ( ( ResultImpl ) transformationResult ).release();
+ }
+
+ private class ResultImpl extends SAXResult {
+ private OutputStream outputStream;
+
+ public ResultImpl(File targetFile) throws RenderingException {
+ try {
+ FopFactory fopFactory = FopFactory.newInstance();
+// fopFactory.getRendererFactory().addRendererMaker(
+// new PDFRendererMaker() {
+//
+// }
+// );
+
+ outputStream = new BufferedOutputStream( new FileOutputStream( targetFile ) );
+
+ FOUserAgent fopUserAgent = fopFactory.newFOUserAgent();
+ fopUserAgent.setProducer( "jDocBook Plugin for Maven" );
+// fopUserAgent.setRendererOverride(
+// new org.apache.fop.render.pdf.PDFRenderer() {
+// public void setupFontInfo(FontInfo inFontInfo) {
+//
+// }
+// }
+// );
+
+ Fop fop = fopFactory.newFop( MimeConstants.MIME_PDF, fopUserAgent, outputStream );
+ setHandler( fop.getDefaultHandler() );
+ }
+ catch ( Throwable t ) {
+ throw new RenderingException( "error building transformation result [" + targetFile.getAbsolutePath() + "]", t );
+ }
+ }
+
+ private void release() {
+ if ( outputStream == null ) {
+ return;
+ }
+ try {
+ outputStream.flush();
+ outputStream.close();
+ }
+ catch ( IOException ignore ) {
+ }
+ }
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/impl/RendererFactory.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/impl/RendererFactory.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/render/impl/RendererFactory.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,57 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.render.impl;
+
+import org.jboss.jdocbook.Options;
+import org.jboss.jdocbook.render.format.StandardDocBookFormatDescriptors;
+import org.jboss.jdocbook.render.Renderer;
+
+/**
+ * A factory for building {@link Renderer} instances.
+ *
+ * @author Steve Ebersole
+ */
+public class RendererFactory {
+ private final Options options;
+
+ public RendererFactory(Options options) {
+ this.options = options;
+ }
+
+ /**
+ * Build an appropriate renderer for the given <tt>formatName</tt>
+ *
+ * @param formatName The name of the formatting in which we want to perform rendering.
+ * @return The renderer.
+ */
+ public Renderer buildRenderer(String formatName) {
+ if ( formatName.equals( StandardDocBookFormatDescriptors.PDF.getName() ) ) {
+ return new PDFRenderer( options );
+ }
+ else {
+ return new BasicRenderer( options );
+ }
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/Constants.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/Constants.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/Constants.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,47 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.util;
+
+/**
+ * Various string constants.
+ *
+ * @author Steve Ebersole
+ */
+public class Constants {
+ /**
+ * The DocBook-supplied XSL for profiling in (what it terms) the two-pass approach.
+ */
+ public static final String MAIN_PROFILE_XSL_RESOURCE = "profiling/profile.xsl";
+
+ /**
+ * The name of the XML DTD validation feature.
+ */
+ public static final String DTD_VALIDATION_FEATURE = "http://xml.org/sax/features/validation";
+
+ /**
+ * The name of the XML DTD loading feature.
+ */
+ public static final String DTD_LOADING_FEATURE = "http://apache.org/xml/features/nonvalidating/load-external-dtd";
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/DocBookProfilingStrategy.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/DocBookProfilingStrategy.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/DocBookProfilingStrategy.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,59 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.util;
+
+/**
+ * Enumeration of the different strategies defined by the DocBook reference manual for applying profiling.
+ *
+ * @author Steve Ebersole
+ */
+public class DocBookProfilingStrategy {
+ public static final DocBookProfilingStrategy NONE = new DocBookProfilingStrategy( "none" );
+ public static final DocBookProfilingStrategy SINGLE_PASS = new DocBookProfilingStrategy( "single_pass" );
+ public static final DocBookProfilingStrategy TWO_PASS = new DocBookProfilingStrategy( "two_pass" );
+
+ private final String name;
+
+ public DocBookProfilingStrategy(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public static DocBookProfilingStrategy parse(String text) {
+ if ( SINGLE_PASS.name.equalsIgnoreCase( text ) ) {
+ return SINGLE_PASS;
+ }
+ else if ( TWO_PASS.name.equalsIgnoreCase( text ) ) {
+ return TWO_PASS;
+ }
+ else {
+ // default...
+ return NONE;
+ }
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/FileUtils.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/FileUtils.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/FileUtils.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,206 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.util;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.net.MalformedURLException;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.sax.SAXSource;
+
+import org.apache.xerces.jaxp.SAXParserFactoryImpl;
+import org.jboss.jdocbook.JDocBookProcessException;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+/**
+ * Various {@link java.io.File file} and {@link java.io.File directory} related utilities.
+ *
+ * @author Steve Ebersole
+ */
+public class FileUtils extends org.codehaus.plexus.util.FileUtils {
+ /**
+ * A filter which simply accepts any file about which it is asked.
+ */
+ public static final FileFilter ACCEPT_ALL = new FileFilter() {
+ /**
+ * {@inheritDoc}
+ */
+ public boolean accept(File pathname) {
+ return true;
+ }
+ };
+
+ /**
+ * Create a SAXSource from a given <tt>file</tt>.
+ * <p/>
+ * NOTE: the result <b>is</b> {@link BufferedInputStream buffered}.
+ *
+ * @param file The file from which to generate a SAXSource
+ * @param resolver An entity resolver to apply to the file reader.
+ * @param xincludeAware Should we handle XIncludes?
+ * @return An appropriate SAXSource
+ */
+ public static SAXSource createSAXSource(File file, EntityResolver resolver, boolean xincludeAware) {
+ try {
+ SAXParserFactory factory = new SAXParserFactoryImpl();
+ factory.setXIncludeAware( xincludeAware );
+ XMLReader reader = factory.newSAXParser().getXMLReader();
+ reader.setEntityResolver( resolver );
+
+ // Disable DTD loading and validation
+ reader.setFeature( Constants.DTD_LOADING_FEATURE, false );
+ reader.setFeature( Constants.DTD_VALIDATION_FEATURE, false );
+
+ try {
+ InputSource source = new InputSource( new BufferedInputStream( new FileInputStream( file ) ) );
+ source.setSystemId( file.toURL().toString() );
+ return new SAXSource( reader, source );
+ }
+ catch ( FileNotFoundException e ) {
+ throw new JDocBookProcessException( "unable to locate source file", e );
+ }
+ catch ( MalformedURLException e ) {
+ throw new JDocBookProcessException( "unexpected problem converting file to URL", e );
+ }
+ }
+ catch ( ParserConfigurationException e ) {
+ throw new JDocBookProcessException( "unable to build SAX Parser/Factory [" + e.getMessage() + "]", e );
+ }
+ catch ( SAXException e ) {
+ throw new JDocBookProcessException( "unable to build SAX Parser/Factory [" + e.getMessage() + "]", e );
+ }
+
+ }
+
+ /**
+ * Determine the 'relativity' of a file in relation to the given basedir. 'relativity', is the relative path
+ * from the basedir to the file's parent (directory).
+ * <p/>
+ * For example, a file <tt>/home/steve/hibernate/tmp/Test.java</tt> would have a relativity of <tt>hibernate/tmp</tt>
+ * relative to <tt>/home/steve</tt> as the basedir.
+ *
+ * @param file The file for which to determine relativity.
+ * @param basedir The directory from which to base the relativity.
+ * @return The relativity.
+ * @throws RuntimeException Indicates that the given file was not found to be relative to basedir.
+ */
+ public static String determineRelativity(File file, File basedir) {
+ String basedirPath = resolveFullPathName( basedir );
+ String directory = resolveFullPathName( file.getParentFile() );
+ if ( basedirPath.equals( directory ) ) {
+ return null;
+ }
+ int baseStart = directory.indexOf( basedirPath );
+ if ( baseStart < 0 ) {
+ throw new RuntimeException( "Included file did not seem to be relative to basedir!" );
+ }
+ String relativity = directory.substring( basedirPath.length() + 1 );
+ while ( relativity.startsWith( "/" ) ) {
+ relativity = relativity.substring( 1 );
+ }
+ return relativity;
+ }
+
+ /**
+ * (recursively) find the most recent timestamp in said directory.
+ *
+ * @param directory The directory to check.
+ * @param acceptor A filter telling which files to consider.
+ * @return The most recent {@link File#lastModified() timestamp} found.
+ */
+ public static long findMostRecentTimestamp(File directory, FileFilter acceptor) {
+ return findMostRecentTimestamp( 0L, directory, acceptor );
+ }
+
+ private static long findMostRecentTimestamp(long current, File directory, FileFilter acceptor) {
+ long local = 0L;
+ for ( File subPath : directory.listFiles() ) {
+ final long temp;
+ if ( subPath.isDirectory() ) {
+ temp = findMostRecentTimestamp( current, directory, acceptor );
+ }
+ else if ( acceptor.accept( subPath ) ) {
+ temp = subPath.lastModified();
+ }
+ else {
+ temp = local;
+ }
+
+ if ( temp > local ) {
+ local = temp;
+ }
+ }
+ return local > current ? local : current;
+ }
+
+ /**
+ * (recursively) find the least recent timestamp in said directory.
+ *
+ * @param directory The directory to check.
+ * @param acceptor A filter telling which files to consider.
+ * @return The least recent {@link File#lastModified() timestamp} found.
+ */
+ public static long findLeastRecentTimestamp(File directory, FileFilter acceptor) {
+ return findLeastRecentTimestamp( Long.MAX_VALUE, directory, acceptor );
+ }
+
+ public static long findLeastRecentTimestamp(long current, File directory, FileFilter acceptor) {
+ long local = Long.MAX_VALUE;
+ for ( File subPath : directory.listFiles() ) {
+ final long temp;
+ if ( subPath.isDirectory() ) {
+ temp = findLeastRecentTimestamp( current, directory, acceptor );
+ }
+ else if ( acceptor.accept( subPath ) ) {
+ temp = subPath.lastModified();
+ }
+ else {
+ temp = local;
+ }
+
+ if ( temp < local ) {
+ local = temp;
+ }
+ }
+ return local < current ? local : current;
+ }
+
+ /**
+ * Here for consistent handling of full path names.
+ *
+ * @param path The path
+ * @return The full path name.
+ */
+ public static String resolveFullPathName(File path) {
+ return path.getAbsolutePath();
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/I18nUtils.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/I18nUtils.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/I18nUtils.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,67 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.util;
+
+import java.io.File;
+
+/**
+ * Collection of utilities for dealing with i18n support, as defined by GNU gettext.
+ *
+ * @author Steve Ebersole
+ */
+public class I18nUtils {
+ /**
+ * Is the given file a GNU gettext POT file?
+ * <p/>
+ * The determination here is made solely upon the file extension currently.
+ *
+ * @param file The file to check.
+ * @return True if it is considered a POT file; false otherwise.
+ */
+ public static boolean isPotFile(File file) {
+ return "pot".equals( FileUtils.getExtension( file.getName() ) );
+ }
+
+ /**
+ * Given a source file, determine its correspnding GNU gettext POT file name.
+ *
+ * @param source The source file.
+ * @return The corresponding POT file name.
+ */
+ public static String determinePotFileName(File source) {
+ return FileUtils.removeExtension( source.getName() ) + ".pot";
+ }
+
+ /**
+ * Given a source file (or a POT file), determine its correspnding GNU gettext PO file name.
+ *
+ * @param template The source (or POT) file.
+ * @return The corresponding PO file name.
+ */
+ public static String determinePoFileName(File template) {
+ return FileUtils.removeExtension( template.getName() ) + ".po";
+ }
+
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/LocaleUtils.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/LocaleUtils.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/LocaleUtils.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,78 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.util;
+
+import java.util.Comparator;
+import java.util.Locale;
+import java.util.StringTokenizer;
+
+/**
+ * Collection of utlities for dealing with {@link Locale locales}.
+ *
+ * @author Steve Ebersole
+ */
+public class LocaleUtils {
+
+ public static final LocaleComparator LOCALE_COMPARATOR_INST = new LocaleComparator();
+
+ public static class LocaleComparator implements Comparator {
+ public int compare(Object o1, Object o2) {
+ return render( ( Locale ) o1, '-' ).compareTo( render( ( Locale ) o2, '-' ) );
+ }
+ }
+
+ public static Locale parse(String locale) {
+ return parse( locale, '-' );
+ }
+
+ public static Locale parse(String locale, char sep) {
+ StringTokenizer tokens = new StringTokenizer( locale, "" + sep );
+ int tokencount = tokens.countTokens();
+ switch ( tokencount ) {
+ case 3 :
+ return new Locale( tokens.nextToken(), tokens.nextToken(), tokens.nextToken() );
+ case 2 :
+ return new Locale( tokens.nextToken(), tokens.nextToken() );
+ case 1 :
+ return new Locale( tokens.nextToken() );
+ default:
+ return new Locale( "tbd" );
+ }
+ }
+
+ public static String render(Locale locale, char sep) {
+ boolean l = locale.getLanguage().length() != 0;
+ boolean c = locale.getCountry().length() != 0;
+ boolean v = locale.getVariant().length() != 0;
+ StringBuffer result = new StringBuffer( locale.getLanguage() );
+ if (c||(l&&v)) {
+ result.append( sep ).append( locale.getCountry() );
+ }
+ if (v&&(l||c)) {
+ result.append( sep ).append( locale.getVariant() );
+ }
+ return result.toString();
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/NoOpWriter.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/NoOpWriter.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/NoOpWriter.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,44 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.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() {
+ }
+}
\ No newline at end of file
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/ResourceHelper.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/ResourceHelper.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/ResourceHelper.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,90 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.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 {
+ /**
+ * Locate said resource, throwing an exception if it could not be found.
+ *
+ * @param name The resource name.
+ * @return The resource's URL.
+ * @throws IllegalArgumentException If the resource could not be found.
+ */
+ public static URL requireResource(String name) {
+ URL resource = locateResource( name );
+ if ( resource == null ) {
+ throw new IllegalArgumentException( "could not locate resource [" + name + "]" );
+ }
+ return resource;
+ }
+
+ /**
+ * Locate said resource.
+ *
+ * @param name The resource name.
+ * @return The resource's URL.
+ */
+ 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 + "]");
+ }
+ }
+ 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;
+ }
+}
\ No newline at end of file
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/TransformerType.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/TransformerType.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/TransformerType.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,91 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.util;
+
+import javax.xml.transform.sax.SAXTransformerFactory;
+
+/**
+ * Enumeration of supported XSLT transformers.
+ *
+ * @author Steve Ebersole
+ */
+public abstract class TransformerType {
+ public static final TransformerType SAXON = new SaxonTransformerType();
+ public static final TransformerType XALAN = new XalanTransformerType();
+
+ private final String name;
+
+ private SAXTransformerFactory factory;
+
+ private TransformerType(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public SAXTransformerFactory getSAXTransformerFactory() {
+ if ( factory == null ) {
+ factory = buildSAXTransformerFactory();
+ }
+ return factory;
+ }
+
+ protected abstract SAXTransformerFactory buildSAXTransformerFactory();
+
+ public static TransformerType parse(String name) {
+ if ( XALAN.name.equals( name ) ) {
+ return XALAN;
+ }
+ else {
+ // default
+ return SAXON;
+ }
+ }
+
+ /**
+ * The SAXON transformer type...
+ */
+ public static class SaxonTransformerType extends TransformerType {
+ public SaxonTransformerType() {
+ super( "saxon" );
+ }
+
+ public SAXTransformerFactory buildSAXTransformerFactory() {
+ return new com.icl.saxon.TransformerFactoryImpl();
+ }
+ }
+
+ public static class XalanTransformerType extends TransformerType {
+ public XalanTransformerType() {
+ super( "xalan" );
+ }
+
+ public SAXTransformerFactory buildSAXTransformerFactory() {
+ return new org.apache.xalan.processor.TransformerFactoryImpl();
+ }
+ }
+}
\ No newline at end of file
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/VCSDirectoryExclusionFilter.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/VCSDirectoryExclusionFilter.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/VCSDirectoryExclusionFilter.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,61 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.util;
+
+import java.io.FileFilter;
+import java.io.File;
+
+import org.codehaus.plexus.util.DirectoryScanner;
+import org.codehaus.plexus.util.SelectorUtils;
+
+/**
+ * A {@link FileFilter} which excludes VCS metadata directories...
+ *
+ * @author Steve Ebersole
+ */
+public class VCSDirectoryExclusionFilter implements FileFilter {
+ /**
+ * {@inheritDoc}
+ */
+ public boolean accept(File path) {
+ if ( path.isDirectory() ) {
+ if ( isVCSDirectory( path ) ) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static boolean isVCSDirectory(File path) {
+ final String absolutePath = path.getAbsolutePath();
+ for ( int i = 0, X = DirectoryScanner.DEFAULTEXCLUDES.length; i < X; i++ ) {
+ if ( SelectorUtils.matchPath( DirectoryScanner.DEFAULTEXCLUDES[i], absolutePath, true ) ) {
+ // do not accept file on match against an exclude
+ return true;
+ }
+ }
+ return false;
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/XIncludeHelper.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/XIncludeHelper.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/util/XIncludeHelper.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,91 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Set;
+import java.util.TreeSet;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.xerces.jaxp.SAXParserFactoryImpl;
+import org.jboss.jdocbook.JDocBookProcessException;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * A helper for dealing with XIncludes.
+ *
+ * @author Steve Ebersole
+ */
+public class XIncludeHelper {
+ /**
+ * Given a file which defining an XML document containing XInclude elements, collect all the referenced XInclude
+ * files.
+ *
+ * @param root The file which (potentially) contains XIncludes.
+ * @return The set of files references via XIncludes.
+ */
+ public static Set<File> locateInclusions(File root) {
+ final Set<File> includes = new TreeSet<File>();
+ try {
+ SAXParserFactory parserFactory = new SAXParserFactoryImpl();
+ parserFactory.setXIncludeAware( true );
+
+ EntityResolver resolver = new EntityResolver() {
+ public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
+ if ( publicId == null && systemId != null && systemId.startsWith( "file:/" ) ) {
+ try {
+ includes.add( new File( new URL( systemId ).getFile() ) );
+ }
+ catch ( MalformedURLException e ) {
+ // should never happen...
+ throw new JDocBookProcessException( "Unable to convert reported XInclude href into URL instance [" + systemId + "]" );
+ }
+ }
+ return null;
+ }
+ };
+
+ Source transformationSource = FileUtils.createSAXSource( root, resolver, true );
+ Result transformationResult = new StreamResult( new NoOpWriter() );
+
+ javax.xml.transform.TransformerFactory transformerFactory = new com.icl.saxon.TransformerFactoryImpl();
+ transformerFactory.newTransformer().transform( transformationSource, transformationResult );
+ }
+ catch ( TransformerException e ) {
+ throw new JDocBookProcessException( "Problem performing 'transformation'", e );
+ }
+
+ return includes;
+ }
+}
\ No newline at end of file
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/TransformerBuilder.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/TransformerBuilder.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/TransformerBuilder.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,156 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.xslt;
+
+import java.io.IOException;
+import java.net.URL;
+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.jboss.jdocbook.render.format.FormatPlan;
+import org.jboss.jdocbook.util.NoOpWriter;
+import org.jboss.jdocbook.util.ResourceHelper;
+import org.jboss.jdocbook.xslt.resolve.ClasspathResolver;
+import org.jboss.jdocbook.xslt.resolve.CurrentVersionResolver;
+import org.jboss.jdocbook.xslt.resolve.ExplicitUrnResolver;
+import org.jboss.jdocbook.xslt.resolve.RelativeJarUriResolver;
+import org.jboss.jdocbook.xslt.resolve.ResolverChain;
+import org.jboss.jdocbook.xslt.resolve.VersionResolver;
+import org.jboss.jdocbook.Options;
+
+/**
+ * A builder of {@link javax.xml.transform.Transformer} instances, configurable
+ * to return either SAXON or XALAN based transformers.
+ *
+ * @author Steve Ebersole
+ */
+public class TransformerBuilder {
+ private final Options options;
+
+ public TransformerBuilder(Options options) {
+ this.options = options;
+ }
+
+ public Transformer buildStandardTransformer(URL xslt) {
+ URIResolver uriResolver = buildStandardUriResolver();
+ return buildTransformer( xslt, uriResolver );
+ }
+
+ public Transformer buildStandardTransformer(String xsltResource) {
+ URIResolver uriResolver = buildStandardUriResolver();
+ return buildTransformer( ResourceHelper.requireResource( xsltResource ), uriResolver );
+ }
+
+ public Transformer buildTransformer(FormatPlan formatPlan, URL customStylesheet) throws XSLTException {
+ URIResolver uriResolver = buildUriResolver( formatPlan );
+ URL xsltStylesheet = customStylesheet == null
+ ? ResourceHelper.requireResource( formatPlan.getStylesheetResource() )
+ : customStylesheet;
+ return buildTransformer( xsltStylesheet, uriResolver );
+ }
+
+ protected Transformer buildTransformer(URL xslt, URIResolver uriResolver) throws XSLTException {
+ javax.xml.transform.TransformerFactory transformerFactory = options.resolveXmlTransformerType().getSAXTransformerFactory();
+ transformerFactory.setURIResolver( uriResolver );
+
+ Transformer transformer;
+ try {
+ Source source = new StreamSource( xslt.openStream(), xslt.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.getLocationAsString() + "] : " + e.getMessage(), e );
+ }
+
+ configureTransformer( transformer, uriResolver, options.getTransformerParameters() );
+
+ return transformer;
+
+ }
+
+ public void configureTransformer(Transformer transformer, FormatPlan formatPlan) {
+ configureTransformer( transformer, buildUriResolver( formatPlan ), options.getTransformerParameters() );
+ }
+
+ public static void configureTransformer(Transformer transformer, URIResolver uriResolver, Properties transformerParameters) {
+ if ( transformer instanceof Controller ) {
+ Controller controller = ( Controller ) transformer;
+ try {
+ controller.makeMessageEmitter();
+ controller.getMessageEmitter().setWriter( new NoOpWriter() );
+ }
+ catch ( TransformerException te ) {
+ // intentionally empty
+ }
+ }
+
+ transformer.setURIResolver( uriResolver );
+ transformer.setParameter( "fop.extensions", "0" );
+ transformer.setParameter( "fop1.extensions", "1" );
+
+ if ( transformerParameters == null ) {
+ return;
+ }
+ for ( Map.Entry<Object, Object> entry : transformerParameters.entrySet() ) {
+ transformer.setParameter( ( String ) entry.getKey(), entry.getValue() );
+ }
+ }
+
+ public ResolverChain buildStandardUriResolver() {
+ ResolverChain resolverChain = new ResolverChain();
+ applyStandardResolvers( resolverChain );
+ return resolverChain;
+ }
+
+ public ResolverChain buildUriResolver(FormatPlan formatPlan) throws XSLTException {
+ return buildUriResolver( formatPlan.getName(), formatPlan.getCorrespondingDocBookStylesheetResource() );
+ }
+
+ public ResolverChain buildUriResolver(String formatName, String docBookstyleSheet) throws XSLTException {
+ ResolverChain resolverChain = new ResolverChain( new ExplicitUrnResolver( formatName, docBookstyleSheet ) );
+ applyStandardResolvers( resolverChain );
+ return resolverChain;
+ }
+
+ private void applyStandardResolvers(ResolverChain resolverChain) {
+ resolverChain.addResolver( new CurrentVersionResolver() );
+ if ( options.getDocbookVersion() != null ) {
+ resolverChain.addResolver( new VersionResolver( options.getDocbookVersion() ) );
+ }
+ resolverChain.addResolver( new RelativeJarUriResolver() );
+ resolverChain.addResolver( new ClasspathResolver() );
+ resolverChain.addResolver( options.getCatalogResolver() );
+ }
+}
\ No newline at end of file
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/XSLTException.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/XSLTException.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/XSLTException.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,45 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.xslt;
+
+import org.jboss.jdocbook.JDocBookProcessException;
+
+/**
+ * Indicates problems either building XSLT transformers or performing
+ * transformations.
+ *
+ * @author Steve Ebersole
+ */
+public class XSLTException extends JDocBookProcessException {
+ private static final long serialVersionUID = -8042140232571503488L;
+
+ public XSLTException(String message) {
+ super( message );
+ }
+
+ public XSLTException(String message, Throwable cause) {
+ super( message, cause );
+ }
+}
\ No newline at end of file
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/catalog/AbstractCatalogManager.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/catalog/AbstractCatalogManager.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/catalog/AbstractCatalogManager.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,57 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.xslt.catalog;
+
+import java.util.List;
+
+import org.apache.xml.resolver.CatalogManager;
+
+/**
+ * Basic support for our notion of CatalogManagers.
+ *
+ * @author Steve Ebersole
+ */
+public abstract class AbstractCatalogManager extends CatalogManager {
+ public AbstractCatalogManager(List<String> catalogNames) {
+ super();
+ setIgnoreMissingProperties( true );
+ if ( catalogNames != null && !catalogNames.isEmpty() ) {
+ StringBuffer buffer = new StringBuffer();
+ boolean first = true;
+ for ( String catalogName : catalogNames ) {
+ if ( catalogName != null ) {
+ if ( first ) {
+ first = false;
+ }
+ else {
+ buffer.append( ';' );
+ }
+ buffer.append( catalogName );
+ }
+ }
+ setCatalogFiles( buffer.toString() );
+ }
+ }
+}
\ No newline at end of file
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/catalog/ExplicitCatalogManager.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/catalog/ExplicitCatalogManager.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/catalog/ExplicitCatalogManager.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,43 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.xslt.catalog;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Utilizes explicit, user-supplied catalog names to build a
+ * CatalogManager.
+ *
+ * @author Steve Ebersole
+ */
+public class ExplicitCatalogManager extends AbstractCatalogManager {
+ public ExplicitCatalogManager(List<String> catalogNames) {
+ super( catalogNames );
+ }
+ public ExplicitCatalogManager(String[] catalogNames) {
+ this( Arrays.asList( catalogNames ) );
+ }
+}
\ No newline at end of file
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/catalog/ImplicitCatalogManager.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/catalog/ImplicitCatalogManager.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/catalog/ImplicitCatalogManager.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,65 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.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 ArrayList<String> resolveCatalogNames() {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ if ( classLoader == null ) {
+ classLoader = ImplicitCatalogManager.class.getClassLoader();
+ }
+ ArrayList<String> names = new ArrayList<String>();
+ 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 names;
+ }
+}
\ No newline at end of file
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/BasicUrnResolver.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/BasicUrnResolver.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/BasicUrnResolver.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,66 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.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 javax.xml.transform.Source}.
+ *
+ * @author Steve Ebersole
+ */
+public class BasicUrnResolver implements URIResolver {
+ private final String urn;
+ private final Source source;
+
+ /**
+ * Constructs a {@link URIResolver} which maps occurences of the given <tt>urn</tt> onto the given
+ * <tt>source</tt>
+ *
+ * @param urn The urn to be replaced.
+ * @param source The value to return instead of the urn.
+ */
+ public BasicUrnResolver(String urn, Source source) {
+ this.urn = urn;
+ this.source = source;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Source resolve(String href, String base) throws TransformerException {
+ return urn.equals( href ) ? source : null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString() {
+ return super.toString() + " [URN:" + urn + "]";
+ }
+}
\ No newline at end of file
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/ClasspathResolver.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/ClasspathResolver.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/ClasspathResolver.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,68 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.jdocbook.xslt.resolve;
+
+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;
+
+/**
+ *
+ * Resolves classpath references from the given classloader using classpath:/
+ * as the protocol handler
+ *
+ * @author Pete Muir
+ */
+public class ClasspathResolver implements URIResolver {
+ private final ClassLoader classLoader;
+
+ public ClasspathResolver(ClassLoader classLoader) {
+ this.classLoader = classLoader;
+ }
+
+ public ClasspathResolver() {
+ this( Thread.currentThread().getContextClassLoader() );
+ }
+
+ public Source resolve(String href, String base) throws TransformerException {
+ // href would need to start with classpath:
+ if ( !href.startsWith( "classpath:" ) ) {
+ return null;
+ }
+
+ try {
+ URL url = classLoader.getResource( href.substring(10) );
+ return new StreamSource( url.openStream(), url.toExternalForm() );
+ }
+ catch ( Throwable t ) {
+ return null;
+ }
+ }
+
+}
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/CurrentVersionResolver.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/CurrentVersionResolver.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/CurrentVersionResolver.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,40 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.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 {
+ /**
+ * Constructs a new CurrentVersionResolver instance.
+ */
+ public CurrentVersionResolver() {
+ super( "current" );
+ }
+}
\ No newline at end of file
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/ExplicitUrnResolver.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/ExplicitUrnResolver.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/ExplicitUrnResolver.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,66 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.xslt.resolve;
+
+import java.io.IOException;
+import java.net.URL;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+
+import org.jboss.jdocbook.xslt.XSLTException;
+import org.jboss.jdocbook.util.ResourceHelper;
+
+
+/**
+ * Resolves an explicit <tt>urn:docbook:stylesheet</tt> URN against the standard
+ * DocBook stylesheets.
+ *
+ * @author Steve Ebersole
+ */
+public class ExplicitUrnResolver extends BasicUrnResolver {
+ private final String name;
+
+ public ExplicitUrnResolver(String name, String stylesheetResource) throws XSLTException {
+ super( "urn:docbook:stylesheet", createSource( name, stylesheetResource ) );
+ this.name = name;
+ }
+
+ private static Source createSource(String name, String stylesheetResource) throws XSLTException {
+ URL stylesheet = ResourceHelper.requireResource( stylesheetResource );
+ try {
+ return new StreamSource( stylesheet.openStream(), stylesheet.toExternalForm() );
+ }
+ catch ( IOException e ) {
+ throw new XSLTException( "could not locate DocBook stylesheet [" + name + "]", e );
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString() {
+ return super.toString() + " [" + name + "]";
+ }
+}
\ No newline at end of file
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/RelativeJarUriResolver.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/RelativeJarUriResolver.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/RelativeJarUriResolver.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,62 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.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 {
+ /**
+ * {@inheritDoc}
+ */
+ 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;
+ }
+ }
+}
\ No newline at end of file
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/ResolverChain.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/ResolverChain.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/ResolverChain.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,77 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.xslt.resolve;
+
+import java.util.List;
+import java.util.ArrayList;
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
+
+/**
+ * Allows chaining a series of {@link javax.xml.transform.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 final List<URIResolver> resolvers = new ArrayList<URIResolver>();
+
+ 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;
+ for ( URIResolver resolver : resolvers ) {
+ result = resolver.resolve( href, base );
+ if ( result != null ) {
+ break;
+ }
+ }
+ return result;
+ }
+}
\ No newline at end of file
Added: jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/VersionResolver.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/VersionResolver.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/jdocbook/xslt/resolve/VersionResolver.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,91 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.jdocbook.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.jdocbook.util.ResourceHelper;
+
+/**
+ * Maps docbook-version based URIs to local classpath lookups. These URIs are in the form
+ * 'http://docbook.sourceforge.net/release/xsl/{version}'
+ *
+ * @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;
+
+ /**
+ * Constructs a VersionResolver instance using the given <tt>version</tt>.
+ *
+ * @param version The version.
+ */
+ public VersionResolver(String version) {
+ this.version = version;
+ this.versionHref = BASE_HREF + version;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ 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;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString() {
+ return super.toString() + " [version=" + version + "]";
+ }
+}
\ No newline at end of file
Added: jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/AbstractDocBookMojo.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/AbstractDocBookMojo.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/AbstractDocBookMojo.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,492 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.maven.plugins.jdocbook;
+
+import java.io.File;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Resource;
+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.apache.maven.execution.MavenSession;
+import org.codehaus.plexus.archiver.manager.ArchiverManager;
+import org.jboss.jdocbook.JDocBookProcessException;
+import org.jboss.jdocbook.Log;
+import org.jboss.jdocbook.render.RenderingException;
+import org.jboss.jdocbook.render.format.FormatPlan;
+import org.jboss.jdocbook.render.format.StandardDocBookFormatDescriptors;
+import org.jboss.jdocbook.util.LocaleUtils;
+import org.jboss.jdocbook.xslt.XSLTException;
+
+/**
+ * Basic support for the various DocBook mojos in this packaging plugin.
+ * Mainly, we are defining common configuration attributes of the packaging.
+ *
+ * @author Steve Ebersole
+ */
+public abstract class AbstractDocBookMojo extends AbstractMojo {
+ public static final String PLUGIN_NAME = "jdocbook";
+
+ /**
+ * INTERNAL : The project being built
+ *
+ * @parameter expression="${project}"
+ * @required
+ * @readonly
+ */
+ protected MavenProject project;
+
+ /**
+ * INTERNAL : The representation of the maven execution.
+ *
+ * @parameter expression="${session}"
+ * @required
+ * @readonly
+ */
+ protected MavenSession session;
+
+ /**
+ * 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 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;
+
+ /**
+ * A {@link Resource} describing project-local images.
+ *
+ * @parameter
+ */
+ protected Resource imageResource;
+
+ /**
+ * A {@link Resource} describing project-local css.
+ *
+ * @parameter
+ */
+ protected Resource cssResource;
+
+ /**
+ * 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/publish"
+ */
+ protected File publishDirectory;
+
+ /**
+ * The directory where we can perform some staging staging occurs. Mainly
+ * this is used for (1) image/css staging; (2) font staging.
+ *
+ * @parameter expression="${basedir}/target/docbook/staging"
+ * @required
+ * @readonly
+ */
+ protected File stagingDirectory;
+
+ /**
+ * A directory used for general transient work.
+ *
+ * @parameter expression="${basedir}/target/docbook/work"
+ * @required
+ * @readonly
+ */
+ protected File workDirectory;
+
+ /**
+ * The formats in which to perform rendering.
+ *
+ * @parameter
+ * @required
+ */
+ protected Format[] formats;
+
+ /**
+ * Whether or not to perform the attching of the format
+ * outputs as classified attachments.
+ *
+ * @parameter
+ */
+ protected boolean attach = true;
+
+ /**
+ * Configurable options
+ *
+ * @parameter
+ */
+ protected Options options;
+
+
+ // translation-specific config setting ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * The locale of the master translation.
+ *
+ * @parameter default-value="en-US"
+ */
+ protected String masterTranslation;
+
+ /**
+ * The path (relative to the sourceDirectory) to the directory containing the master sources. By default the
+ * master-translation's locale (en-US) will be used if such a directory exists <b>if translations are specified</b>.
+ * Users can explicitly specify such a relative path here.
+ *
+ * @parameter default-value=""
+ */
+ protected String relativeMasterTranslationPath;
+
+ /**
+ * The directory for POT translations files.
+ *
+ * @parameter expression="${basedir}/src/main/docbook/pot"
+ */
+ protected File potDirectory;
+
+ /**
+ * The locales of all non-master translations.
+ *
+ * @parameter
+ */
+ protected String[] translations;
+
+ /**
+ * The directory which contains the translations. The assumed strategy here is that each translation would
+ * have a directory under the directory named here which would contain the PO sources for that particular
+ * language translation. The default here is to use sourceDirectory itself.
+ *
+ * @parameter
+ */
+ protected File translationBaseDirectory;
+
+ private File resolvedMasterSourceDirectory;
+
+ /**
+ * The override method to perform the actual processing of the
+ * mojo.
+ *
+ * @param formatPlans The format plans
+ * @throws RenderingException Indicates problem performing rendering
+ * @throws XSLTException Indicates problem building or executing XSLT transformer
+ */
+ protected void process(FormatPlan[] formatPlans) throws JDocBookProcessException {
+ }
+
+ protected void doExecute() throws JDocBookProcessException {
+ process( determineFormatPlans() );
+ }
+
+ public final void execute() throws MojoExecutionException, MojoFailureException {
+ if ( options == null ) {
+ options = new Options();
+ }
+ options.setLog( new MavenLogBridge() );
+
+ if ( translationBaseDirectory == null ) {
+ translationBaseDirectory = sourceDirectory;
+ }
+
+ if ( translations == null ) {
+ translations = new String[0];
+ }
+
+
+ if ( relativeMasterTranslationPath == null || "".equals( relativeMasterTranslationPath ) ) {
+ // see if we have a directory named according to the master translation within the sourceDorectory...
+ File test = new File( sourceDirectory, masterTranslation );
+ if ( test.exists() ) {
+ relativeMasterTranslationPath = masterTranslation;
+ }
+ }
+
+ resolvedMasterSourceDirectory = sourceDirectory;
+ if ( relativeMasterTranslationPath != null && !"".equals( relativeMasterTranslationPath ) ) {
+ resolvedMasterSourceDirectory = new File( resolvedMasterSourceDirectory, relativeMasterTranslationPath );
+ }
+
+ try {
+ doExecute();
+ }
+ catch ( XSLTException e ) {
+ throw new MojoExecutionException( "XSLT problem", e );
+ }
+ catch ( RenderingException e ) {
+ throw new MojoExecutionException( "Rendering problem", e );
+ }
+ }
+
+ private FormatPlan[] determineFormatPlans() {
+ FormatPlan[] plans = new FormatPlan[ formats.length ];
+ for ( int i = 0; i < formats.length; i++ ) {
+ plans[i] = new FormatPlan( formats[i], StandardDocBookFormatDescriptors.getDescriptor( formats[i].getFormatName() ) );
+ }
+ return plans;
+ }
+
+ protected String getRequestedFormat() {
+ String requestedFormat = session.getExecutionProperties().getProperty( "jdocbook.format" );
+ if ( requestedFormat != null ) {
+ getLog().info( "requested processing limited to [" + requestedFormat + "] format" );
+ }
+ return requestedFormat;
+ }
+
+ protected Locale getRequestedLocale() {
+ String requestedLocaleStr = session.getExecutionProperties().getProperty( "jdocbook.lang" );
+ Locale requestedLocale = requestedLocaleStr == null ? null : parseLocale( requestedLocaleStr );
+ if ( requestedLocale != null ) {
+ getLog().info( "requested processing limited to [" + stringify( requestedLocale ) + "] lang" ) ;
+ }
+ return requestedLocale;
+ }
+
+ protected MasterTranslationDescriptor getMasterTranslationDescriptor() {
+ return new MasterTranslationDescriptor( parseLocale( masterTranslation ) );
+ }
+
+ protected List<PublishingSource> getPublishingSources() {
+ ArrayList<PublishingSource> descriptors = new ArrayList<PublishingSource>();
+ descriptors.add( getMasterTranslationDescriptor() );
+
+ for ( String locale : translations ) {
+ descriptors.add( new TranslationDescriptor( parseLocale( locale ) ) );
+ }
+
+ return descriptors;
+ }
+
+ protected List<I18nSource> getI18nSources() {
+ ArrayList<I18nSource> descriptors = new ArrayList<I18nSource>();
+ for ( String locale : translations ) {
+ descriptors.add( new TranslationDescriptor( parseLocale( locale ) ) );
+ }
+ return descriptors;
+ }
+
+ protected static interface ArtifactProcessor {
+ public void process(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) {
+ for ( Object artifact : artifacts ) {
+ processor.process( ( Artifact ) artifact );
+ }
+ }
+
+ protected Locale parseLocale(String locale) {
+ return LocaleUtils.parse( locale, options.getLocaleSeparator() );
+ }
+
+ protected String stringify(Locale locale) {
+ return LocaleUtils.render( locale, options.getLocaleSeparator() );
+ }
+
+ protected static interface PublishingSource {
+ public Locale getLocale();
+ public File resolveDocumentFile();
+ public File resolvePublishingDirectory();
+ }
+
+ protected static interface I18nSource {
+ public Locale getLocale();
+ public File resolvePoDirectory();
+ public File resolveTranslatedXmlDirectory();
+ }
+
+ protected class MasterTranslationDescriptor implements PublishingSource {
+ private final Locale locale;
+
+ public MasterTranslationDescriptor(Locale locale) {
+ this.locale = locale;
+ }
+
+ public Locale getLocale() {
+ return locale;
+ }
+
+ public File resolveDocumentFile() {
+ return new File( resolvedMasterSourceDirectory, sourceDocumentName );
+ }
+
+ public File resolvePublishingDirectory() {
+ return new File( publishDirectory, stringify( locale ) );
+ }
+ }
+
+ protected class TranslationDescriptor implements PublishingSource, I18nSource {
+ private final Locale locale;
+
+ public TranslationDescriptor(Locale locale) {
+ this.locale = locale;
+ }
+
+ public Locale getLocale() {
+ return locale;
+ }
+
+ public File resolvePoDirectory() {
+ return new File( translationBaseDirectory, stringify( locale ) );
+ }
+
+ public File resolveTranslatedXmlDirectory() {
+ return new File( new File( workDirectory, "xml" ), stringify( locale ) );
+ }
+
+ public File resolveDocumentFile() {
+ return new File( resolveTranslatedXmlDirectory(), sourceDocumentName );
+ }
+
+ public File resolvePublishingDirectory() {
+ return new File( publishDirectory, stringify( locale ) );
+ }
+ }
+
+ private class MavenLogBridge implements Log {
+ public void trace(String message) {
+ getLog().debug( message );
+ }
+
+ public void trace(String message, Object... args) {
+ if ( getLog().isDebugEnabled() ) {
+ getLog().debug( MessageFormat.format( message, args ) );
+ }
+ }
+
+ public void info(String message) {
+ getLog().info( message );
+ }
+
+ public void info(String message, Object... args) {
+ if ( getLog().isInfoEnabled() ) {
+ getLog().info( MessageFormat.format( message, args ) );
+ }
+ }
+
+ public void info(String message, Throwable exception) {
+ getLog().info( message, exception );
+ }
+
+ public void info(String message, Throwable exception, Object... args) {
+ if ( getLog().isInfoEnabled() ) {
+ getLog().info( MessageFormat.format( message, args ), exception );
+ }
+ }
+
+ public void error(String message) {
+ getLog().error( message );
+ }
+
+ public void error(String message, Object... args) {
+ if ( getLog().isErrorEnabled() ) {
+ getLog().error( MessageFormat.format( message, args ) );
+ }
+ }
+
+ public void error(String message, Throwable exception) {
+ getLog().error( message, exception );
+ }
+
+ public void error(String message, Throwable exception, Object... args) {
+ if ( getLog().isErrorEnabled() ) {
+ getLog().error( MessageFormat.format( message, args ), exception );
+ }
+ }
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/CleanPoMojo.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/CleanPoMojo.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/CleanPoMojo.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,61 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.maven.plugins.jdocbook;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Locale;
+
+import org.jboss.jdocbook.JDocBookProcessException;
+import org.codehaus.plexus.util.FileUtils;
+
+/**
+ * CleanPoMojo implementation
+ *
+ * @goal clean-po
+ * @requiresDependencyResolution
+ *
+ * @author Steve Ebersole
+ */
+public class CleanPoMojo extends AbstractDocBookMojo {
+ protected void doExecute() throws JDocBookProcessException {
+ Locale requestedLocale = getRequestedLocale();
+ for ( I18nSource source : getI18nSources() ) {
+ if ( requestedLocale != null && !requestedLocale.equals( source.getLocale() ) ) {
+ continue;
+ }
+ final File poDirectory = source.resolvePoDirectory();
+ if ( poDirectory.exists() ) {
+ try {
+ FileUtils.cleanDirectory( poDirectory );
+ }
+ catch ( IOException e ) {
+ getLog().warn( "unable to cleanup POT directory [" + poDirectory + "]", e );
+ }
+ }
+ }
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/CleanPotMojo.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/CleanPotMojo.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/CleanPotMojo.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,52 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.maven.plugins.jdocbook;
+
+import java.io.IOException;
+
+import org.codehaus.plexus.util.FileUtils;
+import org.jboss.jdocbook.JDocBookProcessException;
+
+/**
+ * Cleanup the POT files.
+ *
+ * @goal clean-pot
+ * @requiresDependencyResolution
+ *
+ * @author Steve Ebersole
+ */
+public class CleanPotMojo extends AbstractDocBookMojo {
+ protected void doExecute() throws JDocBookProcessException {
+ if ( potDirectory.exists() ) {
+ try {
+ FileUtils.cleanDirectory( potDirectory );
+ }
+ catch ( IOException e ) {
+ getLog().warn( "unable to cleanup POT directory [" + potDirectory + "]", e );
+ }
+ }
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/Format.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/Format.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/Format.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,36 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.maven.plugins.jdocbook;
+
+import org.jboss.jdocbook.render.format.UserFormatConfiguration;
+
+/**
+ * Maven non-sense. Simply pulls UserFormatConfiguration into the namespace in regards to plugin config.
+ *
+ * @author Steve Ebersole
+ */
+public class Format extends UserFormatConfiguration {
+}
Added: jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/GenerationMojo.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/GenerationMojo.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/GenerationMojo.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,122 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.maven.plugins.jdocbook;
+
+import java.io.File;
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.maven.artifact.Artifact;
+import org.jboss.jdocbook.profile.ProfilerFactory;
+import org.jboss.jdocbook.render.RenderingException;
+import org.jboss.jdocbook.render.format.FormatPlan;
+import org.jboss.jdocbook.render.impl.RendererFactory;
+import org.jboss.jdocbook.util.DocBookProfilingStrategy;
+import org.jboss.jdocbook.xslt.XSLTException;
+
+/**
+ * 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(FormatPlan[] plans) throws XSLTException, RenderingException {
+ if ( !sourceDirectory.exists() ) {
+ getLog().info( "sourceDirectory [" + sourceDirectory.getAbsolutePath() + "] did not exist" );
+ return;
+ }
+
+ if ( !workDirectory.exists() ) {
+ workDirectory.mkdirs();
+ }
+
+ 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() );
+ }
+ }
+ }
+ );
+ }
+
+ RendererFactory rendererFactory = new RendererFactory( options );
+ Locale requestedLocale = getRequestedLocale();
+ String requestedFormat = getRequestedFormat();
+
+ List<PublishingSource> sources = getPublishingSources();
+ for ( PublishingSource source : sources ) {
+ if ( requestedLocale != null && !requestedLocale.equals( source.getLocale() ) ) {
+ getLog().info( "skipping non-requested lang [" + stringify( source.getLocale() ) + "]" );
+ continue;
+ }
+
+ File sourceFile = source.resolveDocumentFile();
+ if ( !sourceFile.exists() ) {
+ getLog().info( "Source document [" + sourceFile.getAbsolutePath() + "] did not exist; skipping" );
+ continue;
+ }
+
+ File publishingDirectory = source.resolvePublishingDirectory();
+ if ( !publishingDirectory.exists() ) {
+ publishingDirectory.mkdirs();
+ }
+
+ final String lang = stringify( source.getLocale() );
+ options.getTransformerParameters().setProperty( "l10n.gentext.language", lang );
+ options.getTransformerParameters().setProperty( "profile.lang", lang );
+
+ boolean hasBeenProfiled = false;
+ for ( FormatPlan plan : plans ) {
+ if ( requestedFormat != null && !requestedFormat.equals( plan.getName() ) ) {
+ getLog().info( "skipping non-requested format [" + plan.getName() + "]" );
+ continue;
+ }
+ if ( plan.getProfiling() == DocBookProfilingStrategy.TWO_PASS && !hasBeenProfiled ) {
+ hasBeenProfiled = true;
+ File profileOutputDir = new File( new File( workDirectory, "profile" ), lang );
+ sourceFile = new ProfilerFactory( profileOutputDir, options ).buildProfiler().applyProfiling( sourceFile );
+ }
+ rendererFactory.buildRenderer( plan.getName() ).render( sourceFile, plan, publishingDirectory, stagingDirectory );
+ }
+ }
+ }
+
+}
Added: jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/Options.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/Options.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/Options.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,34 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.maven.plugins.jdocbook;
+
+/**
+ * Maven non-sense. Simply pulls Options into the namespace in regards to plugin config.
+ *
+ * @author Steve Ebersole
+ */
+public class Options extends org.jboss.jdocbook.Options {
+}
Added: jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/PackageMojo.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/PackageMojo.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/PackageMojo.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,83 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.maven.plugins.jdocbook;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.codehaus.plexus.archiver.ArchiverException;
+import org.codehaus.plexus.archiver.jar.JarArchiver;
+import org.jboss.jdocbook.render.RenderingException;
+import org.jboss.jdocbook.render.format.FormatPlan;
+import org.jboss.jdocbook.xslt.XSLTException;
+
+/**
+ * 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 {
+ /**
+ * {@inheritDoc}
+ */
+ protected void process(FormatPlan[] formatPlans) throws RenderingException, XSLTException {
+ File projectArtifactFile = new File( project.getBuild().getOutputDirectory(), project.getBuild().getFinalName() + ".war" );
+ JarArchiver archiver = new JarArchiver();
+ archiver.setDestFile( projectArtifactFile );
+
+// RendererFactory rendererFactory = new RendererFactory( options );
+ try {
+ for ( PublishingSource source : getPublishingSources() ) {
+ for ( FormatPlan formatPlan : formatPlans ) {
+ archiver.addDirectory(
+ new File( source.resolvePublishingDirectory(), formatPlan.getName() ),
+ formatPlan.getName() + "/"
+ );
+// if ( attach ) {
+// File bundle = rendererFactory.buildRenderer( formatPlan.getName() ).getAttachableBundle( )
+// }
+ }
+ }
+ archiver.createArchive();
+ }
+ catch ( IOException e ) {
+ throw new RenderingException( "Unable to create archive [" + projectArtifactFile.getAbsolutePath() + "]", e );
+ }
+ catch ( ArchiverException e ) {
+ throw new RenderingException( "Unable to populate archive [" + projectArtifactFile.getAbsolutePath() + "]", e );
+ }
+
+ project.getArtifact().setFile( projectArtifactFile );
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/ResourceMojo.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/ResourceMojo.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/ResourceMojo.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,116 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.maven.plugins.jdocbook;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+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.jboss.jdocbook.render.RenderingException;
+import org.jboss.jdocbook.render.format.FormatPlan;
+import org.jboss.jdocbook.xslt.XSLTException;
+import org.jboss.maven.shared.resource.ResourceDelegate;
+
+/**
+ * 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(FormatPlan[] formattings) throws RenderingException, XSLTException {
+ // allow project local style artifacts to override imported ones...
+ processDependencySupportArtifacts( collectDocBookStyleDependentArtifacts() );
+ processProjectResources();
+ }
+
+ // project local resources ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ private void processProjectResources() throws RenderingException {
+ if ( imageResource != null ) {
+ new ResourceDelegate( project, new File( stagingDirectory, "images" ), getLog() ).process( imageResource );
+ }
+ if ( cssResource != null ) {
+ new ResourceDelegate( project, new File( stagingDirectory, "css" ), getLog() ).process( cssResource );
+ }
+ }
+
+
+ // dependency support resources ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ private List<Artifact> collectDocBookStyleDependentArtifacts() {
+ final ArrayList<Artifact> rtn = new ArrayList<Artifact>();
+ processArtifacts(
+ new ArtifactProcessor() {
+ public void process(Artifact artifact) {
+ if ( "jdocbook-style".equals( artifact.getType() ) ) {
+ rtn.add( artifact );
+ }
+ }
+ }
+ );
+ return rtn;
+ }
+
+ private void processDependencySupportArtifacts(List<Artifact> artifacts) throws RenderingException {
+ for ( Artifact artifact : artifacts ) {
+ processDependencySupportArtifact( artifact.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: jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/TranslationMojo.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/TranslationMojo.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/TranslationMojo.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,57 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.maven.plugins.jdocbook;
+
+import java.util.Locale;
+
+import org.jboss.jdocbook.JDocBookProcessException;
+import org.jboss.jdocbook.i18n.Factory;
+
+/**
+ * Responsible for translating the DocBook source based on the translator's PO files.
+ *
+ * @goal translate
+ * @requiresDependencyResolution
+ *
+ * @author Steve Ebersole
+ */
+public class TranslationMojo extends AbstractDocBookMojo {
+ protected void doExecute() throws JDocBookProcessException {
+ Locale requestedLocale = getRequestedLocale();
+ MasterTranslationDescriptor masterTranslationDescriptor = getMasterTranslationDescriptor();
+ for ( I18nSource source : getI18nSources() ) {
+ if ( requestedLocale == null || requestedLocale.equals( source.getLocale() ) ) {
+ getLog().info( "Processing translation [" + stringify( source.getLocale() ) + "]" );
+ Factory.getTranslationBuilder().buildTranslation(
+ masterTranslationDescriptor.resolveDocumentFile(),
+ source.resolvePoDirectory(),
+ source.resolveTranslatedXmlDirectory(),
+ options
+ );
+ }
+ }
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/UpdatePoMojo.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/UpdatePoMojo.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/UpdatePoMojo.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,54 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.maven.plugins.jdocbook;
+
+import java.util.List;
+import java.util.Locale;
+
+import org.jboss.jdocbook.JDocBookProcessException;
+import org.jboss.jdocbook.i18n.Factory;
+
+/**
+ * UpdatePoMojo implementationslatable strings from the master translation source into the POT files.
+ *
+ * @goal update-po
+ * @requiresDependencyResolution
+ *
+ * @author Steve Ebersole
+ */
+public class UpdatePoMojo extends AbstractDocBookMojo {
+ protected void doExecute() throws JDocBookProcessException {
+ Locale translationLocale = getRequestedLocale();
+ List<I18nSource> sources = getI18nSources();
+ for ( I18nSource source : sources ) {
+ if ( translationLocale == null || translationLocale.equals( source.getLocale() ) ) {
+ getLog().info( "Updating PO file [" + stringify( source.getLocale() ) + "]" );
+ Factory.getPoSynchronizer()
+ .synchronizePo( potDirectory, source.resolvePoDirectory(), source.getLocale(), options );
+ }
+ }
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/UpdatePotMojo.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/UpdatePotMojo.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/maven/plugins/jdocbook/UpdatePotMojo.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,45 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.maven.plugins.jdocbook;
+
+import org.jboss.jdocbook.JDocBookProcessException;
+import org.jboss.jdocbook.i18n.Factory;
+
+
+/**
+ * Manages pushing translatable strings from the master translation source into the POT files.
+ *
+ * @goal update-pot
+ * @requiresDependencyResolution
+ *
+ * @author Steve Ebersole
+ */
+public class UpdatePotMojo extends AbstractDocBookMojo {
+ protected void doExecute() throws JDocBookProcessException {
+ MasterTranslationDescriptor master = getMasterTranslationDescriptor();
+ Factory.getPotSynchronizer().synchronizePot( master.resolveDocumentFile(), potDirectory, options );
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/maven/shared/process/ExecutionException.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/maven/shared/process/ExecutionException.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/maven/shared/process/ExecutionException.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,43 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.maven.shared.process;
+
+/**
+ * Used to indicate problems performing an execution (sys call).
+ *
+ * @author Steve Ebersole
+ */
+public class ExecutionException extends RuntimeException {
+ private static final long serialVersionUID = -8773360957835742679L;
+
+ public ExecutionException(String message) {
+ super( message );
+ }
+
+ public ExecutionException(String message, Throwable cause) {
+ super( message, cause );
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/maven/shared/process/Executor.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/maven/shared/process/Executor.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/maven/shared/process/Executor.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,91 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.maven.shared.process;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Responsible for performing system call executions and coordinating error checking, process I/O, etc.
+ *
+ * @author Steve Ebersole
+ */
+public class Executor {
+ /**
+ * Shorthand for {@link #execute(String, java.io.OutputStream, java.io.OutputStream)} using
+ * {@link System#out} and {@link System#err} for the process's stdout and errout, respectively.
+ *
+ * @param cmd The command to execute.
+ */
+ public static void execute(String cmd) {
+ execute( cmd, System.out, System.err );
+ }
+
+ /**
+ * Shorthand for {@link #execute(String, java.io.OutputStream, java.io.OutputStream)} using
+ * {@link System#err} for the process's errout and the given <tt>out</tt> for its stdout.
+ *
+ * @param cmd The command to execute.
+ * @param out The stream to which to pipe the process's stdout.
+ */
+ public static void execute(String cmd, OutputStream out) {
+ execute( cmd, out, System.err );
+ }
+
+ /**
+ * Perform the given cmd as a System call, piping the {@link Process#getOutputStream() input} of the resulting
+ * process to our {@link System#in}, its {@link Process#getOutputStream() stdout} to the given <tt>out</tt> stream
+ * and its {@link Process#getOutputStream() errout} to the given <tt>err</tt> stream.
+ *
+ * @param cmd The command to execute.
+ * @param out The stream to which to pipe the process's stdout.
+ * @param err The stream to which to pipe the process's errout.
+ */
+ public static void execute(String cmd, OutputStream out, OutputStream err) {
+ ProcessOutputManager outputManager = null;
+ try {
+ Process cmdProcess = Runtime.getRuntime().exec( cmd );
+ outputManager = new ProcessOutputManager( cmdProcess, out, err );
+ try {
+ cmdProcess.waitFor();
+ }
+ catch ( InterruptedException e ) {
+ throw new ExecutionException( "unable to obtain appropriate runtime environment", e );
+ }
+ if ( cmdProcess.exitValue() != 0 ) {
+ // assume problem...
+ throw new ExecutionException( "there was a problem executing command; check output" );
+ }
+ }
+ catch ( IOException e ) {
+ throw new ExecutionException( "unable to obtain appropriate runtime environment", e );
+ }
+ finally {
+ if ( outputManager != null ) {
+ outputManager.stop();
+ }
+ }
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/maven/shared/process/ProcessOutputManager.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/maven/shared/process/ProcessOutputManager.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/maven/shared/process/ProcessOutputManager.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,70 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.jboss.maven.shared.process;
+
+import java.io.OutputStream;
+
+/**
+ * ProcessOutputManager implementation
+ *
+ * @author Steve Ebersole
+ */
+public class ProcessOutputManager {
+ private final StreamBridge outputBridge;
+ private final StreamBridge errorBridge;
+
+ private final Thread outputStreamThread;
+ private final Thread errorStreamThread;
+
+ public ProcessOutputManager(Process process, OutputStream out, OutputStream err) {
+ outputBridge = new StreamBridge( process.getInputStream(), out );
+ errorBridge = new StreamBridge( process.getErrorStream(), err );
+
+ outputStreamThread = new Thread( outputBridge );
+ outputStreamThread.setDaemon( true );
+ outputStreamThread.start();
+
+ errorStreamThread = new Thread( errorBridge );
+ errorStreamThread.setDaemon( true );
+ errorStreamThread.start();
+ }
+
+ public void stop() {
+ try {
+ outputStreamThread.join();
+ }
+ catch ( InterruptedException e ) {
+ // ignore
+ }
+ try {
+ errorStreamThread.join();
+ }
+ catch ( InterruptedException e ) {
+ // ignore
+ }
+ outputBridge.stop();
+ errorBridge.stop();
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/maven/shared/process/StreamBridge.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/maven/shared/process/StreamBridge.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/maven/shared/process/StreamBridge.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,88 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.maven.shared.process;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * Bridges an input stream to an output stream.
+ * <p/>
+ * This is used in system call handling because the output of the created process is actually represented as an input
+ * stream to our java process. Generally we need to 'pipe' this to an output stream (the console for example).
+ *
+ * @author Steve Ebersole
+ */
+public class StreamBridge implements Runnable {
+ private static final int DEF_BUFFER_SIZE = 512;
+
+ private final InputStream inputStream;
+ private final OutputStream outputStream;
+ private final int bufferSize;
+
+ private boolean stopped = false;
+
+ public StreamBridge(InputStream inputStream, OutputStream outputStream) {
+ this( inputStream, outputStream, DEF_BUFFER_SIZE );
+ }
+
+ public StreamBridge(InputStream inputStream, OutputStream outputStream, int bufferSize) {
+ this.inputStream = inputStream;
+ this.outputStream = outputStream;
+ this.bufferSize = bufferSize;
+ }
+
+ public void run() {
+ final byte[] buf = new byte[bufferSize];
+ int length;
+ try {
+ while ( true ) {
+ length = inputStream.read( buf );
+ if ( ( length <= 0 ) || stopped ) {
+ break;
+ }
+ outputStream.write( buf, 0, length );
+ outputStream.flush();
+ }
+ outputStream.flush();
+ }
+ catch ( IOException ignore ) {
+ // ???
+ }
+ finally {
+ synchronized (this) {
+ notifyAll();
+ }
+ }
+ }
+
+ synchronized void stop() {
+ stopped = true;
+ notifyAll();
+ }
+
+}
Added: jbpm4/docbook/src/main/java/org/jboss/maven/shared/properties/CompositeMavenProjectProperties.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/maven/shared/properties/CompositeMavenProjectProperties.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/maven/shared/properties/CompositeMavenProjectProperties.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,80 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.maven.shared.properties;
+
+import java.util.AbstractMap;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.io.File;
+
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
+
+/**
+ * Presents an consolidated, aggregated view of project properties.
+ * <p/>
+ * Aggregation occurs across {@link System#getProperties()},
+ * {@link org.apache.maven.project.MavenProject#getProperties()} and
+ * via bean-propetties-style reflection on {@link org.apache.maven.project.MavenProject}.
+ *
+ * @author Steve Ebersole
+ */
+public class CompositeMavenProjectProperties extends AbstractMap {
+ private final MavenProject project;
+ private final Map values;
+
+ @SuppressWarnings("unchecked")
+ public CompositeMavenProjectProperties(MavenProject project) {
+ this.project = project;
+ values = new HashMap( System.getProperties() );
+ values.putAll( project.getProperties() );
+ for ( Object o : project.getBuild().getFilters() ) {
+ String filtersfile = ( String ) o;
+ values.putAll( PropertiesHelper.loadPropertyFile( new File( filtersfile ) ) );
+ }
+ }
+
+ public synchronized Object get(Object key) {
+ // try the local value map first...
+ Object value = values.get( key );
+
+ // then try reflection on the project bean properties...
+ if ( value == null ) {
+ try {
+ value = ReflectionValueExtractor.evaluate( String.valueOf( key ), project );
+ }
+ catch( Throwable ignore ) {
+ // intentionally empty...
+ }
+ }
+ return value;
+ }
+
+ public Set entrySet() {
+ throw new UnsupportedOperationException( "iterating MavenProject properties is not supported" );
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/maven/shared/properties/PropertiesException.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/maven/shared/properties/PropertiesException.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/maven/shared/properties/PropertiesException.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,43 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.maven.shared.properties;
+
+/**
+ * Some problem processing {@link java.util.Properties}.
+ *
+ * @author Steve Ebersole
+ */
+public class PropertiesException extends RuntimeException {
+ private static final long serialVersionUID = 5200535349269107151L;
+
+ public PropertiesException(String message) {
+ super( message );
+ }
+
+ public PropertiesException(String message, Throwable cause) {
+ super( message, cause );
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/maven/shared/properties/PropertiesHelper.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/maven/shared/properties/PropertiesHelper.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/maven/shared/properties/PropertiesHelper.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,149 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.maven.shared.properties;
+
+import java.util.Properties;
+import java.util.Enumeration;
+import java.io.File;
+import java.io.IOException;
+import java.io.FileInputStream;
+
+import org.codehaus.plexus.util.IOUtil;
+
+/**
+ * Utilities for dealing with @{link Properties} objects.
+ * <p/>
+ * Taken from maven-war-plugin, which apparently took it from
+ * maven-resources-plugin... ;)
+ *
+ * @author Steve Ebersole
+ */
+public class PropertiesHelper {
+
+ /**
+ * Disallow external instantiation of PropertiesHelper.
+ */
+ private PropertiesHelper() {
+ }
+
+ /**
+ * Reads a property file, resolving all internal variables.
+ *
+ * @param propfile The property file to load
+ *
+ * @return the loaded and fully resolved Properties object
+ */
+ public static Properties loadPropertyFile(File propfile) {
+ if ( !propfile.exists() ) {
+ throw new PropertiesException( "unable to locate spercified prop file [" + propfile.toString() + "]" );
+ }
+
+ Properties props = new Properties();
+ if ( propfile.exists() ) {
+ try {
+ FileInputStream inStream = new FileInputStream( propfile );
+ try {
+ props.load( inStream );
+ }
+ finally {
+ IOUtil.close( inStream );
+ }
+ }
+ catch( IOException ioe ) {
+ throw new PropertiesException( "unable to load properties file [" + propfile + "]" );
+ }
+ }
+
+ for ( Enumeration n = props.propertyNames(); n.hasMoreElements(); ) {
+ String k = ( String ) n.nextElement();
+ props.setProperty( k, PropertiesHelper.getInterpolatedPropertyValue( k, props ) );
+ }
+
+ return props;
+ }
+
+
+ /**
+ * Retrieves a property value, replacing values like ${token}
+ * using the Properties to look them up.
+ * <p/>
+ * It will leave unresolved properties alone, trying for System
+ * properties, and implements reparsing (in the case that
+ * the value of a property contains a key), and will
+ * not loop endlessly on a pair like
+ * test = ${test}.
+ *
+ * @param key The key for which to find the corresponding value
+ * @param props The properties from which to find the value.
+ * @return The (possible interpolated) property value
+ */
+ public static String getInterpolatedPropertyValue(String key, Properties props) {
+ // This can also be done using InterpolationFilterReader,
+ // but it requires reparsing the file over and over until
+ // it doesn't change.
+
+ String v = props.getProperty( key );
+ String ret = "";
+ int idx, idx2;
+
+ while ( ( idx = v.indexOf( "${" ) ) >= 0 ) {
+ // append prefix to result
+ ret += v.substring( 0, idx );
+
+ // strip prefix from original
+ v = v.substring( idx + 2 );
+
+ // if no matching } then bail
+ if ( ( idx2 = v.indexOf( '}' ) ) < 0 ) {
+ break;
+ }
+
+ // strip out the key and resolve it
+ // resolve the key/value for the ${statement}
+ String nk = v.substring( 0, idx2 );
+ v = v.substring( idx2 + 1 );
+ String nv = props.getProperty( nk );
+
+ // try global environment..
+ if ( nv == null ) {
+ nv = System.getProperty( nk );
+ }
+
+ // if the key cannot be resolved,
+ // leave it alone ( and don't parse again )
+ // else prefix the original string with the
+ // resolved property ( so it can be parsed further )
+ // taking recursion into account.
+ if ( nv == null || nv.equals( key ) ) {
+ ret += "${" + nk + "}";
+ }
+ else {
+ v = nv + v;
+ }
+ }
+ return ret + v;
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/maven/shared/resource/ResourceDelegate.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/maven/shared/resource/ResourceDelegate.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/maven/shared/resource/ResourceDelegate.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,271 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.maven.shared.resource;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.jboss.maven.shared.properties.CompositeMavenProjectProperties;
+import org.codehaus.plexus.util.DirectoryScanner;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.InterpolationFilterReader;
+
+/**
+ * A delegate for handling {@link Resource} resolution.
+ *
+ * @author Steve Ebersole
+ */
+public class ResourceDelegate {
+ public static final String[] DEFAULT_DEFAULT_INCLUDES = new String[] { "**/**" };
+
+ private final File basedir;
+ private final File baseTargetDirectory;
+ private final String[] defaultIncludes;
+ private final String[] defaultExcludes;
+ private final Log log;
+
+ private final Map filterProperties;
+
+ /**
+ * Constructs a Delegate instance for handling Resource resolution.
+ *
+ * @param project The project currently being built.
+ * @param baseTargetDirectory The base target directory to which we should copy resources.
+ * @param log The log instance to use for logging.
+ */
+ public ResourceDelegate(MavenProject project, File baseTargetDirectory, Log log) {
+ this( project, baseTargetDirectory, DEFAULT_DEFAULT_INCLUDES, null, log );
+ }
+
+ /**
+ * Constructs a Delegate instance for handling Resource resolution.
+ *
+ * @param project The project currently being built.
+ * @param baseTargetDirectory The base target directory to which we should copy resources.
+ * @param defaultIncludes default patterns for resource copying inclusion.
+ * @param defaultExcludes default patterns for resource copying exclusion.
+ * @param log The log instance to use for logging.
+ */
+ public ResourceDelegate(
+ MavenProject project,
+ File baseTargetDirectory,
+ String[] defaultIncludes,
+ String[] defaultExcludes,
+ Log log) {
+ this.basedir = project.getBasedir();
+ this.baseTargetDirectory = baseTargetDirectory;
+ this.defaultIncludes = defaultIncludes;
+ this.defaultExcludes = defaultExcludes;
+ this.log = log;
+ this.filterProperties = new CompositeMavenProjectProperties( project );
+ }
+
+ public void process(Resource[] resources) throws ResourceException {
+ for ( Resource resource : resources ) {
+ process( resource );
+ }
+ }
+
+ public void process(Resource resource) throws ResourceException {
+ getLog().debug( "starting resource processing for : " + resource.getDirectory() );
+ String[] fileNames = collectFileNames( resource );
+ if ( fileNames == null ) {
+ getLog().debug( "no matching files found" );
+ return;
+ }
+
+ File destination = resource.getTargetPath() == null
+ ? baseTargetDirectory
+ : new File( baseTargetDirectory, resource.getTargetPath() );
+ if ( !destination.exists() ) {
+ destination.mkdirs();
+ }
+
+ for ( String fileName : fileNames ) {
+ if ( resource.isFiltering() ) {
+ copyFilteredFile(
+ new File( resource.getDirectory(), fileName ),
+ new File( destination, fileName ),
+ null,
+ getFilterWrappers(),
+ filterProperties
+ );
+ }
+ else {
+ copyFileIfModified(
+ new File( resource.getDirectory(), fileName ),
+ new File( destination, fileName )
+ );
+ }
+ }
+ }
+
+ /**
+ * Given a resource, determine the matching file names which should be
+ * processed.
+ *
+ * @param resource The resource model.
+ * @return The collected matching file names.
+ */
+ private String[] collectFileNames(Resource resource) {
+ File resourceDirectory = new File( resource.getDirectory() );
+ if ( !resourceDirectory.exists() && !resource.getDirectory().startsWith( "/" ) ) {
+ resourceDirectory = new File( basedir, resource.getDirectory() );
+ if ( !resourceDirectory.exists() ) {
+ resourceDirectory = null;
+ }
+ }
+ if ( resourceDirectory == null ) {
+ throw new ResourceException( "could not locate specified resource directory" );
+ }
+
+ DirectoryScanner scanner = new DirectoryScanner();
+ scanner.setBasedir( resource.getDirectory() );
+ scanner.setIncludes( determineIncludes( resource ) );
+ scanner.setExcludes( determineExcludes( resource ) );
+ scanner.addDefaultExcludes();
+ scanner.scan();
+ return scanner.getIncludedFiles();
+ }
+
+ @SuppressWarnings("unchecked")
+ private String[] determineIncludes(Resource resource) {
+ return toStringArray( resource.getIncludes(), defaultIncludes );
+ }
+
+ @SuppressWarnings("unchecked")
+ private String[] determineExcludes(Resource resource) {
+ return toStringArray( resource.getExcludes(), defaultExcludes );
+ }
+
+
+ private interface FilterWrapper {
+ Reader getReader(Reader fileReader, Map filterProperties);
+ }
+
+ private FilterWrapper[] getFilterWrappers() {
+ return new FilterWrapper[] {
+ // support ${token}
+ new FilterWrapper() {
+ public Reader getReader(Reader fileReader, Map filterProperties) {
+ return new InterpolationFilterReader(
+ fileReader, filterProperties, "${", "}"
+ );
+ }
+ },
+ // support @token@
+ new FilterWrapper() {
+ public Reader getReader(Reader fileReader, Map filterProperties) {
+ return new InterpolationFilterReader(
+ fileReader, filterProperties, "@", "@"
+ );
+ }
+ }
+ };
+ }
+
+ private static void copyFilteredFile(
+ File from,
+ File to,
+ String encoding,
+ FilterWrapper[] wrappers,
+ Map filterProperties) throws ResourceException {
+ // buffer so it isn't reading a byte at a time!
+ Reader fileReader = null;
+ Writer fileWriter = null;
+ try {
+ // fix for MWAR-36, ensures that the parent dir are created first
+ to.getParentFile().mkdirs();
+
+ if ( encoding == null || encoding.length() < 1 ) {
+ fileReader = new BufferedReader( new FileReader( from ) );
+ fileWriter = new FileWriter( to );
+ }
+ else {
+ FileInputStream instream = new FileInputStream( from );
+ FileOutputStream outstream = new FileOutputStream( to );
+ fileReader = new BufferedReader(
+ new InputStreamReader( instream, encoding )
+ );
+ fileWriter = new OutputStreamWriter( outstream, encoding );
+ }
+
+ Reader reader = fileReader;
+ for ( FilterWrapper wrapper : wrappers ) {
+ reader = wrapper.getReader( reader, filterProperties );
+ }
+
+ IOUtil.copy( reader, fileWriter );
+ }
+ catch( IOException e ) {
+ throw new ResourceException( e.getMessage(), e );
+ }
+ finally {
+ IOUtil.close( fileReader );
+ IOUtil.close( fileWriter );
+ }
+ }
+
+ private static void copyFileIfModified(File source, File destination) throws ResourceException {
+ if ( destination.lastModified() < source.lastModified() ) {
+ try {
+ FileUtils.copyFile( source.getCanonicalFile(), destination );
+ destination.setLastModified( source.lastModified() );
+ }
+ catch ( IOException e ) {
+ throw new ResourceException( e.getMessage(), e );
+ }
+ }
+ }
+
+ private Log getLog() {
+ return log;
+ }
+
+ private static String[] toStringArray(List<String> list, String[] defaultArray) {
+ if ( list == null || list.isEmpty() ) {
+ return defaultArray;
+ }
+ else {
+ return list.toArray( new String[ list.size() ] );
+ }
+ }
+}
Added: jbpm4/docbook/src/main/java/org/jboss/maven/shared/resource/ResourceException.java
===================================================================
--- jbpm4/docbook/src/main/java/org/jboss/maven/shared/resource/ResourceException.java (rev 0)
+++ jbpm4/docbook/src/main/java/org/jboss/maven/shared/resource/ResourceException.java 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,43 @@
+/*
+ * jDocBook, processing of DocBook sources as a Maven plugin
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+
+package org.jboss.maven.shared.resource;
+
+/**
+ * Some problem processing resource definitions.
+ *
+ * @author Steve Ebersole
+ */
+public class ResourceException extends RuntimeException {
+ private static final long serialVersionUID = -5047838607221369662L;
+
+ public ResourceException(String message) {
+ super( message );
+ }
+
+ public ResourceException(String message, Throwable cause) {
+ super( message, cause );
+ }
+}
Added: jbpm4/docbook/src/main/resources/META-INF/plexus/components.xml
===================================================================
--- jbpm4/docbook/src/main/resources/META-INF/plexus/components.xml (rev 0)
+++ jbpm4/docbook/src/main/resources/META-INF/plexus/components.xml 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,49 @@
+<!--
+ ~ jDocBook, processing of DocBook sources as a Maven plugin
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ 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, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY 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
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ ~
+ -->
+
+<component-set>
+
+ <components>
+
+ <!-- Defines the lifecycle associated with the 'jdocbook' 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>
+
+ </components>
+
+</component-set>
\ No newline at end of file
Added: jbpm4/docbook/src/site/apt/examples/arbitrary-styles.apt
===================================================================
--- jbpm4/docbook/src/site/apt/examples/arbitrary-styles.apt (rev 0)
+++ jbpm4/docbook/src/site/apt/examples/arbitrary-styles.apt 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,30 @@
+ ------
+ Arbitrary Styles
+ ------
+ 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
+
+Applying Arbitrary Styles
+
+ Because of the plugin's use of {{{../staging.html}staging}} to
+ handle style resources, users can actually use resources from any
+ source as style elements. For example, here we use the <dependency>
+ plugin to unpack a zip file into the staging directory directly:
+
+ <todo : the example...>
\ No newline at end of file
Added: jbpm4/docbook/src/site/apt/examples/custom-xslt.apt
===================================================================
--- jbpm4/docbook/src/site/apt/examples/custom-xslt.apt (rev 0)
+++ jbpm4/docbook/src/site/apt/examples/custom-xslt.apt 2008-09-15 08:25:22 UTC (rev 2239)
@@ -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 should 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>
++----+
+
+
+* jdocbook-style classpath: URL
+
+ See {{{../style.html}here}} for background discussion.
+
+ As a specific example of using an XSLT defined in a <jdocbook-style> package,
+ consider the following jdocbook-style package distributed by the venerable
+ Acme Corporation:
+
++----+
+acmeskin.docbook-support/
+ xslt/
+ com/
+ acme/
+ fo.xsl
++----+
+
+ 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>jdocbook-style</type>
+ </dependency>
+ </dependencies>
+ <configuration>
+ <formats>
+ <format>
+ <formatName>pdf</formatName>
+ <stylesheetResource>classpath:/xslt/com/acme/fo.xsl</stylesheetResource>
+ </format>
+ </formats>
+ </configuration>
+</plugin>
++----+
\ No newline at end of file
Added: jbpm4/docbook/src/site/apt/examples/docbook-version.apt
===================================================================
--- jbpm4/docbook/src/site/apt/examples/docbook-version.apt (rev 0)
+++ jbpm4/docbook/src/site/apt/examples/docbook-version.apt 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,48 @@
+ ------
+ Specific DocBook Version
+ ------
+ 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
+
+Specific DocBook Version
+
+ The version of DocBook to use is itself defined as dependency. By default,
+ the version defined by the <jDocBook Plugin> is used, so that would depend
+ on the version of the <jDocBook Plugin> used.
+
+ It is however, possible to override that and say to use another version of
+ DocBook instead, simply by defining the new version as a dependency.
+
++----+
+<plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifacId>maven-jdocbook-plugin</artifactId>
+ <extensions>true</extensions>
+ <dependencies>
+ <dependency>
+ <!-- This is the groupId/artifactId used for the repackaging of DocBook -->
+ <!-- This needs to match, or you will have two versions of DocBook accessible -->
+ <groupId>net.sf.docbook</groupId>
+ <artifactId>docbook</artifactId>
+ <!-- Whichever version you wanted to use instead -->
+ <version>latest.and.greatest</version>
+ </dependency>
+ </dependencies>
+</plugin>
++----+
Added: jbpm4/docbook/src/site/apt/examples/jdocbook-style.apt
===================================================================
--- jbpm4/docbook/src/site/apt/examples/jdocbook-style.apt (rev 0)
+++ jbpm4/docbook/src/site/apt/examples/jdocbook-style.apt 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,129 @@
+ ------
+ Complete jdocbook-style Example
+ ------
+ 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
+
+Complete jdocbook-style Example
+
+ The intention in splitting the <jdocbook> plugin and <jdocbook-style> plugin
+ is the notion of separation-of-concerns; namely, let documentation content
+ developers focus on developing content, while documentation style developers
+ develop the "look and feel" of the produced output(s). This split represents
+ the "sweet spot" for this plugin, and is the main intended use-case. So let's
+ take a look at this approach from beginning to end.
+
+ Since an example, is worth (probably more than) a thousand words for most
+ of us, lets take a look at an example of the approach of combining these
+ two plugins. As I mentioned before, the venerable Acme Corporation produces a
+ <jdocbook-style> bundle for all their product manuals. As the person in charge
+ of Acme's latest product, WhizBang, you'll need to utilize that style bundle in producing
+ your manual.
+
+* The jdocbook-style bundle
+
+ Acme Corporation only produces manuals in PDF format. And they have a minimum
+ of custom images. Here is the source layout of the acme-manual-style
+ project:
+
++----+
+acme-manual-style/
+ images/
+ acme-corp-logo.svg
+ xslt/
+ acme-manual.xsl
+ pom.xml
++----+
+
+ <Generally, as a developer of a jdocbook project you would not need to
+ know such details about the source structure of the corresponding
+ jdocbook-style project. The above is included just in the interest
+ of completeness.>
+
+ That project source produces an artifact named acme-manual-style.jdocbook-style (the
+ artifact is really a jar file, but unfortunately Maven forces the artifact
+ to have an extension matching the name of the packaging, which here is
+ jdocbook-style). The contents of that archive are as follows:
+
++----+
+ images/
+ acme-corp-logo.svg
+ xslt/
+ acme-manual.xsl
+ META-INF/
+ ....
++----+
+
+ See the documentation of the maven-jdocbook-style-plugin project for more
+ details. The above was a very brief overview.
+
+* The WhizBang manual project
+
+ First, we create the project directory structure:
+
++----+
+whizbang-manual/
+ src/
+ main/
+ docbook/
+ whizbang.xml
+ whizbang-front.gif
+ whizbang-back.gif
+ pom.xml
++----+
+
+ Let's take a look at the pom.xml for the WhizBang manual...
+
++----+
+<project>
+ ...
+ <groupId>com.acme</groupId>
+ <artifactId>whizbang-manual<artifactId>
+ <type>jdocbook</type>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifacId>maven-jdocbook-plugin</artifactId>
+ <extensions>true</extensions>
+ <dependencies>
+ <!--- This is the jdocbook-style discussed above -->
+ <dependency>
+ <groupId>com.acme</groupId>
+ <artifactId>acme-manual-style</artifactId>
+ <type>jdocbook-style</type>
+ </dependency>
+ </dependencies>
+ <configuration>
+ <formats>
+ <format>
+ <formatName>pdf</formatName>
+ <stylesheetResource>classpath:/xslt/acme-manual.xsl</stylesheetResource>
+ </format>
+ </formats>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
++----+
+
+ Those of you who have developed with DocBook before may not believe this,
+ but that's all there is to it. The plugin and Maven's dependency mechanism
+ take care of the rest.
\ No newline at end of file
Added: jbpm4/docbook/src/site/apt/examples/project-local-style.apt
===================================================================
--- jbpm4/docbook/src/site/apt/examples/project-local-style.apt (rev 0)
+++ jbpm4/docbook/src/site/apt/examples/project-local-style.apt 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,51 @@
+ ------
+ Project Local Style
+ ------
+ 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
+
+Project Local Style
+
+ As discussed {{{../style.html}here}}, a jdocbook project may provide custom
+ style elements. Currently this is limited to images and css. These are
+ controlled by the <<imageResource>> and <<cssResource>> parameters. For example,
+ a common approach to developing DocBook-based documentation is to keep the
+ source and images in the same relative directory:
+
++----+
+<plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifacId>maven-jdocbook-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <sourceDirectory>src/main/docs</sourceDirectory>
+ <sourceDocumentName>my-doc.xml</sourceDocumentName>
+ <imageResource>
+ <directory>src/main/docs</directory>
+ <includes>
+ <include>**/*.png</include>
+ <include>**/*.svg</include>
+ <include>**/*.gif</include>
+ </includes>
+ </imageResource>
+ ...
+ </configuration>
+</plugin>
++----+
+
Added: jbpm4/docbook/src/site/apt/formats.apt
===================================================================
--- jbpm4/docbook/src/site/apt/formats.apt (rev 0)
+++ jbpm4/docbook/src/site/apt/formats.apt 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,144 @@
+ ------
+ Format
+ ------
+ Steve Ebersole
+ ------
+ 7 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
+
+Format
+
+ 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>
++----+
+
+ Sometimes (especially with chunked html formatting) it is desired to have the main chunk
+ produce a file named 'index.html' instead of '<artifactId>.html':
+
++----+
+<plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifacId>maven-jdocbook-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <sourceDocumentName>source.xml</sourceDocumentName>
+ <formats>
+ <format>
+ <formatName>html</formatName>
+ <finalName>index.html</finalN ame>
+ </format>
+ </formats>
+ </configuration>
+</plugin>
++----+
Added: jbpm4/docbook/src/site/apt/i18n.apt
===================================================================
--- jbpm4/docbook/src/site/apt/i18n.apt (rev 0)
+++ jbpm4/docbook/src/site/apt/i18n.apt 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,39 @@
+ ------
+ Internationalization
+ ------
+ Steve Ebersole
+ ------
+ 30 October 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
+
+Internationalization
+
+ In support of internationalization (i18n) and locationization (l10n) efforts, the <jDocBook Plugin> allows you
+ to develop and manage language-specific versions of your documentation. Currently this support is achieved via
+ the GNU {{{http://www.gnu.org/software/gettext/}gettext}} package, which aims to help developers and translators by
+ providing a series of tools to make localizing content easier. In this iteration, the <jDocBook Plugin> relies on
+ the host system having the following executables available on their system/path and makes use of system
+ RuntimeEnvironment calls to execute them:
+
+ [[1]] msginit and msgmerge - these come from the <gettext> package itself (see link above)
+
+ [[2]] xml2pot and po2xml - which come from the KDE poxml package (
+
+ []
+
+ It is expected that there will be a java port of these tools at some point, and that the <jDocBook Plugin> would
+ then be updated to use those ports. However, such an effort is large and not expected anytime soon.
\ No newline at end of file
Added: jbpm4/docbook/src/site/apt/index.apt
===================================================================
--- jbpm4/docbook/src/site/apt/index.apt (rev 0)
+++ jbpm4/docbook/src/site/apt/index.apt 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,106 @@
+ ------
+ 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 aim 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 were 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).
+
+ XLST, fonts, images and css collectively define a "style". See the
+ maven-jdocbook-style-plugin for more information about the ability to
+ develop styles separately from the source documents. In fact a hope with
+ creating the jdocbook-style plugin in the first place is creation of
+ shareable styles reusable across many projects. {{{style.html}Here}}
+ is a discussion of using jdocbook-style bundles within jdobcook projects.
+
+ 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/jdocbook-style.html}Complete jdocbook-style example}}
+
+ * {{{examples/project-local-style.html}Using custom project-local images/css}}
+
+ * {{{examples/arbitrary-styles.html}Using arbitrary style images/css}}
+
+ * {{{examples/custom-xslt.html}Using custom XSLT}}
+
+ * {{{examples/docbook-version.html}Specifying DocBook version}}
\ No newline at end of file
Added: jbpm4/docbook/src/site/apt/staging.apt
===================================================================
--- jbpm4/docbook/src/site/apt/staging.apt (rev 0)
+++ jbpm4/docbook/src/site/apt/staging.apt 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,49 @@
+ ------
+ Staging
+ ------
+ Steve Ebersole
+ ------
+ 7 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
+
+Staging
+
+ The <jDocBook Plugin> uses staging for handling of images, css and fonts in
+ a consistent manner. All of these resources might 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
+ is the <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:
+
+ 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>
++----+
+
+ <todo : flesh this out, possibly with some examples of 'alternative staging'>
\ No newline at end of file
Added: jbpm4/docbook/src/site/apt/style.apt
===================================================================
--- jbpm4/docbook/src/site/apt/style.apt (rev 0)
+++ jbpm4/docbook/src/site/apt/style.apt 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,83 @@
+ ------
+ Styles
+ ------
+ 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
+
+Styles
+
+ Styles are composed of XSLT, images, css and fonts. These style components
+ may be pulled together from a number of different locations. Mainly, it is
+ intended that there are 2 main types of style components:
+
+ [jdocbook-style] - These are style components that are developed as part of
+ a separate project and packaged into a <jdocbook-style> artifact. The
+ intention is for these style bundles to be deployed into a Maven repo
+ and referenced just as a other project dependencies (with
+ type=jdocbook-style).
+
+ [project local] - These are style elements defined as part of the local
+ jdocbook project. Typically, these would indicated either:
+
+ [[1]] overrides of some shared (ala, jdocbook-style) style element
+
+ [[2]] style elements specific to the local project (e.g. images
+ referred to from the project DocBook sources.
+
+ []
+
+ project local elements are generally limited to images and css.
+
+ []
+
+* jdocbook-style integration
+
+ <jdocbook-style> is another maven packaging type, defined by the
+ org.jboss.maven.plugins:maven-jdocbook-style-plugin plugin. The goal
+ of the <jdocbook-style> is to define a common, resuable packaging bundle
+ for DocBook style elements such as XSLT, images, fonts and css.
+ The <jDocBook Plugin> can take advantage of a <jdocbook-style> 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 <jdocbook-style> dependency
+ as a custom stylesheet (see the {{{usage.html}usage}} 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 <jdocbook-style>.
+
+ []
+
+ See the {{{examples/jdocbook-style.html}example}} illustrating complete jdocbook-style
+ usage.
+
+* Project local elements
+
+ <todo : this section need writing... ;)>
+
+ See {{{staging.html}staging}}.
Added: jbpm4/docbook/src/site/apt/usage.apt
===================================================================
--- jbpm4/docbook/src/site/apt/usage.apt (rev 0)
+++ jbpm4/docbook/src/site/apt/usage.apt 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,67 @@
+ ------
+ 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
+
+ To understand usage of the <jDocBook Plugin>, there are really a few concepts
+ you must understand.
+
+ [[1]] {{{formats.apt}Formats}} define the type of output(s) you wish to produce.
+
+ [[2]] {{{style.apt}Styles}} define how those format outputs should look.
+
+ []
+
+ If you want to use local style elements, it is also a good idea to understand
+ {{{staging.html}staging}} as well.
+
+* Minimal configuration
+
+ The most basic configuration of the <jDocBook Plugin> is to simply tell it:
+
+ [[1]] The DocBook soure file to be transformed
+
+ [[2]] The formats into which the source should be transformed.
+
+ []
+
+ Here is a minimal configuration defining PDF and HTML output formats, for a
+ source file named source.xml:
+
++----+
+<plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jdocbook-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <sourceDocumentName>source.xml</sourceDocumentName>
+ <formats>
+ <format>
+ <formatName>pdf</formatName>
+ </format>
+ <format>
+ <formatName>html</formatName>
+ </format>
+ </formats>
+ </configuration>
+</plugin>
++----+
\ No newline at end of file
Added: jbpm4/docbook/src/site/site.xml
===================================================================
--- jbpm4/docbook/src/site/site.xml (rev 0)
+++ jbpm4/docbook/src/site/site.xml 2008-09-15 08:25:22 UTC (rev 2239)
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ jDocBook, processing of DocBook sources as a Maven plugin
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ 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, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY 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
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ ~
+ -->
+
+<project name="jDocBook Plugin">
+
+ <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="Style" href="style.html"/>
+ <item name="Internationalization" href="i18n.html"/>
+ </menu>
+
+ <menu name="Examples">
+ <item name="Complete jdocbook-style Example" href="examples/jdocbook-style.html"/>
+ <item name="Project-local Style" href="examples/project-local-style.html"/>
+ <item name="Arbitrary Style" href="examples/arbitrary-styles.html"/>
+ <item name="Custom XSLT" href="examples/custom-xslt.html"/>
+ <item name="Using a Specific DocBook Version" href="examples/docbook-version.html"/>
+ </menu>
+
+ ${reports}
+ </body>
+
+</project>
More information about the jbpm-commits
mailing list