[hibernate-commits] Hibernate SVN: r12662 - in
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main:
java/org/codehaus/mojo/docbook and 12 other directories.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Mon Jul 2 09:53:28 EDT 2007
Author: steve.ebersole at jboss.com
Date: 2007-07-02 09:53:27 -0400 (Mon, 02 Jul 2007)
New Revision: 12662
Added:
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/AbstractDocBookMojo.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/DocBookSupportResourcesMojo.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/Format.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/GenerationMojo.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/Options.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/PackageMojo.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/ResourceMojo.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/TranslationDiffReport.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/RenderingException.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/XSLTException.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/format/
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/format/BasicFormatHandler.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/format/FormatHandler.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/format/FormatHandlerFactory.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/format/PdfFormatHandler.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/util/
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/util/Formatting.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/util/NoOpWriter.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/util/ResourceHelper.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/util/StaleSourceChecker.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/util/StandardDocBookFormatSpecification.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/util/TransformerType.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/xslt/
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/xslt/TransformerFactory.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/xslt/catalog/
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/xslt/catalog/AbstractCatalogManager.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/xslt/catalog/ExplicitCatalogManager.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/xslt/catalog/ImplicitCatalogManager.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/xslt/resolve/
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/xslt/resolve/BasicUrnResolver.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/xslt/resolve/CurrentVersionResolver.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/xslt/resolve/ExplicitUrnResolver.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/xslt/resolve/RelativeJarUriResolver.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/xslt/resolve/ResolverChain.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/xslt/resolve/VersionResolver.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/revdiff/
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/revdiff/BaselineHandler.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/revdiff/ContentItem.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/revdiff/ContentItemDescriptor.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/revdiff/Diff.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/revdiff/DiffCreator.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/revdiff/GenerationException.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/revdiff/IndexReportGenerator.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/revdiff/TranslationHandler.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/revdiff/TranslationReportGenerator.java
Removed:
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/AbstractDocBookMojo.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/DocBookSupportResourcesMojo.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/Format.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/GenerationMojo.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/Options.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/PackageMojo.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/ResourceMojo.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/TranslationDiffReport.java
Modified:
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/OLinkDBUpdater.java
sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/resources/META-INF/plexus/components.xml
Log:
reverting back from codehaus move
Deleted: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/AbstractDocBookMojo.java
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/AbstractDocBookMojo.java 2007-07-02 13:37:33 UTC (rev 12661)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/AbstractDocBookMojo.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -1,255 +0,0 @@
-/*
- * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, v. 2.1. This program is distributed in the
- * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details. You should have received a
- * copy of the GNU Lesser General Public License, v.2.1 along with this
- * distribution; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Red Hat Author(s): Steve Ebersole
- */
-package org.codehaus.mojo.docbook;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.maven.doxia.siterenderer.Renderer;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectHelper;
-import org.codehaus.plexus.archiver.manager.ArchiverManager;
-import org.codehaus.mojo.docbook.gen.RenderingException;
-import org.codehaus.mojo.docbook.gen.XSLTException;
-import org.codehaus.mojo.docbook.gen.util.Formatting;
-import org.codehaus.mojo.docbook.gen.util.StandardDocBookFormatSpecification;
-
-/**
- * Basic support for the various DocBook mojos in this package. Mainly, we are
- * defining common configuration attributes of the packaging.
- * <p/>
- * todo : I'd much prefer to see the "partial artifact coord" stuff go away
- * and use custom package types to convey this information. This frees the
- * user from duplicate entry of the information.
- *
- * @author Steve Ebersole
- */
-public abstract class AbstractDocBookMojo extends AbstractMojo {
- public static final String PLUGIN_NAME = "jboss-docbook";
-
- /**
- * INTERNAL : The project being built
- *
- * @parameter expression="${project}"
- * @required
- * @readonly
- */
- protected MavenProject project;
-
- /**
- * INTERNAL : The artifacts associated with the dependencies defined as part
- * of the project to which we are being attached.
- *
- * @parameter expression="${project.artifacts}"
- * @required
- * @readonly
- */
- protected Set projectArtifacts;
-
- /**
- * INTERNAL : The artifacts associated to the dependencies defined as part
- * of our configuration within the project to which we are being attached.
- *
- * @parameter expression="${plugin.artifacts}"
- * @required
- * @readonly
- */
- protected List pluginArtifacts;
-
- /**
- * INTERNAL : used to get reference to environemtn Archiver/UnArchiver.
- *
- * @parameter expression="${component.org.codehaus.plexus.archiver.manager.ArchiverManager}"
- * @required
- * @readonly
- */
- protected ArchiverManager archiverManager;
-
- /**
- * INTERNAL : used in the translation diff report
- *
- * @parameter expression="${component.org.apache.maven.doxia.siterenderer.Renderer}"
- * @required
- * @readonly
- */
- protected Renderer siteRenderer;
-
- /**
- * INTERNAL : used during packaging to attach produced artifacts
- *
- * @parameter expression="${component.org.apache.maven.project.MavenProjectHelper}"
- * @required
- * @readonly
- */
- protected MavenProjectHelper projectHelper;
-
- /**
- * The name of the document (relative to sourceDirectory) which is the
- * document to be rendered.
- *
- * @parameter
- * @required
- */
- protected String sourceDocumentName;
-
- /**
- * The directory where the sources are located.
- *
- * @parameter expression="${basedir}/src/main/docbook"
- */
- protected File sourceDirectory;
-
- /**
- * The directory containing local images
- *
- * @parameter expression="${basedir}/src/main/images"
- */
- protected File imagesDirectory;
-
- /**
- * The directory containing local css
- *
- * @parameter expression="${basedir}/src/main/css"
- */
- protected File cssDirectory;
-
- /**
- * The directory containing local fonts
- *
- * @parameter expression="${basedir}/src/main/fonts"
- */
- protected File fontsDirectory;
-
- /**
- * The directory where the output will be written.
- *
- * @parameter expression="${basedir}/target/docbook"
- */
- protected File targetDirectory;
-
- /**
- * The directory where "docbook resource" staging occurs. Mainly this is
- * used for (1) image/css staging for html-based output; (2) base directory
- * for value of <tt>img.src.path</tt> DocBook XSLT parameter for fop-based
- * formattings.
- *
- * @parameter expression="${basedir}/target/staging"
- * @required
- * @readonly
- */
- protected File stagingDirectory;
-
- /**
- * The formats in which to perform rendering.
- *
- * @parameter
- * @required
- */
- protected Format[] formats;
-
- /**
- * The artifactId of the master translation (unless, of course, this is the
- * master translation). It is assumed that the master translation:<ol>
- * <li>is part of the same groupId</li>
- * <li>has its source defined as a dependency (classifier = source)</li>
- * </ol>
- *
- * @parameter
- */
- protected String masterTranslationArtifactId;
-
- /**
- * Local path to the master translation to use for diff reporting.
- *
- * @parameter
- */
- protected File masterTranslationFile;
-
- /**
- * The relative path font configuration to use.
- *
- * @parameter
- */
- protected String fontConfig;
-
- /**
- * Configurable options
- *
- * @parameter
- */
- protected Options options;
-
-
- /**
- * The override method to perform the actual processing of the
- * mojo.
- *
- * @param formattings The fomattings configured for render
- * @throws RenderingException Indicates problem performing rendering
- * @throws XSLTException Indicates problem building or executing XSLT transformer
- */
- protected abstract void process(Formatting[] formattings) throws RenderingException, XSLTException;
-
- public final void execute() throws MojoExecutionException, MojoFailureException {
- try {
- process( buildFormattings() );
- }
- catch ( XSLTException e ) {
- throw new MojoExecutionException( "XSLT problem", e );
- }
- catch ( RenderingException e ) {
- throw new MojoExecutionException( "Rendering problem", e );
- }
- }
-
- private Formatting[] buildFormattings() {
- Formatting[] formattings = new Formatting[ formats.length ];
- for ( int i = 0; i < formats.length; i++ ) {
- formattings[i] = new Formatting( StandardDocBookFormatSpecification.parse( formats[i].getFormatName() ), formats[i] );
- }
- return formattings;
- }
-
- protected static interface ArtifactProcessor {
- public void process(org.apache.maven.artifact.Artifact artifact);
- }
-
- protected void processArtifacts(ArtifactProcessor processor) {
- processProjectArtifacts( processor );
- processPluginArtifacts( processor );
- }
-
- protected void processProjectArtifacts(ArtifactProcessor processor) {
- processArtifacts( processor, projectArtifacts );
- }
-
- protected void processPluginArtifacts(ArtifactProcessor processor) {
- processArtifacts( processor, pluginArtifacts );
- }
-
- private void processArtifacts(ArtifactProcessor processor, Collection artifacts) {
- Iterator itr = artifacts.iterator();
- while ( itr.hasNext() ) {
- processor.process( ( org.apache.maven.artifact.Artifact ) itr.next() );
- }
- }
-}
Deleted: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/DocBookSupportResourcesMojo.java
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/DocBookSupportResourcesMojo.java 2007-07-02 13:37:33 UTC (rev 12661)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/DocBookSupportResourcesMojo.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -1,103 +0,0 @@
-/*
- * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, v. 2.1. This program is distributed in the
- * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details. You should have received a
- * copy of the GNU Lesser General Public License, v.2.1 along with this
- * distribution; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Red Hat Author(s): Steve Ebersole
- */
-package org.codehaus.mojo.docbook;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.codehaus.plexus.util.FileUtils;
-
-/**
- * Defines resources-like processing for docbook-support files such
- * as XSLT, fonts, resources (images/css/etc), moving them to specific locations
- * within the output directory for inclusion in the final package.
- *
- * @goal support-resources
- * @phase process-resources
- * @requiresDependencyResolution
- *
- * @author Steve Ebersole
- */
-public class DocBookSupportResourcesMojo extends AbstractMojo {
-
- /**
- * The directory containing the XSLT sources.
- *
- * @parameter expression="${basedir}/src/main/styles"
- */
- protected File xsltSourceDirectory;
-
- /**
- * The directory containing fonts to be included in package.
- *
- * @parameter expression="${basedir}/src/main/fonts"
- */
- protected File fontSourceDirectory;
-
- /**
- * The directory containing images to be included in package.
- *
- * @parameter expression="${basedir}/src/main/images"
- */
- protected File imagesSourceDirectory;
-
- /**
- * The directory containing css to be included in package.
- *
- * @parameter expression="${basedir}/src/main/css"
- */
- protected File cssSourceDirectory;
-
- /**
- * The directory from which packaging is staged.
- *
- * @parameter expression="${project.build.outputDirectory}"
- */
- protected File outputDirectory;
-
- public void execute() throws MojoExecutionException, MojoFailureException {
- copySource( xsltSourceDirectory, new File( outputDirectory, "styles" ) );
- copySource( fontSourceDirectory, new File( outputDirectory, "fonts" ) );
- copySource( imagesSourceDirectory, new File( outputDirectory, "images" ) );
- copySource( cssSourceDirectory, new File( outputDirectory, "css" ) );
- }
-
- private void copySource(File sourceDirectory, File targetDirectory)
- throws MojoExecutionException {
- getLog().info( "attempting to copy directory : " + sourceDirectory.getAbsolutePath() );
- if ( !sourceDirectory.exists() ) {
- return;
- }
- String[] list = sourceDirectory.list();
- if ( list == null || list.length == 0 ) {
- return;
- }
-
- if ( !targetDirectory.exists() ) {
- targetDirectory.mkdirs();
- }
-
- try {
- FileUtils.copyDirectoryStructure( sourceDirectory, targetDirectory );
- }
- catch ( IOException e ) {
- throw new MojoExecutionException( "unable to copy source directory [" + sourceDirectory.getAbsolutePath() + "]", e );
- }
- }
-}
Deleted: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/Format.java
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/Format.java 2007-07-02 13:37:33 UTC (rev 12661)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/Format.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -1,80 +0,0 @@
-/*
- * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, v. 2.1. This program is distributed in the
- * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details. You should have received a
- * copy of the GNU Lesser General Public License, v.2.1 along with this
- * distribution; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Red Hat Author(s): Steve Ebersole
- */
-package org.codehaus.mojo.docbook;
-
-/**
- * Represents a user format specification.
- *
- * @author Steve Ebersole
- */
-public class Format {
- private String formatName;
-
- private String targetFileExtension;
- private String finalName;
- private String stylesheetResource;
- private Boolean imagePathSettingRequired;
- private Boolean imageCopyingRequired;
- private Boolean doingChunking;
-
- public Format() {
- }
-
- public Format(
- String formatName,
- String targetFileExtension,
- String finalName,
- String stylesheetResource,
- Boolean imagePathSettingRequired,
- Boolean imageCopyingRequired,
- Boolean doingChunking) {
- this.formatName = formatName;
- this.targetFileExtension = targetFileExtension;
- this.finalName = finalName;
- this.stylesheetResource = stylesheetResource;
- this.imagePathSettingRequired = imagePathSettingRequired;
- this.imageCopyingRequired = imageCopyingRequired;
- this.doingChunking = doingChunking;
- }
-
- public String getFormatName() {
- return formatName;
- }
-
- public String getTargetFileExtension() {
- return targetFileExtension;
- }
-
- public String getFinalName() {
- return finalName;
- }
-
- public String getStylesheetResource() {
- return stylesheetResource;
- }
-
- public Boolean getImagePathSettingRequired() {
- return imagePathSettingRequired;
- }
-
- public Boolean getImageCopyingRequired() {
- return imageCopyingRequired;
- }
-
- public Boolean getDoingChunking() {
- return doingChunking;
- }
-}
Deleted: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/GenerationMojo.java
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/GenerationMojo.java 2007-07-02 13:37:33 UTC (rev 12661)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/GenerationMojo.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -1,99 +0,0 @@
-/*
- * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, v. 2.1. This program is distributed in the
- * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details. You should have received a
- * copy of the GNU Lesser General Public License, v.2.1 along with this
- * distribution; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Red Hat Author(s): Steve Ebersole
- */
-package org.codehaus.mojo.docbook;
-
-import java.io.File;
-
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.mojo.docbook.gen.util.Formatting;
-import org.codehaus.mojo.docbook.gen.format.FormatHandlerFactory;
-import org.codehaus.mojo.docbook.gen.RenderingException;
-import org.codehaus.mojo.docbook.gen.XSLTException;
-import org.apache.maven.artifact.Artifact;
-
-/**
- * This mojo's responsibility within the plugin/packaging is actually performing
- * the DocBook transformations. At the highest level, it takes the source and
- * process it via the specified DocBook XSLT to produce output.
- *
- * @goal generate
- * @phase compile
- * @requiresDependencyResolution
- *
- * @author Steve Ebersole
- */
-public class GenerationMojo extends AbstractDocBookMojo {
-
- protected void process(Formatting[] formattings) throws XSLTException, RenderingException {
- if ( !sourceDirectory.exists() ) {
- getLog().info( "sourceDirectory [" + sourceDirectory.getAbsolutePath() + "] did not exist" );
- return;
- }
- File source = new File( sourceDirectory, sourceDocumentName );
- if ( !source.exists() ) {
- getLog().info( "source [" + source.getAbsolutePath() + "] did not exist" );
- return;
- }
-
- if ( !targetDirectory.exists() ) {
- FileUtils.mkdir( targetDirectory.getAbsolutePath() );
- }
-
- if ( options.getDocbookVersion() == null ) {
- processArtifacts(
- new ArtifactProcessor() {
- public void process(Artifact artifact) {
- if ( "net.sf.docbook".equals( artifact.getGroupId() ) &&
- "docbook".equals( artifact.getArtifactId() ) ) {
- getLog().debug( "Found docbook version : " + artifact.getVersion() );
- if ( options.getDocbookVersion() != null ) {
- getLog().warn( "found multiple docbook versions" );
- }
- options.setDocbookVersion( artifact.getVersion() );
- }
- }
- }
- );
- }
-
- File fontConfigFile = null;
- if ( fontConfig != null ) {
- getLog().debug( "checking for fontConfig existence [" + fontConfig + "]" );
- if ( stagingDirectory != null ) {
- File tmp = new File( stagingDirectory, fontConfig );
- if ( tmp.exists() ) {
- getLog().info( "using font configuration : " + tmp.getAbsolutePath() );
- fontConfigFile = tmp;
- }
- }
- }
-
- FormatHandlerFactory formatHandlerFactory = new FormatHandlerFactory(
- options,
- source,
- targetDirectory,
- stagingDirectory,
- fontConfigFile,
- project,
- getLog()
- );
-
- for ( int i = 0; i < formattings.length; i++ ) {
- formatHandlerFactory.buildFormatHandler( formattings[i] ).render( source );
- }
- }
-
-}
Modified: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/OLinkDBUpdater.java
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/OLinkDBUpdater.java 2007-07-02 13:37:33 UTC (rev 12661)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/OLinkDBUpdater.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -32,9 +32,9 @@
import javax.xml.transform.stream.StreamSource;
import org.apache.maven.plugin.logging.Log;
-import org.codehaus.mojo.docbook.gen.util.NoOpWriter;
-import org.codehaus.mojo.docbook.gen.util.ResourceHelper;
-import org.codehaus.mojo.docbook.gen.util.StandardDocBookFormatSpecification;
+import org.jboss.maven.plugins.docbook.gen.util.NoOpWriter;
+import org.jboss.maven.plugins.docbook.gen.util.ResourceHelper;
+import org.jboss.maven.plugins.docbook.gen.util.StandardDocBookFormatSpecification;
import org.codehaus.plexus.compiler.util.scan.InclusionScanException;
import org.codehaus.plexus.compiler.util.scan.StaleSourceScanner;
import org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping;
Deleted: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/Options.java
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/Options.java 2007-07-02 13:37:33 UTC (rev 12661)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/Options.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -1,78 +0,0 @@
-/*
- * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, v. 2.1. This program is distributed in the
- * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details. You should have received a
- * copy of the GNU Lesser General Public License, v.2.1 along with this
- * distribution; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Red Hat Author(s): Steve Ebersole
- */
-package org.codehaus.mojo.docbook;
-
-import java.util.Properties;
-
-/**
- * A (detachable) representation of the user configuration.
- *
- * @author Steve Ebersole
- */
-public class Options {
- private boolean xincludeSupported;
- private String[] catalogs;
- private String xmlTransformerType;
- private Properties transformerParameters;
- private boolean useRelativeImageUris = true;
- private String docbookVersion;
-
- public Options() {
- }
-
- public Options(
- boolean xincludeSupported,
- String[] catalogs,
- String xmlTransformerType,
- Properties transformerParameters,
- boolean useRelativeImageUris,
- String docBookVersion) {
- this.xincludeSupported = xincludeSupported;
- this.catalogs = catalogs;
- this.xmlTransformerType = xmlTransformerType;
- this.transformerParameters = transformerParameters;
- this.useRelativeImageUris = useRelativeImageUris;
- this.docbookVersion = docBookVersion;
- }
-
- public boolean isXincludeSupported() {
- return xincludeSupported;
- }
-
- public String[] getCatalogs() {
- return catalogs;
- }
-
- public String getXmlTransformerType() {
- return xmlTransformerType;
- }
-
- public Properties getTransformerParameters() {
- return transformerParameters;
- }
-
- public boolean isUseRelativeImageUris() {
- return useRelativeImageUris;
- }
-
- public String getDocbookVersion() {
- return docbookVersion;
- }
-
- void setDocbookVersion(String docbookVersion) {
- this.docbookVersion = docbookVersion;
- }
-}
Deleted: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/PackageMojo.java
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/PackageMojo.java 2007-07-02 13:37:33 UTC (rev 12661)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/PackageMojo.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -1,56 +0,0 @@
-/*
- * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, v. 2.1. This program is distributed in the
- * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details. You should have received a
- * copy of the GNU Lesser General Public License, v.2.1 along with this
- * distribution; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Red Hat Author(s): Steve Ebersole
- */
-package org.codehaus.mojo.docbook;
-
-import java.io.File;
-
-import org.codehaus.mojo.docbook.gen.util.Formatting;
-import org.codehaus.mojo.docbook.gen.RenderingException;
-import org.codehaus.mojo.docbook.gen.format.FormatHandlerFactory;
-
-/**
- * This mojo's responsibility within the plugin/packaging is to bundle the
- * individual formats into deployable formats. The desicion Note that some formats (PDF, e.g.) are
- * already deployable.
- * <p/>
- * After bundling, each bundle is then attached to the project
- *
- * @goal bundle
- * @phase package
- * @requiresDependencyResolution
- *
- * @author Steve Ebersole
- */
-public class PackageMojo extends AbstractDocBookMojo {
- protected void process(Formatting[] formattings) throws RenderingException {
- File source = new File( sourceDirectory, sourceDocumentName );
- FormatHandlerFactory formatHandlerFactory = new FormatHandlerFactory(
- options,
- source,
- targetDirectory,
- stagingDirectory,
- null,
- project,
- getLog()
- );
-
- project.getArtifact().setFile( project.getFile() );
-
- for ( int i = 0; i < formattings.length; i++ ) {
- formatHandlerFactory.buildFormatHandler( formattings[i] ).attachOutput( source, projectHelper );
- }
- }
-}
Deleted: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/ResourceMojo.java
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/ResourceMojo.java 2007-07-02 13:37:33 UTC (rev 12661)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/ResourceMojo.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -1,128 +0,0 @@
-/*
- * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, v. 2.1. This program is distributed in the
- * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details. You should have received a
- * copy of the GNU Lesser General Public License, v.2.1 along with this
- * distribution; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Red Hat Author(s): Steve Ebersole
- */
-package org.codehaus.mojo.docbook;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.maven.artifact.Artifact;
-import org.codehaus.plexus.archiver.ArchiverException;
-import org.codehaus.plexus.archiver.UnArchiver;
-import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.mojo.docbook.gen.util.Formatting;
-import org.codehaus.mojo.docbook.gen.RenderingException;
-import org.codehaus.mojo.docbook.gen.XSLTException;
-
-/**
- * This mojo's responsibility within the plugin/packaging is to process resources
- * defined by various inputs, moving them into a staging directory for use
- * during XSLT processing. This is needed because the DocBook XSLT only allow
- * defining a single <tt>img.src.path</tt> value; FOP only allows a single
- * <tt>fontBaseDir</tt> value; etc.
- *
- * @goal resources
- * @phase process-resources
- * @requiresDependencyResolution
- *
- * @author Steve Ebersole
- */
-public class ResourceMojo extends AbstractDocBookMojo {
-
- protected void process(Formatting[] formattings) throws RenderingException, XSLTException {
- processProjectResources();
- processDependencySupportArtifacts( collectDocBookSupportDependentArtifacts() );
- }
-
- // project local resources ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- private void processProjectResources() throws RenderingException {
- copySource( imagesDirectory, new File( stagingDirectory, "images" ) );
- copySource( cssDirectory, new File( stagingDirectory, "css" ) );
- copySource( fontsDirectory, new File( stagingDirectory, "fonts" ) );
- }
-
- private void copySource(File sourceDirectory, File targetDirectory)
- throws RenderingException {
- getLog().info( "attempting to copy directory : " + sourceDirectory.getAbsolutePath() );
- if ( !sourceDirectory.exists() ) {
- return;
- }
- String[] list = sourceDirectory.list();
- if ( list == null || list.length == 0 ) {
- return;
- }
-
- if ( !targetDirectory.exists() ) {
- targetDirectory.mkdirs();
- }
-
- try {
- FileUtils.copyDirectoryStructure( sourceDirectory, targetDirectory );
- }
- catch ( IOException e ) {
- throw new RenderingException( "unable to copy source directory [" + sourceDirectory.getAbsolutePath() + "]", e );
- }
- }
-
-
- // dependency support resources ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- private List collectDocBookSupportDependentArtifacts() {
- final ArrayList rtn = new ArrayList();
- processArtifacts(
- new ArtifactProcessor() {
- public void process(Artifact artifact) {
- if ( "docbook-support".equals( artifact.getType() ) ) {
- rtn.add( artifact );
- }
- }
- }
- );
- return rtn;
- }
-
- private void processDependencySupportArtifacts(List artifacts) throws RenderingException {
- Iterator itr = artifacts.iterator();
- while ( itr.hasNext() ) {
- final Artifact supportArtifact = ( Artifact ) itr.next();
- processDependencySupportArtifact( supportArtifact.getFile(), stagingDirectory );
- }
- }
-
- protected void processDependencySupportArtifact(File file, File target) throws RenderingException {
- getLog().info( "unpacking dependency resource [" + file.getAbsolutePath() + "] to staging-dir [" + target.getAbsolutePath() + "]" );
- try {
- target.mkdirs();
- UnArchiver unArchiver = archiverManager.getUnArchiver( "jar" );
- unArchiver.setSourceFile( file );
- unArchiver.setDestDirectory( target );
- unArchiver.extract();
- }
- catch ( NoSuchArchiverException e ) {
- throw new RenderingException( "Unknown archiver type", e );
- }
- catch ( ArchiverException e ) {
- throw new RenderingException( "Error unpacking file [" + file + "] to [" + target + "]", e );
- }
- catch ( IOException e ) {
- throw new RenderingException( "Error unpacking file [" + file + "] to [" + target + "]", e );
- }
- }
-}
Deleted: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/TranslationDiffReport.java
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/TranslationDiffReport.java 2007-07-02 13:37:33 UTC (rev 12661)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/TranslationDiffReport.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -1,187 +0,0 @@
-/*
- * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, v. 2.1. This program is distributed in the
- * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details. You should have received a
- * copy of the GNU Lesser General Public License, v.2.1 along with this
- * distribution; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Red Hat Author(s): Christian Bauer, Steve Ebersole
- */
-package org.codehaus.mojo.docbook;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.reporting.MavenReport;
-import org.apache.maven.reporting.MavenReportException;
-import org.codehaus.mojo.docbook.gen.util.Formatting;
-import org.codehaus.mojo.docbook.gen.RenderingException;
-import org.codehaus.mojo.docbook.revdiff.Diff;
-import org.codehaus.mojo.docbook.revdiff.DiffCreator;
-import org.codehaus.mojo.docbook.revdiff.GenerationException;
-import org.codehaus.mojo.docbook.revdiff.TranslationReportGenerator;
-
-/**
- * A plugin for generating a "translation diff" report across different
- * translations of the same document. This is useful for the translators to
- * know what changes exist between their translation and the master.
- * <p/>
- * Eventually, there is a possibility this will not be needed as we move
- * forward if it is decided to move to the xliff format for translations.
- *
- * @goal diff
- * @phase site
- * @requiresDependencyResolution
- *
- * @author Christian Bauer
- * @author Steve Ebersole
- */
-public class TranslationDiffReport extends AbstractDocBookMojo implements MavenReport {
-
- public static final String NAME = "translation-diff-report";
- private File reportOutputDirectory;
-
- private ResourceBundle getBundle(Locale locale) {
- return ResourceBundle.getBundle( NAME, locale, this.getClass().getClassLoader() );
- }
-
- private String buildReportFileName() {
- return getOutputName() + ".html";
- }
-
- // AbstractDocBookMojo impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Copied nearly verbatim from {@link org.apache.maven.reporting.AbstractMavenReport#execute()}
- *
- * {@inheritDoc}
- */
- protected void process(Formatting[] formattings) throws RenderingException {
- try {
- generateReport( Locale.getDefault() );
- }
- catch (GenerationException t) {
- throw new RenderingException( "An error has occurred in " + NAME + " report generation.", t );
- }
- }
-
-
- // MavenReport impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public String getOutputName() {
- return NAME;
- }
-
- public String getName(Locale locale) {
- return getBundle( locale ).getString( "report.name" );
- }
-
- public String getDescription(Locale locale) {
- return getBundle( locale ).getString( "report.description" );
- }
-
- public String getCategoryName() {
- return CATEGORY_PROJECT_REPORTS;
- }
-
- public void setReportOutputDirectory(File dir) {
- this.reportOutputDirectory = dir;
- }
-
- public File getReportOutputDirectory() {
- if ( reportOutputDirectory == null ) {
- reportOutputDirectory = new File( project.getReporting().getOutputDirectory() );
- }
- return reportOutputDirectory;
- }
-
- public boolean isExternalReport() {
- return false;
- }
-
- public boolean canGenerateReport() {
- return masterTranslationArtifactId != null ||
- ( masterTranslationFile != null && masterTranslationFile.exists() );
- }
-
- public void generate(org.codehaus.doxia.sink.Sink sink, Locale locale) throws MavenReportException {
- try {
- generateReport( locale );
- }
- catch ( GenerationException e ) {
- throw new MavenReportException( "error generating report", e );
- }
- }
-
-
- // report generation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- private void generateReport(Locale locale) throws GenerationException {
- getLog().debug( "starting " + PLUGIN_NAME + ":diff goal execution" );
-
- if ( !canGenerateReport() ) {
- getLog().info( "project is documentation master (or no master defined)" );
- return;
- }
-
- File master = masterTranslationFile;
- if ( master == null ) {
- MasterTranslationLocator locator = new MasterTranslationLocator();
- processArtifacts( locator );
- master = locator.located.getFile();
- }
- if ( master == null ) {
- throw new GenerationException( "unable to locate master source" );
- }
-
- File translation = new File( sourceDirectory, sourceDocumentName );
-
- getLog().debug( " master : " + master.getAbsolutePath() );
- getLog().debug( " translation : " + translation.getAbsolutePath() );
-
- File output = new File( getReportOutputDirectory(), buildReportFileName() );
- prepReportFile( output );
-
- DiffCreator diffCreator = new DiffCreator( options.isXincludeSupported(), getLog() );
- Diff diff = diffCreator.findDiff( master, translation );
-
- TranslationReportGenerator generator = new TranslationReportGenerator( sourceDirectory, getBundle( locale ), getLog() );
- generator.generate( diff, output, locale.toString() );
- }
-
- class MasterTranslationLocator implements ArtifactProcessor {
- private final String groupId = project.getGroupId();
- private Artifact located;
- public void process(Artifact artifact) {
- if ( groupId.equals( artifact.getGroupId() ) && masterTranslationArtifactId.equals( artifact.getArtifactId() ) ) {
- if ( located != null ) {
- getLog().warn( "duplicate matching master found" );
- }
- located = artifact;
- }
- }
- }
-
- private void prepReportFile(File reportFile) throws GenerationException {
- if ( reportFile.exists() ) {
- reportFile.delete();
- }
- if ( !reportFile.exists() ) {
- try {
- reportFile.createNewFile();
- }
- catch ( IOException e ) {
- throw new GenerationException( "unable to prep report file [" + reportFile.getAbsolutePath() + "]" );
- }
- }
- }
-}
Added: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/AbstractDocBookMojo.java
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/AbstractDocBookMojo.java (rev 0)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/AbstractDocBookMojo.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -0,0 +1,255 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.docbook;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.doxia.siterenderer.Renderer;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectHelper;
+import org.codehaus.plexus.archiver.manager.ArchiverManager;
+import org.jboss.maven.plugins.docbook.gen.RenderingException;
+import org.jboss.maven.plugins.docbook.gen.XSLTException;
+import org.jboss.maven.plugins.docbook.gen.util.Formatting;
+import org.jboss.maven.plugins.docbook.gen.util.StandardDocBookFormatSpecification;
+
+/**
+ * Basic support for the various DocBook mojos in this package. Mainly, we are
+ * defining common configuration attributes of the packaging.
+ * <p/>
+ * todo : I'd much prefer to see the "partial artifact coord" stuff go away
+ * and use custom package types to convey this information. This frees the
+ * user from duplicate entry of the information.
+ *
+ * @author Steve Ebersole
+ */
+public abstract class AbstractDocBookMojo extends AbstractMojo {
+ public static final String PLUGIN_NAME = "jboss-docbook";
+
+ /**
+ * INTERNAL : The project being built
+ *
+ * @parameter expression="${project}"
+ * @required
+ * @readonly
+ */
+ protected MavenProject project;
+
+ /**
+ * INTERNAL : The artifacts associated with the dependencies defined as part
+ * of the project to which we are being attached.
+ *
+ * @parameter expression="${project.artifacts}"
+ * @required
+ * @readonly
+ */
+ protected Set projectArtifacts;
+
+ /**
+ * INTERNAL : The artifacts associated to the dependencies defined as part
+ * of our configuration within the project to which we are being attached.
+ *
+ * @parameter expression="${plugin.artifacts}"
+ * @required
+ * @readonly
+ */
+ protected List pluginArtifacts;
+
+ /**
+ * INTERNAL : used to get reference to environemtn Archiver/UnArchiver.
+ *
+ * @parameter expression="${component.org.codehaus.plexus.archiver.manager.ArchiverManager}"
+ * @required
+ * @readonly
+ */
+ protected ArchiverManager archiverManager;
+
+ /**
+ * INTERNAL : used in the translation diff report
+ *
+ * @parameter expression="${component.org.apache.maven.doxia.siterenderer.Renderer}"
+ * @required
+ * @readonly
+ */
+ protected Renderer siteRenderer;
+
+ /**
+ * INTERNAL : used during packaging to attach produced artifacts
+ *
+ * @parameter expression="${component.org.apache.maven.project.MavenProjectHelper}"
+ * @required
+ * @readonly
+ */
+ protected MavenProjectHelper projectHelper;
+
+ /**
+ * The name of the document (relative to sourceDirectory) which is the
+ * document to be rendered.
+ *
+ * @parameter
+ * @required
+ */
+ protected String sourceDocumentName;
+
+ /**
+ * The directory where the sources are located.
+ *
+ * @parameter expression="${basedir}/src/main/docbook"
+ */
+ protected File sourceDirectory;
+
+ /**
+ * The directory containing local images
+ *
+ * @parameter expression="${basedir}/src/main/images"
+ */
+ protected File imagesDirectory;
+
+ /**
+ * The directory containing local css
+ *
+ * @parameter expression="${basedir}/src/main/css"
+ */
+ protected File cssDirectory;
+
+ /**
+ * The directory containing local fonts
+ *
+ * @parameter expression="${basedir}/src/main/fonts"
+ */
+ protected File fontsDirectory;
+
+ /**
+ * The directory where the output will be written.
+ *
+ * @parameter expression="${basedir}/target/docbook"
+ */
+ protected File targetDirectory;
+
+ /**
+ * The directory where "docbook resource" staging occurs. Mainly this is
+ * used for (1) image/css staging for html-based output; (2) base directory
+ * for value of <tt>img.src.path</tt> DocBook XSLT parameter for fop-based
+ * formattings.
+ *
+ * @parameter expression="${basedir}/target/staging"
+ * @required
+ * @readonly
+ */
+ protected File stagingDirectory;
+
+ /**
+ * The formats in which to perform rendering.
+ *
+ * @parameter
+ * @required
+ */
+ protected Format[] formats;
+
+ /**
+ * The artifactId of the master translation (unless, of course, this is the
+ * master translation). It is assumed that the master translation:<ol>
+ * <li>is part of the same groupId</li>
+ * <li>has its source defined as a dependency (classifier = source)</li>
+ * </ol>
+ *
+ * @parameter
+ */
+ protected String masterTranslationArtifactId;
+
+ /**
+ * Local path to the master translation to use for diff reporting.
+ *
+ * @parameter
+ */
+ protected File masterTranslationFile;
+
+ /**
+ * The relative path font configuration to use.
+ *
+ * @parameter
+ */
+ protected String fontConfig;
+
+ /**
+ * Configurable options
+ *
+ * @parameter
+ */
+ protected Options options;
+
+
+ /**
+ * The override method to perform the actual processing of the
+ * mojo.
+ *
+ * @param formattings The fomattings configured for render
+ * @throws RenderingException Indicates problem performing rendering
+ * @throws XSLTException Indicates problem building or executing XSLT transformer
+ */
+ protected abstract void process(Formatting[] formattings) throws RenderingException, XSLTException;
+
+ public final void execute() throws MojoExecutionException, MojoFailureException {
+ try {
+ process( buildFormattings() );
+ }
+ catch ( XSLTException e ) {
+ throw new MojoExecutionException( "XSLT problem", e );
+ }
+ catch ( RenderingException e ) {
+ throw new MojoExecutionException( "Rendering problem", e );
+ }
+ }
+
+ private Formatting[] buildFormattings() {
+ Formatting[] formattings = new Formatting[ formats.length ];
+ for ( int i = 0; i < formats.length; i++ ) {
+ formattings[i] = new Formatting( StandardDocBookFormatSpecification.parse( formats[i].getFormatName() ), formats[i] );
+ }
+ return formattings;
+ }
+
+ protected static interface ArtifactProcessor {
+ public void process(org.apache.maven.artifact.Artifact artifact);
+ }
+
+ protected void processArtifacts(ArtifactProcessor processor) {
+ processProjectArtifacts( processor );
+ processPluginArtifacts( processor );
+ }
+
+ protected void processProjectArtifacts(ArtifactProcessor processor) {
+ processArtifacts( processor, projectArtifacts );
+ }
+
+ protected void processPluginArtifacts(ArtifactProcessor processor) {
+ processArtifacts( processor, pluginArtifacts );
+ }
+
+ private void processArtifacts(ArtifactProcessor processor, Collection artifacts) {
+ Iterator itr = artifacts.iterator();
+ while ( itr.hasNext() ) {
+ processor.process( ( org.apache.maven.artifact.Artifact ) itr.next() );
+ }
+ }
+}
Added: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/DocBookSupportResourcesMojo.java
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/DocBookSupportResourcesMojo.java (rev 0)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/DocBookSupportResourcesMojo.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -0,0 +1,103 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.docbook;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.codehaus.plexus.util.FileUtils;
+
+/**
+ * Defines resources-like processing for docbook-support files such
+ * as XSLT, fonts, resources (images/css/etc), moving them to specific locations
+ * within the output directory for inclusion in the final package.
+ *
+ * @goal support-resources
+ * @phase process-resources
+ * @requiresDependencyResolution
+ *
+ * @author Steve Ebersole
+ */
+public class DocBookSupportResourcesMojo extends AbstractMojo {
+
+ /**
+ * The directory containing the XSLT sources.
+ *
+ * @parameter expression="${basedir}/src/main/styles"
+ */
+ protected File xsltSourceDirectory;
+
+ /**
+ * The directory containing fonts to be included in package.
+ *
+ * @parameter expression="${basedir}/src/main/fonts"
+ */
+ protected File fontSourceDirectory;
+
+ /**
+ * The directory containing images to be included in package.
+ *
+ * @parameter expression="${basedir}/src/main/images"
+ */
+ protected File imagesSourceDirectory;
+
+ /**
+ * The directory containing css to be included in package.
+ *
+ * @parameter expression="${basedir}/src/main/css"
+ */
+ protected File cssSourceDirectory;
+
+ /**
+ * The directory from which packaging is staged.
+ *
+ * @parameter expression="${project.build.outputDirectory}"
+ */
+ protected File outputDirectory;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ copySource( xsltSourceDirectory, new File( outputDirectory, "styles" ) );
+ copySource( fontSourceDirectory, new File( outputDirectory, "fonts" ) );
+ copySource( imagesSourceDirectory, new File( outputDirectory, "images" ) );
+ copySource( cssSourceDirectory, new File( outputDirectory, "css" ) );
+ }
+
+ private void copySource(File sourceDirectory, File targetDirectory)
+ throws MojoExecutionException {
+ getLog().info( "attempting to copy directory : " + sourceDirectory.getAbsolutePath() );
+ if ( !sourceDirectory.exists() ) {
+ return;
+ }
+ String[] list = sourceDirectory.list();
+ if ( list == null || list.length == 0 ) {
+ return;
+ }
+
+ if ( !targetDirectory.exists() ) {
+ targetDirectory.mkdirs();
+ }
+
+ try {
+ FileUtils.copyDirectoryStructure( sourceDirectory, targetDirectory );
+ }
+ catch ( IOException e ) {
+ throw new MojoExecutionException( "unable to copy source directory [" + sourceDirectory.getAbsolutePath() + "]", e );
+ }
+ }
+}
Added: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/Format.java
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/Format.java (rev 0)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/Format.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -0,0 +1,80 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.docbook;
+
+/**
+ * Represents a user format specification.
+ *
+ * @author Steve Ebersole
+ */
+public class Format {
+ private String formatName;
+
+ private String targetFileExtension;
+ private String finalName;
+ private String stylesheetResource;
+ private Boolean imagePathSettingRequired;
+ private Boolean imageCopyingRequired;
+ private Boolean doingChunking;
+
+ public Format() {
+ }
+
+ public Format(
+ String formatName,
+ String targetFileExtension,
+ String finalName,
+ String stylesheetResource,
+ Boolean imagePathSettingRequired,
+ Boolean imageCopyingRequired,
+ Boolean doingChunking) {
+ this.formatName = formatName;
+ this.targetFileExtension = targetFileExtension;
+ this.finalName = finalName;
+ this.stylesheetResource = stylesheetResource;
+ this.imagePathSettingRequired = imagePathSettingRequired;
+ this.imageCopyingRequired = imageCopyingRequired;
+ this.doingChunking = doingChunking;
+ }
+
+ public String getFormatName() {
+ return formatName;
+ }
+
+ public String getTargetFileExtension() {
+ return targetFileExtension;
+ }
+
+ public String getFinalName() {
+ return finalName;
+ }
+
+ public String getStylesheetResource() {
+ return stylesheetResource;
+ }
+
+ public Boolean getImagePathSettingRequired() {
+ return imagePathSettingRequired;
+ }
+
+ public Boolean getImageCopyingRequired() {
+ return imageCopyingRequired;
+ }
+
+ public Boolean getDoingChunking() {
+ return doingChunking;
+ }
+}
Added: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/GenerationMojo.java
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/GenerationMojo.java (rev 0)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/GenerationMojo.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -0,0 +1,99 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.docbook;
+
+import java.io.File;
+
+import org.codehaus.plexus.util.FileUtils;
+import org.jboss.maven.plugins.docbook.gen.util.Formatting;
+import org.jboss.maven.plugins.docbook.gen.format.FormatHandlerFactory;
+import org.jboss.maven.plugins.docbook.gen.RenderingException;
+import org.jboss.maven.plugins.docbook.gen.XSLTException;
+import org.apache.maven.artifact.Artifact;
+
+/**
+ * This mojo's responsibility within the plugin/packaging is actually performing
+ * the DocBook transformations. At the highest level, it takes the source and
+ * process it via the specified DocBook XSLT to produce output.
+ *
+ * @goal generate
+ * @phase compile
+ * @requiresDependencyResolution
+ *
+ * @author Steve Ebersole
+ */
+public class GenerationMojo extends AbstractDocBookMojo {
+
+ protected void process(Formatting[] formattings) throws XSLTException, RenderingException {
+ if ( !sourceDirectory.exists() ) {
+ getLog().info( "sourceDirectory [" + sourceDirectory.getAbsolutePath() + "] did not exist" );
+ return;
+ }
+ File source = new File( sourceDirectory, sourceDocumentName );
+ if ( !source.exists() ) {
+ getLog().info( "source [" + source.getAbsolutePath() + "] did not exist" );
+ return;
+ }
+
+ if ( !targetDirectory.exists() ) {
+ FileUtils.mkdir( targetDirectory.getAbsolutePath() );
+ }
+
+ if ( options.getDocbookVersion() == null ) {
+ processArtifacts(
+ new ArtifactProcessor() {
+ public void process(Artifact artifact) {
+ if ( "net.sf.docbook".equals( artifact.getGroupId() ) &&
+ "docbook".equals( artifact.getArtifactId() ) ) {
+ getLog().debug( "Found docbook version : " + artifact.getVersion() );
+ if ( options.getDocbookVersion() != null ) {
+ getLog().warn( "found multiple docbook versions" );
+ }
+ options.setDocbookVersion( artifact.getVersion() );
+ }
+ }
+ }
+ );
+ }
+
+ File fontConfigFile = null;
+ if ( fontConfig != null ) {
+ getLog().debug( "checking for fontConfig existence [" + fontConfig + "]" );
+ if ( stagingDirectory != null ) {
+ File tmp = new File( stagingDirectory, fontConfig );
+ if ( tmp.exists() ) {
+ getLog().info( "using font configuration : " + tmp.getAbsolutePath() );
+ fontConfigFile = tmp;
+ }
+ }
+ }
+
+ FormatHandlerFactory formatHandlerFactory = new FormatHandlerFactory(
+ options,
+ source,
+ targetDirectory,
+ stagingDirectory,
+ fontConfigFile,
+ project,
+ getLog()
+ );
+
+ for ( int i = 0; i < formattings.length; i++ ) {
+ formatHandlerFactory.buildFormatHandler( formattings[i] ).render( source );
+ }
+ }
+
+}
Added: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/Options.java
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/Options.java (rev 0)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/Options.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -0,0 +1,78 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.docbook;
+
+import java.util.Properties;
+
+/**
+ * A (detachable) representation of the user configuration.
+ *
+ * @author Steve Ebersole
+ */
+public class Options {
+ private boolean xincludeSupported;
+ private String[] catalogs;
+ private String xmlTransformerType;
+ private Properties transformerParameters;
+ private boolean useRelativeImageUris = true;
+ private String docbookVersion;
+
+ public Options() {
+ }
+
+ public Options(
+ boolean xincludeSupported,
+ String[] catalogs,
+ String xmlTransformerType,
+ Properties transformerParameters,
+ boolean useRelativeImageUris,
+ String docBookVersion) {
+ this.xincludeSupported = xincludeSupported;
+ this.catalogs = catalogs;
+ this.xmlTransformerType = xmlTransformerType;
+ this.transformerParameters = transformerParameters;
+ this.useRelativeImageUris = useRelativeImageUris;
+ this.docbookVersion = docBookVersion;
+ }
+
+ public boolean isXincludeSupported() {
+ return xincludeSupported;
+ }
+
+ public String[] getCatalogs() {
+ return catalogs;
+ }
+
+ public String getXmlTransformerType() {
+ return xmlTransformerType;
+ }
+
+ public Properties getTransformerParameters() {
+ return transformerParameters;
+ }
+
+ public boolean isUseRelativeImageUris() {
+ return useRelativeImageUris;
+ }
+
+ public String getDocbookVersion() {
+ return docbookVersion;
+ }
+
+ void setDocbookVersion(String docbookVersion) {
+ this.docbookVersion = docbookVersion;
+ }
+}
Added: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/PackageMojo.java
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/PackageMojo.java (rev 0)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/PackageMojo.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -0,0 +1,56 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.docbook;
+
+import java.io.File;
+
+import org.jboss.maven.plugins.docbook.gen.util.Formatting;
+import org.jboss.maven.plugins.docbook.gen.RenderingException;
+import org.jboss.maven.plugins.docbook.gen.format.FormatHandlerFactory;
+
+/**
+ * This mojo's responsibility within the plugin/packaging is to bundle the
+ * individual formats into deployable formats. The desicion Note that some formats (PDF, e.g.) are
+ * already deployable.
+ * <p/>
+ * After bundling, each bundle is then attached to the project
+ *
+ * @goal bundle
+ * @phase package
+ * @requiresDependencyResolution
+ *
+ * @author Steve Ebersole
+ */
+public class PackageMojo extends AbstractDocBookMojo {
+ protected void process(Formatting[] formattings) throws RenderingException {
+ File source = new File( sourceDirectory, sourceDocumentName );
+ FormatHandlerFactory formatHandlerFactory = new FormatHandlerFactory(
+ options,
+ source,
+ targetDirectory,
+ stagingDirectory,
+ null,
+ project,
+ getLog()
+ );
+
+ project.getArtifact().setFile( project.getFile() );
+
+ for ( int i = 0; i < formattings.length; i++ ) {
+ formatHandlerFactory.buildFormatHandler( formattings[i] ).attachOutput( source, projectHelper );
+ }
+ }
+}
Added: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/ResourceMojo.java
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/ResourceMojo.java (rev 0)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/ResourceMojo.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -0,0 +1,128 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.docbook;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.codehaus.plexus.archiver.ArchiverException;
+import org.codehaus.plexus.archiver.UnArchiver;
+import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
+import org.codehaus.plexus.util.FileUtils;
+import org.jboss.maven.plugins.docbook.gen.util.Formatting;
+import org.jboss.maven.plugins.docbook.gen.RenderingException;
+import org.jboss.maven.plugins.docbook.gen.XSLTException;
+
+/**
+ * This mojo's responsibility within the plugin/packaging is to process resources
+ * defined by various inputs, moving them into a staging directory for use
+ * during XSLT processing. This is needed because the DocBook XSLT only allow
+ * defining a single <tt>img.src.path</tt> value; FOP only allows a single
+ * <tt>fontBaseDir</tt> value; etc.
+ *
+ * @goal resources
+ * @phase process-resources
+ * @requiresDependencyResolution
+ *
+ * @author Steve Ebersole
+ */
+public class ResourceMojo extends AbstractDocBookMojo {
+
+ protected void process(Formatting[] formattings) throws RenderingException, XSLTException {
+ processProjectResources();
+ processDependencySupportArtifacts( collectDocBookSupportDependentArtifacts() );
+ }
+
+ // project local resources ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ private void processProjectResources() throws RenderingException {
+ copySource( imagesDirectory, new File( stagingDirectory, "images" ) );
+ copySource( cssDirectory, new File( stagingDirectory, "css" ) );
+ copySource( fontsDirectory, new File( stagingDirectory, "fonts" ) );
+ }
+
+ private void copySource(File sourceDirectory, File targetDirectory)
+ throws RenderingException {
+ getLog().info( "attempting to copy directory : " + sourceDirectory.getAbsolutePath() );
+ if ( !sourceDirectory.exists() ) {
+ return;
+ }
+ String[] list = sourceDirectory.list();
+ if ( list == null || list.length == 0 ) {
+ return;
+ }
+
+ if ( !targetDirectory.exists() ) {
+ targetDirectory.mkdirs();
+ }
+
+ try {
+ FileUtils.copyDirectoryStructure( sourceDirectory, targetDirectory );
+ }
+ catch ( IOException e ) {
+ throw new RenderingException( "unable to copy source directory [" + sourceDirectory.getAbsolutePath() + "]", e );
+ }
+ }
+
+
+ // dependency support resources ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ private List collectDocBookSupportDependentArtifacts() {
+ final ArrayList rtn = new ArrayList();
+ processArtifacts(
+ new ArtifactProcessor() {
+ public void process(Artifact artifact) {
+ if ( "docbook-support".equals( artifact.getType() ) ) {
+ rtn.add( artifact );
+ }
+ }
+ }
+ );
+ return rtn;
+ }
+
+ private void processDependencySupportArtifacts(List artifacts) throws RenderingException {
+ Iterator itr = artifacts.iterator();
+ while ( itr.hasNext() ) {
+ final Artifact supportArtifact = ( Artifact ) itr.next();
+ processDependencySupportArtifact( supportArtifact.getFile(), stagingDirectory );
+ }
+ }
+
+ protected void processDependencySupportArtifact(File file, File target) throws RenderingException {
+ getLog().info( "unpacking dependency resource [" + file.getAbsolutePath() + "] to staging-dir [" + target.getAbsolutePath() + "]" );
+ try {
+ target.mkdirs();
+ UnArchiver unArchiver = archiverManager.getUnArchiver( "jar" );
+ unArchiver.setSourceFile( file );
+ unArchiver.setDestDirectory( target );
+ unArchiver.extract();
+ }
+ catch ( NoSuchArchiverException e ) {
+ throw new RenderingException( "Unknown archiver type", e );
+ }
+ catch ( ArchiverException e ) {
+ throw new RenderingException( "Error unpacking file [" + file + "] to [" + target + "]", e );
+ }
+ catch ( IOException e ) {
+ throw new RenderingException( "Error unpacking file [" + file + "] to [" + target + "]", e );
+ }
+ }
+}
Added: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/TranslationDiffReport.java
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/TranslationDiffReport.java (rev 0)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/TranslationDiffReport.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -0,0 +1,187 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Christian Bauer, Steve Ebersole
+ */
+package org.jboss.maven.plugins.docbook;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.reporting.MavenReport;
+import org.apache.maven.reporting.MavenReportException;
+import org.jboss.maven.plugins.docbook.gen.util.Formatting;
+import org.jboss.maven.plugins.docbook.gen.RenderingException;
+import org.jboss.maven.plugins.docbook.revdiff.Diff;
+import org.jboss.maven.plugins.docbook.revdiff.DiffCreator;
+import org.jboss.maven.plugins.docbook.revdiff.GenerationException;
+import org.jboss.maven.plugins.docbook.revdiff.TranslationReportGenerator;
+
+/**
+ * A plugin for generating a "translation diff" report across different
+ * translations of the same document. This is useful for the translators to
+ * know what changes exist between their translation and the master.
+ * <p/>
+ * Eventually, there is a possibility this will not be needed as we move
+ * forward if it is decided to move to the xliff format for translations.
+ *
+ * @goal diff
+ * @phase site
+ * @requiresDependencyResolution
+ *
+ * @author Christian Bauer
+ * @author Steve Ebersole
+ */
+public class TranslationDiffReport extends AbstractDocBookMojo implements MavenReport {
+
+ public static final String NAME = "translation-diff-report";
+ private File reportOutputDirectory;
+
+ private ResourceBundle getBundle(Locale locale) {
+ return ResourceBundle.getBundle( NAME, locale, this.getClass().getClassLoader() );
+ }
+
+ private String buildReportFileName() {
+ return getOutputName() + ".html";
+ }
+
+ // AbstractDocBookMojo impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Copied nearly verbatim from {@link org.apache.maven.reporting.AbstractMavenReport#execute()}
+ *
+ * {@inheritDoc}
+ */
+ protected void process(Formatting[] formattings) throws RenderingException {
+ try {
+ generateReport( Locale.getDefault() );
+ }
+ catch (GenerationException t) {
+ throw new RenderingException( "An error has occurred in " + NAME + " report generation.", t );
+ }
+ }
+
+
+ // MavenReport impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public String getOutputName() {
+ return NAME;
+ }
+
+ public String getName(Locale locale) {
+ return getBundle( locale ).getString( "report.name" );
+ }
+
+ public String getDescription(Locale locale) {
+ return getBundle( locale ).getString( "report.description" );
+ }
+
+ public String getCategoryName() {
+ return CATEGORY_PROJECT_REPORTS;
+ }
+
+ public void setReportOutputDirectory(File dir) {
+ this.reportOutputDirectory = dir;
+ }
+
+ public File getReportOutputDirectory() {
+ if ( reportOutputDirectory == null ) {
+ reportOutputDirectory = new File( project.getReporting().getOutputDirectory() );
+ }
+ return reportOutputDirectory;
+ }
+
+ public boolean isExternalReport() {
+ return false;
+ }
+
+ public boolean canGenerateReport() {
+ return masterTranslationArtifactId != null ||
+ ( masterTranslationFile != null && masterTranslationFile.exists() );
+ }
+
+ public void generate(org.codehaus.doxia.sink.Sink sink, Locale locale) throws MavenReportException {
+ try {
+ generateReport( locale );
+ }
+ catch ( GenerationException e ) {
+ throw new MavenReportException( "error generating report", e );
+ }
+ }
+
+
+ // report generation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ private void generateReport(Locale locale) throws GenerationException {
+ getLog().debug( "starting " + PLUGIN_NAME + ":diff goal execution" );
+
+ if ( !canGenerateReport() ) {
+ getLog().info( "project is documentation master (or no master defined)" );
+ return;
+ }
+
+ File master = masterTranslationFile;
+ if ( master == null ) {
+ MasterTranslationLocator locator = new MasterTranslationLocator();
+ processArtifacts( locator );
+ master = locator.located.getFile();
+ }
+ if ( master == null ) {
+ throw new GenerationException( "unable to locate master source" );
+ }
+
+ File translation = new File( sourceDirectory, sourceDocumentName );
+
+ getLog().debug( " master : " + master.getAbsolutePath() );
+ getLog().debug( " translation : " + translation.getAbsolutePath() );
+
+ File output = new File( getReportOutputDirectory(), buildReportFileName() );
+ prepReportFile( output );
+
+ DiffCreator diffCreator = new DiffCreator( options.isXincludeSupported(), getLog() );
+ Diff diff = diffCreator.findDiff( master, translation );
+
+ TranslationReportGenerator generator = new TranslationReportGenerator( sourceDirectory, getBundle( locale ), getLog() );
+ generator.generate( diff, output, locale.toString() );
+ }
+
+ class MasterTranslationLocator implements ArtifactProcessor {
+ private final String groupId = project.getGroupId();
+ private Artifact located;
+ public void process(Artifact artifact) {
+ if ( groupId.equals( artifact.getGroupId() ) && masterTranslationArtifactId.equals( artifact.getArtifactId() ) ) {
+ if ( located != null ) {
+ getLog().warn( "duplicate matching master found" );
+ }
+ located = artifact;
+ }
+ }
+ }
+
+ private void prepReportFile(File reportFile) throws GenerationException {
+ if ( reportFile.exists() ) {
+ reportFile.delete();
+ }
+ if ( !reportFile.exists() ) {
+ try {
+ reportFile.createNewFile();
+ }
+ catch ( IOException e ) {
+ throw new GenerationException( "unable to prep report file [" + reportFile.getAbsolutePath() + "]" );
+ }
+ }
+ }
+}
Copied: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/RenderingException.java (from rev 12660, sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/RenderingException.java)
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/RenderingException.java (rev 0)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/RenderingException.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -0,0 +1,31 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.docbook.gen;
+
+/**
+ * Indicates issues performing rendering.
+ *
+ * @author Steve Ebersole
+ */
+public class RenderingException extends Exception {
+ public RenderingException(String message) {
+ super( message );
+ }
+
+ public RenderingException(String message, Throwable cause) {
+ super( message, cause );
+ }
+}
Copied: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/XSLTException.java (from rev 12660, sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/XSLTException.java)
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/XSLTException.java (rev 0)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/XSLTException.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -0,0 +1,32 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.docbook.gen;
+
+/**
+ * Indicates problems either building XSLT transformers or performing
+ * transformations.
+ *
+ * @author Steve Ebersole
+ */
+public class XSLTException extends Exception {
+ public XSLTException(String message) {
+ super( message );
+ }
+
+ public XSLTException(String message, Throwable cause) {
+ super( message, cause );
+ }
+}
Copied: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/format/BasicFormatHandler.java (from rev 12660, sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/format/BasicFormatHandler.java)
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/format/BasicFormatHandler.java (rev 0)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/format/BasicFormatHandler.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -0,0 +1,215 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.docbook.gen.format;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stream.StreamResult;
+
+import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProjectHelper;
+import org.codehaus.plexus.archiver.ArchiverException;
+import org.codehaus.plexus.archiver.jar.JarArchiver;
+import org.codehaus.plexus.util.FileUtils;
+import org.jboss.maven.plugins.docbook.gen.RenderingException;
+import org.jboss.maven.plugins.docbook.gen.XSLTException;
+import org.jboss.maven.plugins.docbook.gen.util.Formatting;
+import org.jboss.maven.plugins.docbook.gen.util.ResourceHelper;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+/**
+ * Provides basic support for renderers, mainly in the form of templating.
+ *
+ * @author Steve Ebersole
+ */
+public class BasicFormatHandler implements FormatHandler {
+ public static final String DTD_VALIDATION_FEATURE = "http://xml.org/sax/features/validation";
+ public static final String DTD_LOADING_FEATURE = "http://apache.org/xml/features/nonvalidating/load-external-dtd";
+
+ protected final FormatHandlerFactory factory;
+ protected final Formatting formatting;
+
+ public BasicFormatHandler(FormatHandlerFactory factory, Formatting formatting) {
+ this.factory = factory;
+ this.formatting = formatting;
+ }
+
+ public File prepareDirectory() throws RenderingException {
+ File target = new File( factory.getTargetDirectory(), formatting.getFormatName() );
+ if ( ! target.exists() ) {
+ FileUtils.mkdir( target.getAbsolutePath() );
+ }
+ if ( formatting.isImageCopyingRequired() ) {
+ if ( factory.getStagingDirectory().exists() ) {
+ File imageBase = new File( factory.getStagingDirectory(), "images" );
+ if ( imageBase.exists() ) {
+ try {
+ FileUtils.copyDirectoryStructure( imageBase, target );
+ }
+ catch ( IOException e ) {
+ throw new RenderingException( "unable to copy images", e );
+ }
+ }
+ }
+ }
+ return target;
+ }
+
+ public void attachOutput(File sourceFile, MavenProjectHelper projectHelper) throws RenderingException {
+ File rawOutputDir = new File( factory.getTargetDirectory(), formatting.getFormatName() );
+
+ String warName = factory.getMavenProject().getBuild().getFinalName() +
+ "-" + formatting.getFormatName() + ".war";
+ File war = new File( factory.getTargetDirectory(), warName );
+
+ JarArchiver archiver = new JarArchiver();
+ archiver.setDestFile( war );
+ try {
+ archiver.addDirectory( rawOutputDir );
+ archiver.createArchive();
+ }
+ catch ( IOException e ) {
+ throw new RenderingException( "Unable to create archive [" + war.getAbsolutePath() + "]", e );
+ }
+ catch ( ArchiverException e ) {
+ throw new RenderingException( "Unable to populate archive [" + war.getAbsolutePath() + "]", e );
+ }
+
+ projectHelper.attachArtifact( factory.getMavenProject(), "war", formatting.getFormatName(), war );
+ }
+
+ public final void render(File sourceFile) throws RenderingException, XSLTException {
+ getLog().debug( "starting formatting [" + formatting.getFormatName() + "]" );
+
+ File target = prepareTarget( prepareDirectory(), sourceFile );
+
+ Transformer transformer = buildTransformer( target );
+ Source transformationSource = buildSource( sourceFile );
+ Result transformationResult = buildResult( target );
+ try {
+ transformer.transform( transformationSource, transformationResult );
+ }
+ catch ( TransformerException e ) {
+ throw new XSLTException( "unable to perform transformation", e );
+ }
+ finally {
+ releaseResult( transformationResult );
+ }
+ }
+
+ private File prepareTarget(File directory, File sourceFile) throws RenderingException {
+ String targetFileName = deduceTargetFileName( sourceFile );
+ getLog().debug( "preparing target file [" + targetFileName + "]" );
+ File target = new File( directory, targetFileName );
+ if ( target.exists() ) {
+ if ( !target.delete() ) {
+ getLog().warn( "unable to clean up previous output file [" + target.getAbsolutePath() + "]" );
+ }
+ }
+ if ( !target.exists() ) {
+ try {
+ target.createNewFile();
+ }
+ catch ( IOException e ) {
+ throw new RenderingException( "unable to create output file [" + target.getAbsolutePath() + "]", e );
+ }
+ }
+ return target;
+ }
+
+ private String deduceTargetFileName(File source) {
+ return formatting.getNamingStrategy().deduceTargetFileName( source );
+ }
+
+ protected Transformer buildTransformer(File targetFile) throws RenderingException, XSLTException {
+ final URL transformationStylesheet = resolveTransformationStylesheet();
+ Transformer transformer = factory.getTransformerFactory()
+ .buildTransformer( formatting, transformationStylesheet );
+ if ( formatting.isImagePathSettingRequired() ) {
+ String imgSrcPath = factory.getStagingDirectory().getAbsolutePath() + "/images/";
+ getLog().debug( "setting 'img.src.path' [" + imgSrcPath + "]" );
+ transformer.setParameter( "img.src.path", imgSrcPath );
+ }
+ if ( factory.getOptions().isUseRelativeImageUris() ) {
+ getLog().debug( "enforcing retention of relative image URIs" );
+ transformer.setParameter( "keep.relative.image.uris", "0" );
+ }
+ if ( formatting.isDoingChunking() ) {
+ getLog().debug( "Chunking output." );
+ String rootFilename = targetFile.getName();
+ rootFilename = rootFilename.substring( 0, rootFilename.lastIndexOf( '.' ) );
+ transformer.setParameter( "root.filename", rootFilename );
+ transformer.setParameter( "base.dir", targetFile.getParent() + File.separator );
+ transformer.setParameter( "manifest.in.base.dir", "1" );
+ }
+ return transformer;
+ }
+
+ protected final URL resolveTransformationStylesheet() throws RenderingException {
+ return ResourceHelper.requireResource( formatting.getStylesheetResource() );
+ }
+
+ private Source buildSource(File sourceFile) throws RenderingException {
+ try {
+ EntityResolver resolver = factory.getCatalogResolver();
+ SAXParserFactory factory = createParserFactory();
+ XMLReader reader = factory.newSAXParser().getXMLReader();
+ reader.setEntityResolver( resolver );
+
+ // Disable DTD loading and validation
+ reader.setFeature( DTD_LOADING_FEATURE, false );
+ reader.setFeature( DTD_VALIDATION_FEATURE, false );
+
+ return new SAXSource( reader, new InputSource( sourceFile.getAbsolutePath() ) );
+ }
+ catch ( ParserConfigurationException e ) {
+ throw new RenderingException( "unable to build SAX Parser", e );
+ }
+ catch ( SAXException e ) {
+ throw new RenderingException( "unable to build SAX Parser", e );
+ }
+ }
+
+ protected final SAXParserFactory createParserFactory() {
+ SAXParserFactory parserFactory = new SAXParserFactoryImpl();
+ parserFactory.setXIncludeAware( factory.getOptions().isXincludeSupported() );
+ return parserFactory;
+ }
+
+ protected Result buildResult(File targetFile) throws RenderingException, XSLTException {
+ return new StreamResult( targetFile );
+ }
+
+ protected void releaseResult(Result transformationResult) {
+ // typically nothing to do...
+ }
+
+ protected Log getLog() {
+ return factory.getLog();
+ }
+}
Copied: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/format/FormatHandler.java (from rev 12660, sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/format/FormatHandler.java)
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/format/FormatHandler.java (rev 0)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/format/FormatHandler.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -0,0 +1,60 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.docbook.gen.format;
+
+import java.io.File;
+
+import org.apache.maven.project.MavenProjectHelper;
+import org.jboss.maven.plugins.docbook.gen.RenderingException;
+import org.jboss.maven.plugins.docbook.gen.XSLTException;
+
+/**
+ * Handles format-specific processing steps.
+ *
+ * @author Steve Ebersole
+ */
+public interface FormatHandler {
+ /**
+ * This is used during the prepare-resources phase to create and prepare
+ * the format specific output directory for rendering. Generally,
+ * preparation might mean copying any format-specific resources to the
+ * format output directory.
+ *
+ * @return The format output directory
+ * @throws RenderingException Indicates problem preparing output directory
+ */
+ public File prepareDirectory() throws RenderingException;
+
+ /**
+ * Performs the actual rendering or transforming of the DocBook sources into
+ * the respective output format.
+ *
+ * @param source The source DocBook file.
+ * @throws RenderingException Problem writing the output file(s).
+ * @throws XSLTException Problem performing XSL transformation.
+ */
+ public void render(File source) throws RenderingException, XSLTException;
+
+ /**
+ * Attaches the formatting output (after possibly bundling it into an archive)
+ * to the maven project.
+ *
+ * @param sourceFile The source DocBook file.
+ * @param projectHelper The project helper (used to attach produced artifact)
+ * @throws RenderingException Indicates problem performing attaching
+ */
+ public void attachOutput(File sourceFile, MavenProjectHelper projectHelper) throws RenderingException;
+}
Copied: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/format/FormatHandlerFactory.java (from rev 12660, sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/format/FormatHandlerFactory.java)
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/format/FormatHandlerFactory.java (rev 0)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/format/FormatHandlerFactory.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -0,0 +1,128 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.docbook.gen.format;
+
+import java.io.File;
+
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.xml.resolver.CatalogManager;
+import org.apache.xml.resolver.tools.CatalogResolver;
+import org.jboss.maven.plugins.docbook.Options;
+import org.jboss.maven.plugins.docbook.gen.util.TransformerType;
+import org.jboss.maven.plugins.docbook.gen.util.StandardDocBookFormatSpecification;
+import org.jboss.maven.plugins.docbook.gen.util.Formatting;
+import org.jboss.maven.plugins.docbook.gen.xslt.TransformerFactory;
+import org.jboss.maven.plugins.docbook.gen.xslt.catalog.ExplicitCatalogManager;
+import org.jboss.maven.plugins.docbook.gen.xslt.catalog.ImplicitCatalogManager;
+
+/**
+ * Builds a renderer for the given format
+ *
+ * @author Steve Ebersole
+ */
+public class FormatHandlerFactory {
+ private final Options options;
+ private final File source;
+ private final File targetDirectory;
+ private final File stagingDirectory;
+ private final File fontConfig;
+ private final MavenProject mavenProject;
+ private final Log log;
+
+ private CatalogResolver catalogResolver;
+ private TransformerFactory transformerFactory;
+
+ public FormatHandlerFactory(
+ Options options,
+ File source,
+ File targetDirectory,
+ File stagingDirectory,
+ File fontConfig,
+ MavenProject mavenProject,
+ Log log) {
+ this.options = options;
+ this.source = source;
+ this.targetDirectory = targetDirectory;
+ this.stagingDirectory = stagingDirectory;
+ this.fontConfig = fontConfig;
+ this.mavenProject = mavenProject;
+ this.log = log;
+ }
+
+ public Options getOptions() {
+ return options;
+ }
+
+ public File getSource() {
+ return source;
+ }
+
+ public File getTargetDirectory() {
+ return targetDirectory;
+ }
+
+ public File getStagingDirectory() {
+ return stagingDirectory;
+ }
+
+ public File getFontConfig() {
+ return fontConfig;
+ }
+
+ public MavenProject getMavenProject() {
+ return mavenProject;
+ }
+
+ public Log getLog() {
+ return log;
+ }
+
+ public CatalogResolver getCatalogResolver() {
+ if ( catalogResolver == null ) {
+ CatalogManager catalogManager;
+ if ( options.getCatalogs() == null || options.getCatalogs().length == 0 ) {
+ catalogManager = new ImplicitCatalogManager();
+ }
+ else {
+ catalogManager = new ExplicitCatalogManager( options.getCatalogs() );
+ }
+ catalogResolver = new CatalogResolver( catalogManager );
+ }
+ return catalogResolver;
+ }
+
+ public TransformerFactory getTransformerFactory() {
+ if ( transformerFactory == null ) {
+ transformerFactory = new TransformerFactory(
+ TransformerType.parse( options.getXmlTransformerType() ),
+ options.getTransformerParameters(),
+ getCatalogResolver(),
+ options.getDocbookVersion()
+ );
+ }
+ return transformerFactory;
+ }
+
+ public FormatHandler buildFormatHandler(Formatting formatting) {
+ if ( formatting.getFormatName().equals( StandardDocBookFormatSpecification.PDF.getName() ) ) {
+ return new PdfFormatHandler( this, formatting );
+ }
+ else {
+ return new BasicFormatHandler( this, formatting );
+ }
+ }
+}
Copied: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/format/PdfFormatHandler.java (from rev 12660, sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/format/PdfFormatHandler.java)
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/format/PdfFormatHandler.java (rev 0)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/format/PdfFormatHandler.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -0,0 +1,175 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.docbook.gen.format;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import javax.xml.transform.Result;
+import javax.xml.transform.sax.SAXResult;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.fop.apps.Driver;
+import org.apache.fop.apps.FOPException;
+import org.apache.maven.plugin.logging.Log;
+import org.jboss.maven.plugins.docbook.gen.util.Formatting;
+import org.jboss.maven.plugins.docbook.gen.RenderingException;
+
+/**
+ * Special handling for pdf rendering
+ *
+ * @author Steve Ebersole
+ */
+public class PdfFormatHandler extends BasicFormatHandler {
+
+ public PdfFormatHandler(FormatHandlerFactory factory, Formatting formatting) {
+ super( factory, formatting );
+ }
+
+ protected Result buildResult(File targetFile) throws RenderingException {
+ getLog().info( "building formatting result [" + targetFile.getAbsolutePath() + "]" );
+ prepareFonts();
+ return new ResultImpl( targetFile );
+ }
+
+ private void prepareFonts() throws RenderingException {
+ // if fonts were specified, then prepare the FOP font metrics configuration
+ // : this is the piece that improved dramatically after fop-0.25,
+ // which unfortunately we are stuck with for other reasons :(
+ if ( factory.getFontConfig() != null ) {
+ org.apache.fop.configuration.Configuration.put( "fontBaseDir", new File( factory.getStagingDirectory(), "fonts" ) );
+ try {
+ new org.apache.fop.apps.Options( factory.getFontConfig() );
+ }
+ catch ( FOPException e ) {
+ throw new RenderingException( "unable to properly prepare FOP fonts", e );
+ }
+ org.apache.fop.configuration.Configuration.put( "fontBaseDir", new File( factory.getStagingDirectory(), "fonts" ) );
+ }
+ }
+
+ protected void releaseResult(Result transformationResult) {
+ ( ( ResultImpl ) transformationResult ).release();
+ }
+
+ private class ResultImpl extends SAXResult {
+ private OutputStream outputStream;
+
+ public ResultImpl(File targetFile) throws RenderingException {
+ Driver driver = new Driver();
+ driver.setLogger( new LoggingBridge( getLog() ) );
+ driver.setRenderer( Driver.RENDER_PDF );
+
+ try {
+ outputStream = new BufferedOutputStream( new FileOutputStream( targetFile ) );
+ driver.setOutputStream( outputStream );
+ setHandler( driver.getContentHandler() );
+ }
+ catch ( Throwable t ) {
+ throw new RenderingException( "error building transformation result [" + targetFile.getAbsolutePath() + "]", t );
+ }
+ }
+
+ private void release() {
+ try {
+ outputStream.flush();
+ outputStream.close();
+ }
+ catch ( IOException e ) {
+ getLog().warn( "error releasing I/O resources", e );
+ }
+ }
+ }
+
+ private static class LoggingBridge implements Logger {
+
+ private Log mavenLog;
+
+ public LoggingBridge(Log mavenLog) {
+ this.mavenLog = mavenLog;
+ }
+
+ public Logger getChildLogger(String arg0) {
+ return null;
+ }
+
+ public void debug(String arg0) {
+ mavenLog.debug( arg0 );
+ }
+
+ public void debug(String arg0, Throwable arg1) {
+ mavenLog.debug( arg0, arg1 );
+ }
+
+ // todo : info logging from FOP is excessively verbose...
+
+ public void info(String arg0) {
+ mavenLog.info( arg0 );
+ }
+
+ public void info(String arg0, Throwable arg1) {
+ mavenLog.info( arg0, arg1 );
+ }
+
+ public void warn(String arg0) {
+ mavenLog.warn( arg0 );
+ }
+
+ public void warn(String arg0, Throwable arg1) {
+ mavenLog.warn( arg0, arg1 );
+ }
+
+ public void error(String arg0) {
+ mavenLog.error( arg0 );
+ }
+
+ public void error(String arg0, Throwable arg1) {
+ mavenLog.error( arg0, arg1 );
+ }
+
+ public void fatalError(String arg0) {
+ mavenLog.error( arg0 );
+ }
+
+ public void fatalError(String arg0, Throwable arg1) {
+ mavenLog.error( arg0, arg1 );
+ }
+
+ public boolean isDebugEnabled() {
+ return mavenLog.isDebugEnabled();
+ }
+
+ public boolean isErrorEnabled() {
+ return mavenLog.isErrorEnabled();
+ }
+
+ public boolean isFatalErrorEnabled() {
+ return mavenLog.isErrorEnabled();
+ }
+
+ public boolean isInfoEnabled() {
+ return mavenLog.isInfoEnabled();
+ }
+
+ public boolean isWarnEnabled() {
+ return mavenLog.isWarnEnabled();
+ }
+
+ }
+
+}
Copied: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/util/Formatting.java (from rev 12660, sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/Formatting.java)
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/util/Formatting.java (rev 0)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/util/Formatting.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -0,0 +1,117 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.docbook.gen.util;
+
+import java.io.File;
+
+import org.codehaus.plexus.util.FileUtils;
+import org.jboss.maven.plugins.docbook.Format;
+
+/**
+ * Defined formatting information. Basically stuff to either pass into the xsl
+ * transformer or stuff needed to prepare for transformation.
+ *
+ * @author Steve Ebersole
+ */
+public class Formatting {
+ private final String formatName;
+ private final String stylesheetResource;
+ private final boolean imagePathSettingRequired;
+ private final boolean imageCopyingRequired;
+ private final boolean doingChunking;
+ private final StandardDocBookFormatSpecification standardDocBookSpec;
+ private final TargetNamingStrategy namingStrategy;
+
+ public Formatting(StandardDocBookFormatSpecification standardDocBookSpec, Format userSpec) {
+ // todo : there may not be a matching standard docbook format spec...
+ if ( ! standardDocBookSpec.getName().equals( userSpec.getFormatName() ) ) {
+ throw new IllegalArgumentException( "formatting type mismatch" );
+ }
+
+ this.standardDocBookSpec = standardDocBookSpec;
+ this.formatName = userSpec.getFormatName();
+
+ this.stylesheetResource = userSpec.getStylesheetResource() == null
+ ? standardDocBookSpec.getStylesheetResource()
+ : "/styles" + userSpec.getStylesheetResource();
+
+ this.imageCopyingRequired = userSpec.getImageCopyingRequired() == null
+ ? standardDocBookSpec.isImageCopyingRequired()
+ : userSpec.getImageCopyingRequired().booleanValue();
+
+ this.imagePathSettingRequired = userSpec.getImagePathSettingRequired() == null
+ ? standardDocBookSpec.isImagePathSettingRequired()
+ : userSpec.getImagePathSettingRequired().booleanValue();
+
+ this.doingChunking =userSpec.getDoingChunking() == null
+ ? standardDocBookSpec.isDoingChunking()
+ : userSpec.getDoingChunking().booleanValue();
+
+ this.namingStrategy = new TargetNamingStrategy( standardDocBookSpec, userSpec );
+ }
+
+ public String getFormatName() {
+ return formatName;
+ }
+
+ public StandardDocBookFormatSpecification getStandardDocBookSpec() {
+ return standardDocBookSpec;
+ }
+
+ public String getStylesheetResource() {
+ return stylesheetResource;
+ }
+
+ public boolean isImagePathSettingRequired() {
+ return imagePathSettingRequired;
+ }
+
+ public boolean isImageCopyingRequired() {
+ return imageCopyingRequired;
+ }
+
+ public boolean isDoingChunking() {
+ return doingChunking;
+ }
+
+ public TargetNamingStrategy getNamingStrategy() {
+ return namingStrategy;
+ }
+
+ public static class TargetNamingStrategy {
+ private String targetFileExtension;
+ private String finalName;
+
+ public TargetNamingStrategy(StandardDocBookFormatSpecification standardDocBookSpec, Format userSpec) {
+ if ( userSpec.getFinalName() != null ) {
+ this.targetFileExtension = null;
+ this.finalName = userSpec.getFinalName();
+ }
+ else {
+ this.targetFileExtension = userSpec.getTargetFileExtension() == null
+ ? standardDocBookSpec.getStandardFileExtension()
+ : userSpec.getTargetFileExtension();
+ this.finalName = null;
+ }
+ }
+
+ public String deduceTargetFileName(File source) {
+ return finalName == null
+ ? FileUtils.basename( source.getAbsolutePath() ) + targetFileExtension
+ : finalName;
+ }
+ }
+}
Copied: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/util/NoOpWriter.java (from rev 12660, sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/NoOpWriter.java)
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/util/NoOpWriter.java (rev 0)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/util/NoOpWriter.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -0,0 +1,35 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.docbook.gen.util;
+
+import java.io.Writer;
+
+/**
+ * A writer which does no writing :)
+ *
+ * @author Steve Ebersole
+ */
+public class NoOpWriter extends Writer {
+
+ public void write(char cbuf[], int off, int len) {
+ }
+
+ public void flush() {
+ }
+
+ public void close() {
+ }
+}
Copied: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/util/ResourceHelper.java (from rev 12660, sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/ResourceHelper.java)
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/util/ResourceHelper.java (rev 0)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/util/ResourceHelper.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -0,0 +1,41 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.docbook.gen.util;
+
+import java.net.URL;
+
+/**
+ * Simple helpers for locating and handling classpath resource lookups.
+ *
+ * @author Steve Ebersole
+ */
+public class ResourceHelper {
+ public static URL requireResource(String name) {
+ URL resource = locateResource( name );
+ if ( resource == null ) {
+ throw new IllegalArgumentException( "could not locate resource [" + name + "]" );
+ }
+ return resource;
+ }
+
+ public static URL locateResource(String name) {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if ( loader == null ) {
+ loader = ResourceHelper.class.getClassLoader();
+ }
+ return loader.getResource( name );
+ }
+}
Copied: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/util/StaleSourceChecker.java (from rev 12660, sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/StaleSourceChecker.java)
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/util/StaleSourceChecker.java (rev 0)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/util/StaleSourceChecker.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -0,0 +1,30 @@
+package org.jboss.maven.plugins.docbook.gen.util;
+
+import java.io.File;
+import java.util.Collections;
+
+import org.codehaus.plexus.compiler.util.scan.StaleSourceScanner;
+import org.codehaus.plexus.compiler.util.scan.InclusionScanException;
+import org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping;
+
+/**
+ * Delegate used for checking sources for staleness.
+ *
+ * @author Steve Ebersole
+ */
+public class StaleSourceChecker {
+ public static boolean hasStaleSources(File sourceDirectory, File databaseDirectory) {
+ try {
+ StaleSourceScanner scanner = new StaleSourceScanner(
+ 0,
+ Collections.singleton( "**/*.xml" ),
+ Collections.EMPTY_SET
+ );
+ scanner.addSourceMapping( new SuffixMapping( ".xml", ".xml.db" ) );
+ return ! scanner.getIncludedSources( sourceDirectory, databaseDirectory ).isEmpty();
+ }
+ catch ( InclusionScanException e ) {
+ throw new RuntimeException( "Error scanning sources in " + sourceDirectory, e );
+ }
+ }
+}
Copied: sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/util/StandardDocBookFormatSpecification.java (from rev 12660, sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/StandardDocBookFormatSpecification.java)
===================================================================
--- sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/util/StandardDocBookFormatSpecification.java (rev 0)
+++ sandbox/trunk/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugins/docbook/gen/util/StandardDocBookFormatSpecification.java 2007-07-02 13:53:27 UTC (rev 12662)
@@ -0,0 +1,148 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugins.docbook.gen.util;
+
+/**
+ * The basic definition of the standard docbook formats.
+ *
+ * @author Steve Ebersole
+ */
+public class StandardDocBookFormatSpecification {
+ public static final StandardDocBookFormatSpecification ECLIPSE =
+ new HtmlBasedStandardDocBookFormat( "eclipse", "/eclipse/eclipse.xsl" );
+
+ public static final StandardDocBookFormatSpecification HTML =
+ new HtmlBasedStandardDocBookFormat( "html", "/html/chunk.xsl" );
+
+ public static final StandardDocBookFormatSpecification HTML_SINGLE =
+ new HtmlBasedStandardDocBookFormat( "html_single", "/html/docbook.xsl", false );
+
+ public static final StandardDocBookFormatSpecification HTMLHELP =
+ new HtmlBasedStandardDocBookFormat( "htmlhelp", "/htmlhelp/htmlhelp.xsl" );
+
+ public static final StandardDocBookFormatSpecification JAVAHELP =
+ new HtmlBasedStandardDocBookFormat( "javahelp", "/javahelp/javahelp.xsl" );
+
+ public static final StandardDocBookFormatSpecification MAN =
+ new HtmlBasedStandardDocBookFormat( "man", "/manpages/docbook.xsl", false );
+
+ public static final StandardDocBookFormatSpecification PDF =
+ new StandardDocBookFormatSpecification( "pdf", "pdf", "/fo/docbook.xsl", true, false, false );
+
+ public static final StandardDocBookFormatSpecification WEBSITE =
+ new HtmlBasedStandardDocBookFormat( "website", "/website/website.xsl", false );
+
+// I'd rather not support this...
+// public static final FormatType WORDML =
+// new FormatType( "wordml", "doc", "/wordml/wordml.xsl", ?, ?, ? );
+
+ public static final StandardDocBookFormatSpecification XHTML =
+ new StandardDocBookFormatSpecification( "xhtml", "xhtml", "/xhtml/docbook.xsl", false, true, false );
+
+ private final String name;
+ private final String standardFileExtension;
+ private final String stylesheetResource;
+ private final boolean imagePathSettingRequired;
+ private final boolean imageCopyingRequired;
+ private final boolean doingChunking;
+
+ public StandardDocBookFormatSpecification(
+ String name,
+ String standardFileExtension,
+ String stylesheetResource,
+ boolean imagePathSettingRequired,
+ boolean imageCopyingRequired,
+ boolean doingChunking) {
+ this.name = name;
+ this.standardFileExtension = standardFileExtension;
+ this.stylesheetResource = stylesheetResource;
+ this.imagePathSettingRequired = imagePathSettingRequired;
+ this.imageCopyingRequired = imageCopyingRequired;
+ this.doingChunking = doingChunking;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getStandardFileExtension() {
+ return standardFileExtension;
+ }
+
+ public String getStylesheetResource() {
+ return stylesheetResource;
+ }
+
+ public boolean isImagePathSettingRequired() {
+ return imagePathSettingRequired;
+ }
+
+ public boolean isImageCopyingRequired() {
+ return imageCopyingRequired;
+ }
+
+ public boolean isDoingChunking() {
+ return doingChunking;
+ }
+
+ public static StandardDocBookFormatSpecification parse(String name) {
+ if ( ECLIPSE.name.equals( name ) ) {
+ return ECLIPSE;
+ }
+ else if ( HTML.name.equals( name ) ) {
+ return HTML;
+ }
+ else if ( HTML_SINGLE.name.equals( name ) ) {
+ return HTML_SINGLE;
+ }
+ else if ( HTMLHELP.name.equals( name ) ) {
+ return HTMLHELP;
+ }
+ else if ( JAVAHELP.name