Hibernate SVN: r11711 - trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-06-24 01:32:43 -0400 (Sun, 24 Jun 2007)
New Revision: 11711
Modified:
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/pom.xml
Log:
still more prep move to codehaus
Modified: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/pom.xml
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/pom.xml 2007-06-24 05:32:19 UTC (rev 11710)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/pom.xml 2007-06-24 05:32:43 UTC (rev 11711)
@@ -114,6 +114,11 @@
<version>1.0-alpha-7</version>
</dependency>
<dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-compiler-api</artifactId>
+ <version>1.5.3</version>
+ </dependency>
+ <dependency>
<groupId>avalon-framework</groupId>
<artifactId>avalon-framework</artifactId>
<version>4.1.5</version>
17 years, 5 months
Hibernate SVN: r11710 - in trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook: gen/util and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-06-24 01:32:19 -0400 (Sun, 24 Jun 2007)
New Revision: 11710
Added:
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/OLinkDBUpdater.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/NoOpWriter.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/StaleSourceChecker.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/TransformerFactory.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/BasicUrnResolver.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/CurrentVersionResolver.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/ExplicitUrnResolver.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/RelativeJarUriResolver.java
Log:
still more prep move to codehaus
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/OLinkDBUpdater.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/OLinkDBUpdater.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/OLinkDBUpdater.java 2007-06-24 05:32:19 UTC (rev 11710)
@@ -0,0 +1,277 @@
+/*
+ * maven-docbook-plugin - Copyright (C) 2005 OPEN input - http://www.openinput.com/
+ *
+ * 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.
+ */
+package org.codehaus.mojo.docbook;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+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.codehaus.plexus.compiler.util.scan.InclusionScanException;
+import org.codehaus.plexus.compiler.util.scan.StaleSourceScanner;
+import org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping;
+import org.codehaus.plexus.util.DirectoryScanner;
+
+/**
+ * @author jgonzalez
+ */
+public class OLinkDBUpdater
+{
+ // todo (steve) : make this a mojo, and assign it a phase in the lifecycle...
+ protected Log log;
+ protected File sourceDirectory;
+ protected File databaseDirectory;
+
+ public OLinkDBUpdater(Log log, File sourceDirectory, File databaseDirectory)
+ {
+ this.log = log;
+ this.sourceDirectory = sourceDirectory;
+ this.databaseDirectory = databaseDirectory;
+ }
+
+ public void update()
+ {
+ StaleSourceScanner scanner = new StaleSourceScanner( 0, Collections.singleton( "**/*.xml" ),
+ Collections.EMPTY_SET );
+ scanner.addSourceMapping( new SuffixMapping( ".xml", ".xml.db" ) );
+
+ Set staleDocbookFiles;
+ try
+ {
+ staleDocbookFiles = scanner.getIncludedSources( this.sourceDirectory, this.databaseDirectory );
+ }
+ catch ( InclusionScanException e )
+ {
+ throw new RuntimeException( "Error scanning sources in " + sourceDirectory, e );
+ }
+
+ if ( !staleDocbookFiles.isEmpty() )
+ {
+ DirectoryScanner docbookScanner = new DirectoryScanner();
+ docbookScanner.setBasedir( this.sourceDirectory );
+ docbookScanner.setFollowSymlinks( true );
+ docbookScanner.setIncludes( new String[] { "**/*.xml" } );
+ docbookScanner.scan();
+ String[] docbookFiles = docbookScanner.getIncludedFiles();
+
+ this.prepareFileSystem( docbookFiles );
+ this.updateOLinkDatabase( staleDocbookFiles );
+ this.createMasterOLinkDatabase( docbookFiles );
+ }
+ else
+ {
+ this.log.info( "olink database up to date" );
+ }
+ }
+
+ protected void prepareFileSystem( String[] docbookFiles )
+ {
+ log.debug( "Creating database directories for the following files - "
+ + Arrays.asList( docbookFiles ).toString() );
+ // TODO: This should be a bit smarter also, shouldn't it?
+ for ( int fileIndex = 0; fileIndex < docbookFiles.length; fileIndex++ )
+ {
+ String docbookFile = docbookFiles[fileIndex];
+ int lastFileSeparator = docbookFile.lastIndexOf( File.separator );
+ if ( lastFileSeparator > 0 )
+ {
+ File directory = new File( this.databaseDirectory, docbookFile.substring( 0, lastFileSeparator ) );
+ directory.mkdirs();
+ }
+ }
+ }
+
+ protected void updateOLinkDatabase( Set docbookFiles )
+ {
+ this.log.info( "Loading olink database generation stylesheet" );
+ Source docbookStyleSheetSource = new StreamSource(
+ ResourceHelper.requireResource(
+ StandardDocBookFormatSpecification.XHTML.getStylesheetResource()
+ ).toString()
+ );
+ Transformer olinkDBGenerator;
+ try
+ {
+ TransformerFactory factory = TransformerFactory.newInstance();
+ olinkDBGenerator = factory.newTransformer( docbookStyleSheetSource );
+ }
+ catch ( TransformerException e )
+ {
+ throw new RuntimeException( "Unable to get a transformer instance from source " + docbookStyleSheetSource.getSystemId(), e );
+ }
+ olinkDBGenerator.setParameter( "collect.xref.targets", "only" );
+ olinkDBGenerator.setParameter( "generate.toc", "" );
+
+ this.log.info( "Creating olink database for " + docbookFiles.size() + " Docbook stale file(s)" );
+ Iterator filesIterator = docbookFiles.iterator();
+ while ( filesIterator.hasNext() )
+ {
+ File docbookFile = (File) filesIterator.next();
+ this.log.debug( "Processing " + this.sourceDirectory + File.separator + docbookFile );
+
+ String relativePath = docbookFile.getAbsolutePath().substring( this.sourceDirectory.getAbsolutePath().length() );
+ File databaseFile = new File( this.databaseDirectory, relativePath + ".db" );
+ Source source = new StreamSource( docbookFile );
+ Result result = new StreamResult( new NoOpWriter() );
+
+ olinkDBGenerator.setParameter( "targets.filename", databaseFile.getAbsolutePath() );
+
+ try
+ {
+ olinkDBGenerator.transform( source, result );
+ }
+ catch ( TransformerException e )
+ {
+ throw new RuntimeException( "Unable to transform from source " + source.getSystemId() + " into " + result.getSystemId(), e );
+ }
+
+ this.log.debug( "Generated " + this.databaseDirectory + File.separator + docbookFile );
+ }
+ }
+
+ protected void createMasterOLinkDatabase( String[] docbookFiles )
+ {
+ File file = new File( this.databaseDirectory + System.getProperty( "file.separator" ) + "olinkdb.xml" );
+ this.log.info( "Creating master olink database file " + file );
+ try
+ {
+ BufferedWriter masterOlinkDBFile = new BufferedWriter( new FileWriter( file ));
+
+ // Write header
+ masterOlinkDBFile.write( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" );
+ masterOlinkDBFile.newLine();
+ masterOlinkDBFile.write( "<!DOCTYPE targetset SYSTEM \"" );
+// masterOlinkDBFile.write( this.stylesheetLocation.resolve( "common/targetdatabase.dtd" ).toString() );
+ masterOlinkDBFile.write( "\" >" );
+ masterOlinkDBFile.newLine();
+
+ masterOlinkDBFile.write( "<targetset>" );
+ masterOlinkDBFile.newLine();
+ masterOlinkDBFile.write( " <sitemap>" );
+ masterOlinkDBFile.newLine();
+ masterOlinkDBFile.write( " <dir name=\"root\">" );
+ masterOlinkDBFile.newLine();
+
+ this.writeDirectoryTagBody( masterOlinkDBFile, 1, "", docbookFiles );
+
+ masterOlinkDBFile.write( " </dir>" );
+ masterOlinkDBFile.newLine();
+ masterOlinkDBFile.write( " </sitemap>" );
+ masterOlinkDBFile.newLine();
+ masterOlinkDBFile.write( "</targetset>" );
+ masterOlinkDBFile.newLine();
+
+ masterOlinkDBFile.close();
+ }
+ catch ( IOException e )
+ {
+ throw new RuntimeException( "Error creating OLink database " + file, e );
+ }
+ }
+
+ protected void writeDirectoryTagBody( BufferedWriter writer, int level, String currentDirectory, String[] files )
+ throws IOException
+ {
+ int currentDirectoryLength = currentDirectory.length();
+ String lastRelativeDirectory = "";
+ List subdirectory = new LinkedList();
+
+ for ( int fileIndex = 0; fileIndex < files.length; fileIndex++ )
+ {
+ String file = files[fileIndex];
+ String relativeFile = file.substring( currentDirectoryLength );
+ if ( relativeFile.indexOf( File.separator ) == -1 )
+ {
+ String fileID = OLinkDBUpdater.computeFileID( file );
+ writer.write( OLinkDBUpdater.indenting( level ) + "<document targetdoc=\"" );
+ writer.write( fileID );
+ writer.write( "\" baseuri=\"" );
+ writer.write( relativeFile.substring( 0, relativeFile.lastIndexOf( "." ) ) + ".html\">" );
+ writer.write( "<xi:include xmlns:xi=\"http://www.w3.org/2003/XInclude\" href=\"" );
+ writer.write( file.replace( File.separatorChar, '/' ) + ".db\"/>" );
+ writer.write( "</document>" );
+ writer.newLine();
+ }
+ else
+ {
+ String relativeDirectory = relativeFile.substring( 0, relativeFile.indexOf( File.separator ) );
+ if ( !relativeDirectory.equals( lastRelativeDirectory ) )
+ {
+ if ( !subdirectory.isEmpty() )
+ {
+ writer.write( OLinkDBUpdater.indenting( level ) + "<dir name=\"" + lastRelativeDirectory
+ + "\">" );
+ writer.newLine();
+ this.writeDirectoryTagBody( writer, level + 1, currentDirectory + File.separator
+ + lastRelativeDirectory, (String[]) subdirectory.toArray( new String[ subdirectory.size() ] ) );
+ writer.write( OLinkDBUpdater.indenting( level ) + "</dir>" );
+ writer.newLine();
+ }
+ lastRelativeDirectory = relativeDirectory;
+ subdirectory.clear();
+ }
+ subdirectory.add( file );
+ }
+ }
+
+ if ( !subdirectory.isEmpty() )
+ {
+ writer.write( OLinkDBUpdater.indenting( level ) + "<dir name=\"" + lastRelativeDirectory + "\">" );
+ writer.newLine();
+ this.writeDirectoryTagBody( writer, level + 1, currentDirectory + File.separator + lastRelativeDirectory,
+ (String[]) subdirectory.toArray( new String[ subdirectory.size() ] ) );
+ writer.write( OLinkDBUpdater.indenting( level ) + "</dir>" );
+ writer.newLine();
+ }
+ }
+
+ public static String computeFileID( String docbookFileName )
+ {
+ String fileID = docbookFileName;
+ if ( docbookFileName.indexOf( File.separator ) == 0 )
+ {
+ fileID = docbookFileName.substring( File.separator.length() );
+ }
+
+ return fileID.replace( File.separatorChar, '-' );
+ }
+
+ protected static String indenting( int level )
+ {
+ StringBuffer indent = new StringBuffer( " " );
+ for ( int currentLevel = 1; currentLevel < level; currentLevel++ )
+ {
+ indent.append( " " );
+ }
+ return indent.toString();
+ }
+
+}
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/NoOpWriter.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/NoOpWriter.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/NoOpWriter.java 2007-06-24 05:32:19 UTC (rev 11710)
@@ -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.codehaus.mojo.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() {
+ }
+}
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/StaleSourceChecker.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/StaleSourceChecker.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/StaleSourceChecker.java 2007-06-24 05:32:19 UTC (rev 11710)
@@ -0,0 +1,30 @@
+package org.codehaus.mojo.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 );
+ }
+ }
+}
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/TransformerFactory.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/TransformerFactory.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/TransformerFactory.java 2007-06-24 05:32:19 UTC (rev 11710)
@@ -0,0 +1,139 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.codehaus.mojo.docbook.gen.xslt;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.stream.StreamSource;
+
+import com.icl.saxon.Controller;
+import org.apache.xml.resolver.tools.CatalogResolver;
+import org.codehaus.mojo.docbook.gen.XSLTException;
+import org.codehaus.mojo.docbook.gen.util.Formatting;
+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.codehaus.mojo.docbook.gen.util.TransformerType;
+import org.codehaus.mojo.docbook.gen.xslt.resolve.CurrentVersionResolver;
+import org.codehaus.mojo.docbook.gen.xslt.resolve.ExplicitUrnResolver;
+import org.codehaus.mojo.docbook.gen.xslt.resolve.RelativeJarUriResolver;
+import org.codehaus.mojo.docbook.gen.xslt.resolve.ResolverChain;
+import org.codehaus.mojo.docbook.gen.xslt.resolve.VersionResolver;
+
+/**
+ * A factory for {@link javax.xml.transform.Transformer} instances, configurable
+ * to return either SAXON or XALAN based transformers.
+ *
+ * @author Steve Ebersole
+ */
+public class TransformerFactory {
+ private final TransformerType transformerType;
+ private final Properties transformerParameters;
+ private final CatalogResolver catalogResolver;
+ private final String docbookVersion;
+
+ public TransformerFactory(
+ TransformerType transformerType,
+ Properties transformerParameters,
+ CatalogResolver catalogResolver,
+ String docbookVersion) {
+ this.transformerType = transformerType;
+ this.transformerParameters = transformerParameters;
+ this.catalogResolver = catalogResolver;
+ this.docbookVersion = docbookVersion;
+ }
+
+ public Transformer buildTransformer(Formatting formatting, URL customStylesheet) throws XSLTException {
+ URIResolver uriResolver = buildUriResolver( formatting.getStandardDocBookSpec() );
+
+ javax.xml.transform.TransformerFactory transformerFactory = buildTransformerFactory();
+ transformerFactory.setURIResolver( uriResolver );
+
+ URL xsltStylesheet = customStylesheet == null
+ ? ResourceHelper.requireResource( formatting.getStylesheetResource() )
+ : customStylesheet;
+
+ Transformer transformer;
+ try {
+ Source source = new StreamSource( xsltStylesheet.openStream(), xsltStylesheet.toExternalForm() );
+ transformer = transformerFactory.newTransformer( source );
+ }
+ catch ( IOException e ) {
+ throw new XSLTException( "problem opening stylesheet", e );
+ }
+ catch ( TransformerConfigurationException e ) {
+ throw new XSLTException( "unable to build transformer", e );
+ }
+
+ transformer.setURIResolver( uriResolver );
+ applyParameters( transformer );
+
+ if ( transformer instanceof Controller ) {
+ Controller controller = ( Controller ) transformer;
+ try {
+ controller.makeMessageEmitter();
+ controller.getMessageEmitter().setWriter( new NoOpWriter() );
+ }
+ catch ( TransformerException te ) {
+ // intentionally empty
+ }
+ }
+ return transformer;
+ }
+
+ private javax.xml.transform.TransformerFactory buildTransformerFactory() {
+ if ( transformerType == TransformerType.XALAN ) {
+ return new com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl();
+ }
+ else {
+ // saxon as default...
+ return new com.icl.saxon.TransformerFactoryImpl();
+ }
+ }
+
+ private void applyParameters(Transformer transformer) {
+ if ( transformerParameters == null ) {
+ return;
+ }
+ Iterator itr = transformerParameters.entrySet().iterator();
+ while ( itr.hasNext() ) {
+ final Map.Entry entry = ( Map.Entry ) itr.next();
+ transformer.setParameter( ( String ) entry.getKey(), entry.getValue() );
+ }
+ }
+
+ public URIResolver buildUriResolver(StandardDocBookFormatSpecification formatType) throws XSLTException {
+ ResolverChain resolverChain = new ResolverChain();
+ if ( formatType != null ) {
+ resolverChain.addResolver( new ExplicitUrnResolver( formatType ) );
+ }
+ resolverChain.addResolver( new CurrentVersionResolver() );
+ if ( docbookVersion != null ) {
+ resolverChain.addResolver( new VersionResolver( docbookVersion ) );
+ }
+ resolverChain.addResolver( new RelativeJarUriResolver() );
+ resolverChain.addResolver( catalogResolver );
+ return resolverChain;
+ }
+}
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/BasicUrnResolver.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/BasicUrnResolver.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/BasicUrnResolver.java 2007-06-24 05:32:19 UTC (rev 11710)
@@ -0,0 +1,44 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.codehaus.mojo.docbook.gen.xslt.resolve;
+
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
+
+/**
+ * Basic support for URIResolvers which map a URN unto a single replacement
+ * {@link Source}.
+ *
+ * @author Steve Ebersole
+ */
+public class BasicUrnResolver implements URIResolver {
+ private final String urn;
+ private final Source source;
+
+ public BasicUrnResolver(String urn, Source source) {
+ this.urn = urn;
+ this.source = source;
+ }
+
+ public Source resolve(String href, String base) throws TransformerException {
+ return urn.equals( href ) ? source : null;
+ }
+
+ public String toString() {
+ return super.toString() + " [URN:" + urn + "]";
+ }
+}
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/CurrentVersionResolver.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/CurrentVersionResolver.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/CurrentVersionResolver.java 2007-06-24 05:32:19 UTC (rev 11710)
@@ -0,0 +1,29 @@
+/*
+ * 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.gen.xslt.resolve;
+
+/**
+ * Map hrefs starting with <tt>http://docbook.sourceforge.net/release/xsl/current/</tt>
+ * to classpath resource lookups.
+ *
+ * @author Steve Ebersole
+ */
+public class CurrentVersionResolver extends VersionResolver {
+
+ public CurrentVersionResolver() {
+ super( "current" );
+ }
+}
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/ExplicitUrnResolver.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/ExplicitUrnResolver.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/ExplicitUrnResolver.java 2007-06-24 05:32:19 UTC (rev 11710)
@@ -0,0 +1,55 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.codehaus.mojo.docbook.gen.xslt.resolve;
+
+import java.io.IOException;
+import java.net.URL;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+
+import org.codehaus.mojo.docbook.gen.XSLTException;
+import org.codehaus.mojo.docbook.gen.util.ResourceHelper;
+import org.codehaus.mojo.docbook.gen.util.StandardDocBookFormatSpecification;
+
+
+/**
+ * Resolves an explicit <tt>urn:docbook:stylesheet</tt> URN against the standard
+ * DocBook stylesheets.
+ *
+ * @author Steve Ebersole
+ */
+public class ExplicitUrnResolver extends BasicUrnResolver {
+ private final StandardDocBookFormatSpecification formatType;
+
+ public ExplicitUrnResolver(StandardDocBookFormatSpecification type) throws XSLTException {
+ super( "urn:docbook:stylesheet", createSource( type ) );
+ this.formatType = type;
+ }
+
+ private static Source createSource(StandardDocBookFormatSpecification type) throws XSLTException {
+ URL stylesheet = ResourceHelper.requireResource( type.getStylesheetResource() );
+ try {
+ return new StreamSource( stylesheet.openStream(), stylesheet.toExternalForm() );
+ }
+ catch ( IOException e ) {
+ throw new XSLTException( "could not locate DocBook stylesheet [" + type.getName() + "]", e );
+ }
+ }
+
+ public String toString() {
+ return super.toString() + " [" + formatType.getName() + "]";
+ }
+}
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/RelativeJarUriResolver.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/RelativeJarUriResolver.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/RelativeJarUriResolver.java 2007-06-24 05:32:19 UTC (rev 11710)
@@ -0,0 +1,51 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.codehaus.mojo.docbook.gen.xslt.resolve;
+
+import java.net.URL;
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.stream.StreamSource;
+
+/**
+ * Responsible for resolving relative references from jar base urls.
+ *
+ * @author Steve Ebersole
+ */
+public class RelativeJarUriResolver implements URIResolver {
+ public Source resolve(String href, String base) throws TransformerException {
+ // href need to be relative
+ if ( href.indexOf( "://" ) > 0 || href.startsWith( "/" ) ) {
+ return null;
+ }
+
+ // base would need to start with jar:
+ if ( !base.startsWith( "jar:" ) ) {
+ return null;
+ }
+
+ String fullHref = base.substring( 4, base.lastIndexOf( '/' ) + 1 )
+ + href;
+ try {
+ URL url = new URL( fullHref );
+ return new StreamSource( url.openStream(), url.toExternalForm() );
+ }
+ catch ( Throwable t ) {
+ return null;
+ }
+ }
+}
17 years, 5 months
Hibernate SVN: r11709 - trunk/sandbox/maven-poc/plugins.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-06-24 00:40:22 -0400 (Sun, 24 Jun 2007)
New Revision: 11709
Removed:
trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/
Log:
merged into docbook plugin as part of prep for move to codehaus
17 years, 5 months
Hibernate SVN: r11708 - in trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook: gen and 5 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-06-24 00:38:15 -0400 (Sun, 24 Jun 2007)
New Revision: 11708
Added:
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/AbstractDocBookMojo.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/DocBookSupportResourcesMojo.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/Format.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/GenerationMojo.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/Options.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/PackageMojo.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/ResourceMojo.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/TranslationDiffReport.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/RenderingException.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/XSLTException.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/format/
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/format/BasicFormatHandler.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/format/FormatHandler.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/format/FormatHandlerFactory.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/format/PdfFormatHandler.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/Formatting.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/ResourceHelper.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/StandardDocBookFormatSpecification.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/TransformerType.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/catalog/
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/catalog/AbstractCatalogManager.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/catalog/ExplicitCatalogManager.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/catalog/ImplicitCatalogManager.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/ResolverChain.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/VersionResolver.java
Log:
more prep move to codehaus
Copied: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/AbstractDocBookMojo.java (from rev 11701, trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/AbstractDocBookMojo.java)
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/AbstractDocBookMojo.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/AbstractDocBookMojo.java 2007-06-24 04:38:15 UTC (rev 11708)
@@ -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.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() );
+ }
+ }
+}
Copied: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/DocBookSupportResourcesMojo.java (from rev 11704, trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/DocBookSupportResourcesMojo.java)
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/DocBookSupportResourcesMojo.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/DocBookSupportResourcesMojo.java 2007-06-24 04:38:15 UTC (rev 11708)
@@ -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.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 );
+ }
+ }
+}
Copied: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/Format.java (from rev 11700, trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/Format.java)
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/Format.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/Format.java 2007-06-24 04:38:15 UTC (rev 11708)
@@ -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.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;
+ }
+}
Copied: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/GenerationMojo.java (from rev 11704, trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/GenerationMojo.java)
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/GenerationMojo.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/GenerationMojo.java 2007-06-24 04:38:15 UTC (rev 11708)
@@ -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.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 );
+ }
+ }
+
+}
Copied: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/Options.java (from rev 11701, trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/Options.java)
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/Options.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/Options.java 2007-06-24 04:38:15 UTC (rev 11708)
@@ -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.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;
+ }
+}
Copied: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/PackageMojo.java (from rev 11704, trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/PackageMojo.java)
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/PackageMojo.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/PackageMojo.java 2007-06-24 04:38:15 UTC (rev 11708)
@@ -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.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 );
+ }
+ }
+}
Copied: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/ResourceMojo.java (from rev 11704, trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/ResourceMojo.java)
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/ResourceMojo.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/ResourceMojo.java 2007-06-24 04:38:15 UTC (rev 11708)
@@ -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.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 );
+ }
+ }
+}
Copied: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/TranslationDiffReport.java (from rev 11701, trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/TranslationDiffReport.java)
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/TranslationDiffReport.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/TranslationDiffReport.java 2007-06-24 04:38:15 UTC (rev 11708)
@@ -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.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: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/RenderingException.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/RenderingException.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/RenderingException.java 2007-06-24 04:38:15 UTC (rev 11708)
@@ -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.codehaus.mojo.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 );
+ }
+}
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/XSLTException.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/XSLTException.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/XSLTException.java 2007-06-24 04:38:15 UTC (rev 11708)
@@ -0,0 +1,33 @@
+/*
+ * 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.gen;
+
+/**
+ * Indicates problems either building XSLT transformers or performing
+ * transformations.
+ *
+ * @author Steve Ebersole
+ */
+public class XSLTException extends Exception {
+
+ public XSLTException(String message) {
+ super( message );
+ }
+
+ public XSLTException(String message, Throwable cause) {
+ super( message, cause );
+ }
+}
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/format/BasicFormatHandler.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/format/BasicFormatHandler.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/format/BasicFormatHandler.java 2007-06-24 04:38:15 UTC (rev 11708)
@@ -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.codehaus.mojo.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.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.ResourceHelper;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+/**
+ * Provides basic support for renderers, mainly in the form of templating.
+ *
+ * @author Steve Ebersole
+ */
+public class BasicFormatHandler implements FormatHandler {
+ public static final String DTD_VALIDATION_FEATURE = "http://xml.org/sax/features/validation";
+ public static final String DTD_LOADING_FEATURE = "http://apache.org/xml/features/nonvalidating/load-external-dtd";
+
+ protected final FormatHandlerFactory factory;
+ protected final Formatting formatting;
+
+ public BasicFormatHandler(FormatHandlerFactory factory, Formatting formatting) {
+ this.factory = factory;
+ this.formatting = formatting;
+ }
+
+ public File prepareDirectory() throws RenderingException {
+ File target = new File( factory.getTargetDirectory(), formatting.getFormatName() );
+ if ( ! target.exists() ) {
+ FileUtils.mkdir( target.getAbsolutePath() );
+ }
+ if ( formatting.isImageCopyingRequired() ) {
+ if ( factory.getStagingDirectory().exists() ) {
+ File imageBase = new File( factory.getStagingDirectory(), "images" );
+ if ( imageBase.exists() ) {
+ try {
+ FileUtils.copyDirectoryStructure( imageBase, target );
+ }
+ catch ( IOException e ) {
+ throw new RenderingException( "unable to copy images", e );
+ }
+ }
+ }
+ }
+ return target;
+ }
+
+ public void attachOutput(File sourceFile, MavenProjectHelper projectHelper) throws RenderingException {
+ File rawOutputDir = new File( factory.getTargetDirectory(), formatting.getFormatName() );
+
+ String warName = factory.getMavenProject().getBuild().getFinalName() +
+ "-" + formatting.getFormatName() + ".war";
+ File war = new File( factory.getTargetDirectory(), warName );
+
+ JarArchiver archiver = new JarArchiver();
+ archiver.setDestFile( war );
+ try {
+ archiver.addDirectory( rawOutputDir );
+ archiver.createArchive();
+ }
+ catch ( IOException e ) {
+ throw new RenderingException( "Unable to create archive [" + war.getAbsolutePath() + "]", e );
+ }
+ catch ( ArchiverException e ) {
+ throw new RenderingException( "Unable to populate archive [" + war.getAbsolutePath() + "]", e );
+ }
+
+ projectHelper.attachArtifact( factory.getMavenProject(), "war", formatting.getFormatName(), war );
+ }
+
+ public final void render(File sourceFile) throws RenderingException, XSLTException {
+ getLog().debug( "starting formatting [" + formatting.getFormatName() + "]" );
+
+ File target = prepareTarget( prepareDirectory(), sourceFile );
+
+ Transformer transformer = buildTransformer( target );
+ Source transformationSource = buildSource( sourceFile );
+ Result transformationResult = buildResult( target );
+ try {
+ transformer.transform( transformationSource, transformationResult );
+ }
+ catch ( TransformerException e ) {
+ throw new XSLTException( "unable to perform transformation", e );
+ }
+ finally {
+ releaseResult( transformationResult );
+ }
+ }
+
+ private File prepareTarget(File directory, File sourceFile) throws RenderingException {
+ String targetFileName = deduceTargetFileName( sourceFile );
+ getLog().debug( "preparing target file [" + targetFileName + "]" );
+ File target = new File( directory, targetFileName );
+ if ( target.exists() ) {
+ if ( !target.delete() ) {
+ getLog().warn( "unable to clean up previous output file [" + target.getAbsolutePath() + "]" );
+ }
+ }
+ if ( !target.exists() ) {
+ try {
+ target.createNewFile();
+ }
+ catch ( IOException e ) {
+ throw new RenderingException( "unable to create output file [" + target.getAbsolutePath() + "]", e );
+ }
+ }
+ return target;
+ }
+
+ private String deduceTargetFileName(File source) {
+ return formatting.getNamingStrategy().deduceTargetFileName( source );
+ }
+
+ protected Transformer buildTransformer(File targetFile) throws RenderingException, XSLTException {
+ final URL transformationStylesheet = resolveTransformationStylesheet();
+ Transformer transformer = factory.getTransformerFactory()
+ .buildTransformer( formatting, transformationStylesheet );
+ if ( formatting.isImagePathSettingRequired() ) {
+ String imgSrcPath = factory.getStagingDirectory().getAbsolutePath() + "/images/";
+ getLog().debug( "setting 'img.src.path' [" + imgSrcPath + "]" );
+ transformer.setParameter( "img.src.path", imgSrcPath );
+ }
+ if ( factory.getOptions().isUseRelativeImageUris() ) {
+ getLog().debug( "enforcing retention of relative image URIs" );
+ transformer.setParameter( "keep.relative.image.uris", "0" );
+ }
+ if ( formatting.isDoingChunking() ) {
+ getLog().debug( "Chunking output." );
+ String rootFilename = targetFile.getName();
+ rootFilename = rootFilename.substring( 0, rootFilename.lastIndexOf( '.' ) );
+ transformer.setParameter( "root.filename", rootFilename );
+ transformer.setParameter( "base.dir", targetFile.getParent() + File.separator );
+ transformer.setParameter( "manifest.in.base.dir", "1" );
+ }
+ return transformer;
+ }
+
+ protected final URL resolveTransformationStylesheet() throws RenderingException {
+ return ResourceHelper.requireResource( formatting.getStylesheetResource() );
+ }
+
+ private Source buildSource(File sourceFile) throws RenderingException {
+ try {
+ EntityResolver resolver = factory.getCatalogResolver();
+ SAXParserFactory factory = createParserFactory();
+ XMLReader reader = factory.newSAXParser().getXMLReader();
+ reader.setEntityResolver( resolver );
+
+ // Disable DTD loading and validation
+ reader.setFeature( DTD_LOADING_FEATURE, false );
+ reader.setFeature( DTD_VALIDATION_FEATURE, false );
+
+ return new SAXSource( reader, new InputSource( sourceFile.getAbsolutePath() ) );
+ }
+ catch ( ParserConfigurationException e ) {
+ throw new RenderingException( "unable to build SAX Parser", e );
+ }
+ catch ( SAXException e ) {
+ throw new RenderingException( "unable to build SAX Parser", e );
+ }
+ }
+
+ protected final SAXParserFactory createParserFactory() {
+ SAXParserFactory parserFactory = new SAXParserFactoryImpl();
+ parserFactory.setXIncludeAware( factory.getOptions().isXincludeSupported() );
+ return parserFactory;
+ }
+
+ protected Result buildResult(File targetFile) throws RenderingException, XSLTException {
+ return new StreamResult( targetFile );
+ }
+
+ protected void releaseResult(Result transformationResult) {
+ // typically nothing to do...
+ }
+
+ protected Log getLog() {
+ return factory.getLog();
+ }
+}
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/format/FormatHandler.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/format/FormatHandler.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/format/FormatHandler.java 2007-06-24 04:38:15 UTC (rev 11708)
@@ -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.codehaus.mojo.docbook.gen.format;
+
+import java.io.File;
+
+import org.apache.maven.project.MavenProjectHelper;
+import org.codehaus.mojo.docbook.gen.RenderingException;
+import org.codehaus.mojo.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;
+}
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/format/FormatHandlerFactory.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/format/FormatHandlerFactory.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/format/FormatHandlerFactory.java 2007-06-24 04:38:15 UTC (rev 11708)
@@ -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.codehaus.mojo.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.codehaus.mojo.docbook.Options;
+import org.codehaus.mojo.docbook.gen.util.StandardDocBookFormatSpecification;
+import org.codehaus.mojo.docbook.gen.util.TransformerType;
+import org.codehaus.mojo.docbook.gen.util.Formatting;
+import org.codehaus.mojo.docbook.gen.xslt.TransformerFactory;
+import org.codehaus.mojo.docbook.gen.xslt.catalog.ExplicitCatalogManager;
+import org.codehaus.mojo.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 );
+ }
+ }
+}
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/format/PdfFormatHandler.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/format/PdfFormatHandler.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/format/PdfFormatHandler.java 2007-06-24 04:38:15 UTC (rev 11708)
@@ -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.codehaus.mojo.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.codehaus.mojo.docbook.gen.util.Formatting;
+import org.codehaus.mojo.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();
+ }
+
+ }
+
+}
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/Formatting.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/Formatting.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/Formatting.java 2007-06-24 04:38:15 UTC (rev 11708)
@@ -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.codehaus.mojo.docbook.gen.util;
+
+import java.io.File;
+
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.mojo.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;
+ }
+ }
+}
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/ResourceHelper.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/ResourceHelper.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/ResourceHelper.java 2007-06-24 04:38:15 UTC (rev 11708)
@@ -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.codehaus.mojo.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 );
+ }
+}
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/StandardDocBookFormatSpecification.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/StandardDocBookFormatSpecification.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/StandardDocBookFormatSpecification.java 2007-06-24 04:38:15 UTC (rev 11708)
@@ -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.codehaus.mojo.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.equals( name ) ) {
+ return JAVAHELP;
+ }
+ else if ( MAN.name.equals( name ) ) {
+ return MAN;
+ }
+ else if ( PDF.name.equals( name ) ) {
+ return PDF;
+ }
+ else if ( WEBSITE.name.equals( name ) ) {
+ return WEBSITE;
+ }
+// else if ( WORDML.name.equals( name ) ) {
+// return WORDML;
+// }
+ else if ( XHTML.name.equals( name ) ) {
+ return XHTML;
+ }
+ else {
+ return null;
+ }
+ }
+
+
+ // convenience for html based formats to simplify ctors ~~~~~~~~~~~~~~~~~~~
+
+ private static class HtmlBasedStandardDocBookFormat extends StandardDocBookFormatSpecification {
+ private HtmlBasedStandardDocBookFormat(String name, String stylesheetResource) {
+ this( name, stylesheetResource, true );
+ }
+ private HtmlBasedStandardDocBookFormat(String name, String stylesheetResource, boolean doingChunking) {
+ super( name, "html", stylesheetResource, false, true, doingChunking );
+ }
+ }
+}
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/TransformerType.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/TransformerType.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/util/TransformerType.java 2007-06-24 04:38:15 UTC (rev 11708)
@@ -0,0 +1,52 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.codehaus.mojo.docbook.gen.util;
+
+/**
+ * Enumeration of supported XSLT transformers.
+ *
+ * @author Steve Ebersole
+ */
+public class TransformerType {
+ public static final TransformerType SAXON = new TransformerType( "saxon", false );
+ public static final TransformerType XALAN = new TransformerType( "xalan", true );
+
+ private final String name;
+ private final boolean supportsReset;
+
+ private TransformerType(String name, boolean supportsReset) {
+ this.name = name;
+ this.supportsReset = supportsReset;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public boolean supportsReset() {
+ return supportsReset;
+ }
+
+ public static TransformerType parse(String name) {
+ if ( XALAN.name.equals( name ) ) {
+ return XALAN;
+ }
+ else {
+ // default
+ return SAXON;
+ }
+ }
+}
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/catalog/AbstractCatalogManager.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/catalog/AbstractCatalogManager.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/catalog/AbstractCatalogManager.java 2007-06-24 04:38:15 UTC (rev 11708)
@@ -0,0 +1,46 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.codehaus.mojo.docbook.gen.xslt.catalog;
+
+import org.apache.xml.resolver.CatalogManager;
+
+/**
+ * Basic support for our notion of CatalogManagers.
+ *
+ * @author Steve Ebersole
+ */
+public abstract class AbstractCatalogManager extends CatalogManager {
+ public AbstractCatalogManager(String[] catalogNames) {
+ super();
+ setIgnoreMissingProperties( true );
+ if ( catalogNames != null && catalogNames.length != 0 ) {
+ StringBuffer buffer = new StringBuffer();
+ boolean first = true;
+ for ( int i = 0; i < catalogNames.length; i++ ) {
+ if ( catalogNames[i] != null ) {
+ if ( first ) {
+ first = false;
+ }
+ else {
+ buffer.append( ';' );
+ }
+ }
+ buffer.append( catalogNames[i] );
+ }
+ setCatalogFiles( buffer.toString() );
+ }
+ }
+}
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/catalog/ExplicitCatalogManager.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/catalog/ExplicitCatalogManager.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/catalog/ExplicitCatalogManager.java 2007-06-24 04:38:15 UTC (rev 11708)
@@ -0,0 +1,28 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.codehaus.mojo.docbook.gen.xslt.catalog;
+
+/**
+ * Utilizes explicit, user-supplied catalog names to build a
+ * CatalogManager.
+ *
+ * @author Steve Ebersole
+ */
+public class ExplicitCatalogManager extends AbstractCatalogManager {
+ public ExplicitCatalogManager(String[] catalogNames) {
+ super( catalogNames );
+ }
+}
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/catalog/ImplicitCatalogManager.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/catalog/ImplicitCatalogManager.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/catalog/ImplicitCatalogManager.java 2007-06-24 04:38:15 UTC (rev 11708)
@@ -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.codehaus.mojo.docbook.gen.xslt.catalog;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+
+/**
+ * CatalogManager which resolves its catalogs internally via classpath
+ * resource lookups. Its looks for resources named '/catalog.xml' on the
+ * classpath.
+ *
+ * @author Steve Ebersole
+ */
+public class ImplicitCatalogManager extends AbstractCatalogManager {
+ public ImplicitCatalogManager() {
+ super( resolveCatalogNames() );
+ }
+
+ private static String[] resolveCatalogNames() {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ if ( classLoader == null ) {
+ classLoader = ImplicitCatalogManager.class.getClassLoader();
+ }
+ ArrayList names = new ArrayList();
+ try {
+ Enumeration enumeration = classLoader.getResources( "/catalog.xml" );
+ while ( enumeration.hasMoreElements() ) {
+ final URL resource = ( URL ) enumeration.nextElement();
+ final String resourcePath = resource.toExternalForm();
+ if ( resourcePath != null ) {
+ names.add( resourcePath );
+ }
+ }
+ }
+ catch ( IOException ignore ) {
+ // intentionally empty
+ }
+ return ( String[] ) names.toArray( new String[ names.size() ] );
+ }
+}
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/ResolverChain.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/ResolverChain.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/ResolverChain.java 2007-06-24 04:38:15 UTC (rev 11708)
@@ -0,0 +1,71 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.codehaus.mojo.docbook.gen.xslt.resolve;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
+
+/**
+ * Allows chaining a series of {@link URIResolver resolvers} together.
+ * <p/>
+ * "Precedence" of the resolvers is determined by the order in which
+ * they are {@link #addResolver added}.
+ *
+ * @author Steve Ebersole
+ */
+public class ResolverChain implements URIResolver {
+ private List resolvers = new ArrayList();
+
+ public ResolverChain() {
+ }
+
+ public ResolverChain(URIResolver resolver) {
+ this();
+ addResolver( resolver );
+ }
+
+ /**
+ * Adds a resolver to the chain.
+ *
+ * @param resolver The resolver to add.
+ */
+ public void addResolver(URIResolver resolver) {
+ resolvers.add( resolver );
+ }
+
+ /**
+ * Here we iterate over all the chained resolvers and delegate to them
+ * until we find one which can handle the resolve request (if any).
+ *
+ * {@inheritDoc}
+ */
+ public Source resolve(String href, String base) throws TransformerException {
+ Source result = null;
+ Iterator itr = resolvers.iterator();
+ while ( itr.hasNext() ) {
+ final URIResolver resolver = ( URIResolver ) itr.next();
+ result = resolver.resolve( href, base );
+ if ( result != null ) {
+ break;
+ }
+ }
+ return result;
+ }
+}
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/VersionResolver.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/VersionResolver.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/gen/xslt/resolve/VersionResolver.java 2007-06-24 04:38:15 UTC (rev 11708)
@@ -0,0 +1,70 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.codehaus.mojo.docbook.gen.xslt.resolve;
+
+import java.io.IOException;
+import java.net.URL;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.stream.StreamSource;
+
+import org.codehaus.mojo.docbook.gen.util.ResourceHelper;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class VersionResolver implements URIResolver {
+ public static final String BASE_HREF = "http://docbook.sourceforge.net/release/xsl/";
+
+ private final String version;
+ private final String versionHref;
+
+ public VersionResolver(String version) {
+ this.version = version;
+ this.versionHref = BASE_HREF + version;
+ }
+
+ public Source resolve(String href, String base) throws TransformerException {
+ if ( href.startsWith( versionHref ) ) {
+ return resolve( href );
+ }
+ else if ( base.startsWith( versionHref ) ) {
+ return resolve( base + "/" + href );
+ }
+ return null;
+ }
+
+ private Source resolve(String href) {
+ String resource = href.substring( versionHref.length() );
+ try {
+ URL resourceURL = ResourceHelper.requireResource( resource );
+ return new StreamSource( resourceURL.openStream(), resourceURL.toExternalForm() );
+ }
+ catch ( IllegalArgumentException e ) {
+ return null;
+ }
+ catch ( IOException e ) {
+ return null;
+ }
+ }
+
+ public String toString() {
+ return super.toString() + " [version=" + version + "]";
+ }
+}
17 years, 5 months
Hibernate SVN: r11707 - trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-06-24 00:18:57 -0400 (Sun, 24 Jun 2007)
New Revision: 11707
Modified:
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/Diff.java
Log:
more prep move to codehaus
Modified: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/Diff.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/Diff.java 2007-06-24 04:18:35 UTC (rev 11706)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/Diff.java 2007-06-24 04:18:57 UTC (rev 11707)
@@ -13,7 +13,7 @@
*
* Red Hat Author(s): Steve Ebersole
*/
-package org.jboss.maven.plugin.docbook.revdiff;
+package org.codehaus.mojo.docbook.revdiff;
import java.util.Set;
import java.util.HashSet;
17 years, 5 months
Hibernate SVN: r11706 - in trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org: codehaus and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-06-24 00:18:35 -0400 (Sun, 24 Jun 2007)
New Revision: 11706
Added:
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/
Modified:
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/BaselineHandler.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/ContentItem.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/ContentItemDescriptor.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/DiffCreator.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/GenerationException.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/IndexReportGenerator.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/TranslationHandler.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/TranslationReportGenerator.java
Log:
more prep move to codehaus
Copied: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff (from rev 11700, trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/revdiff)
Modified: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/BaselineHandler.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/revdiff/BaselineHandler.java 2007-06-22 19:39:47 UTC (rev 11700)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/BaselineHandler.java 2007-06-24 04:18:35 UTC (rev 11706)
@@ -13,7 +13,7 @@
*
* Red Hat Author(s): Christian Bauer, Steve Ebersole
*/
-package org.jboss.maven.plugin.docbook.revdiff;
+package org.codehaus.mojo.docbook.revdiff;
import java.util.Map;
@@ -55,7 +55,7 @@
// The default revision is 0
int revision = 0;
if ( atts.getValue( "revision" ) != null ) {
- revision = new Integer( atts.getValue( "revision" ) ).intValue();
+ revision = Integer.parseInt( atts.getValue( "revision" ) );
}
// Generate new ContentItem and new original state
Modified: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/ContentItem.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/revdiff/ContentItem.java 2007-06-22 19:39:47 UTC (rev 11700)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/ContentItem.java 2007-06-24 04:18:35 UTC (rev 11706)
@@ -13,7 +13,7 @@
*
* Red Hat Author(s): Christian Bauer
*/
-package org.jboss.maven.plugin.docbook.revdiff;
+package org.codehaus.mojo.docbook.revdiff;
/**
* Describes a particular piece of content, including descriptors
@@ -61,11 +61,8 @@
ContentItem that = ( ContentItem ) o;
- if ( !identifier.equals( that.identifier ) ) {
- return false;
- }
+ return identifier.equals( that.identifier );
- return true;
}
public int hashCode() {
Modified: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/ContentItemDescriptor.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/revdiff/ContentItemDescriptor.java 2007-06-22 19:39:47 UTC (rev 11700)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/ContentItemDescriptor.java 2007-06-24 04:18:35 UTC (rev 11706)
@@ -13,7 +13,7 @@
*
* Red Hat Author(s): Christian Bauer
*/
-package org.jboss.maven.plugin.docbook.revdiff;
+package org.codehaus.mojo.docbook.revdiff;
/**
*
Modified: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/DiffCreator.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/revdiff/DiffCreator.java 2007-06-22 19:39:47 UTC (rev 11700)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/DiffCreator.java 2007-06-24 04:18:35 UTC (rev 11706)
@@ -13,7 +13,7 @@
*
* Red Hat Author(s): Steve Ebersole
*/
-package org.jboss.maven.plugin.docbook.revdiff;
+package org.codehaus.mojo.docbook.revdiff;
import java.io.File;
import java.io.IOException;
Modified: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/GenerationException.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/revdiff/GenerationException.java 2007-06-22 19:39:47 UTC (rev 11700)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/GenerationException.java 2007-06-24 04:18:35 UTC (rev 11706)
@@ -13,7 +13,7 @@
*
* Red Hat Author(s): Steve Ebersole
*/
-package org.jboss.maven.plugin.docbook.revdiff;
+package org.codehaus.mojo.docbook.revdiff;
/**
* Indicates problems generating the diff report
Modified: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/IndexReportGenerator.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/revdiff/IndexReportGenerator.java 2007-06-22 19:39:47 UTC (rev 11700)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/IndexReportGenerator.java 2007-06-24 04:18:35 UTC (rev 11706)
@@ -13,7 +13,7 @@
*
* Red Hat Author(s): Steve Ebersole
*/
-package org.jboss.maven.plugin.docbook.revdiff;
+package org.codehaus.mojo.docbook.revdiff;
import java.util.Locale;
import java.util.List;
Modified: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/TranslationHandler.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/revdiff/TranslationHandler.java 2007-06-22 19:39:47 UTC (rev 11700)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/TranslationHandler.java 2007-06-24 04:18:35 UTC (rev 11706)
@@ -13,7 +13,7 @@
*
* Red Hat Author(s): Christian Bauer, Steve Ebersole
*/
-package org.jboss.maven.plugin.docbook.revdiff;
+package org.codehaus.mojo.docbook.revdiff;
import java.util.Map;
import java.util.Iterator;
@@ -54,7 +54,7 @@
if ( identifier != null ) {
int revision = 0;
if ( atts.getValue( "revision" ) != null ) {
- revision = new Integer( atts.getValue( "revision" ) ).intValue();
+ revision = Integer.parseInt( atts.getValue( "revision" ) );
}
ContentItemDescriptor translationState = new ContentItemDescriptor(
Modified: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/TranslationReportGenerator.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/revdiff/TranslationReportGenerator.java 2007-06-22 19:39:47 UTC (rev 11700)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/codehaus/mojo/docbook/revdiff/TranslationReportGenerator.java 2007-06-24 04:18:35 UTC (rev 11706)
@@ -13,7 +13,7 @@
*
* Red Hat Author(s): Christian Bauer, Steve Ebersole
*/
-package org.jboss.maven.plugin.docbook.revdiff;
+package org.codehaus.mojo.docbook.revdiff;
import java.io.File;
import java.io.FileWriter;
17 years, 5 months
Hibernate SVN: r11705 - trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-06-24 00:13:24 -0400 (Sun, 24 Jun 2007)
New Revision: 11705
Removed:
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/AbstractDocBookMojo.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/DocBookSupportResourcesMojo.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/Format.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/GenerationMojo.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/Options.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/PackageMojo.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/ResourceMojo.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/TranslationDiffReport.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/revdiff/
Log:
more prep for move to codehaus
Deleted: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/AbstractDocBookMojo.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/AbstractDocBookMojo.java 2007-06-24 04:08:36 UTC (rev 11704)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/AbstractDocBookMojo.java 2007-06-24 04:13:24 UTC (rev 11705)
@@ -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.jboss.maven.plugin.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.plugin.docbook.gen.RenderingException;
-import org.jboss.maven.plugin.docbook.gen.XSLTException;
-import org.jboss.maven.plugin.docbook.gen.util.Formatting;
-import org.jboss.maven.plugin.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 org.jboss.maven.plugin.docbook.gen.RenderingException
- * @throws XSLTException
- */
- 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: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/DocBookSupportResourcesMojo.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/DocBookSupportResourcesMojo.java 2007-06-24 04:08:36 UTC (rev 11704)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/DocBookSupportResourcesMojo.java 2007-06-24 04:13:24 UTC (rev 11705)
@@ -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.jboss.maven.plugin.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: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/Format.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/Format.java 2007-06-24 04:08:36 UTC (rev 11704)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/Format.java 2007-06-24 04:13:24 UTC (rev 11705)
@@ -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.jboss.maven.plugin.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: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/GenerationMojo.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/GenerationMojo.java 2007-06-24 04:08:36 UTC (rev 11704)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/GenerationMojo.java 2007-06-24 04:13:24 UTC (rev 11705)
@@ -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.jboss.maven.plugin.docbook;
-
-import java.io.File;
-
-import org.codehaus.plexus.util.FileUtils;
-import org.jboss.maven.plugin.docbook.gen.util.Formatting;
-import org.jboss.maven.plugin.docbook.gen.format.FormatHandlerFactory;
-import org.jboss.maven.plugin.docbook.gen.RenderingException;
-import org.jboss.maven.plugin.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 );
- }
- }
-
-}
Deleted: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/Options.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/Options.java 2007-06-24 04:08:36 UTC (rev 11704)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/Options.java 2007-06-24 04:13:24 UTC (rev 11705)
@@ -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.jboss.maven.plugin.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: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/PackageMojo.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/PackageMojo.java 2007-06-24 04:08:36 UTC (rev 11704)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/PackageMojo.java 2007-06-24 04:13:24 UTC (rev 11705)
@@ -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.jboss.maven.plugin.docbook;
-
-import java.io.File;
-
-import org.jboss.maven.plugin.docbook.gen.util.Formatting;
-import org.jboss.maven.plugin.docbook.gen.RenderingException;
-import org.jboss.maven.plugin.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: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/ResourceMojo.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/ResourceMojo.java 2007-06-24 04:08:36 UTC (rev 11704)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/ResourceMojo.java 2007-06-24 04:13:24 UTC (rev 11705)
@@ -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.jboss.maven.plugin.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.plugin.docbook.gen.util.Formatting;
-import org.jboss.maven.plugin.docbook.gen.RenderingException;
-import org.jboss.maven.plugin.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: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/TranslationDiffReport.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/TranslationDiffReport.java 2007-06-24 04:08:36 UTC (rev 11704)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/TranslationDiffReport.java 2007-06-24 04:13:24 UTC (rev 11705)
@@ -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.jboss.maven.plugin.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.plugin.docbook.gen.util.Formatting;
-import org.jboss.maven.plugin.docbook.gen.RenderingException;
-import org.jboss.maven.plugin.docbook.revdiff.Diff;
-import org.jboss.maven.plugin.docbook.revdiff.DiffCreator;
-import org.jboss.maven.plugin.docbook.revdiff.GenerationException;
-import org.jboss.maven.plugin.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() + "]" );
- }
- }
- }
-}
17 years, 5 months
Hibernate SVN: r11704 - in trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin: src and 4 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-06-24 00:08:36 -0400 (Sun, 24 Jun 2007)
New Revision: 11704
Added:
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/DocBookSupportResourcesMojo.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/site/
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/site/apt/
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/site/apt/examples/
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/site/apt/index.apt
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/site/apt/usage.apt
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/site/site.xml
Modified:
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/pom.xml
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/GenerationMojo.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/PackageMojo.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/ResourceMojo.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/resources/META-INF/plexus/components.xml
Log:
prep move to codehaus
Modified: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/pom.xml
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/pom.xml 2007-06-22 23:40:50 UTC (rev 11703)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/pom.xml 2007-06-24 04:08:36 UTC (rev 11704)
@@ -1,18 +1,88 @@
<?xml version="1.0"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
<modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss.maven.plugins</groupId>
- <artifactId>maven-jboss-docbook-plugin</artifactId>
+ <parent>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>mojo</artifactId>
+ <version>15</version>
+ </parent>
+
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>docbook-maven-plugin</artifactId>
+ <packaging>maven-plugin</packaging>
<version>2.0-SNAPSHOT</version>
- <packaging>maven-plugin</packaging>
+ <name>Maven Docbook Plugin</name>
+ <description>This plugin adds support for Docbook transformations to Maven.</description>
+ <url>http://mojo.codehaus.org/maven-docbook-plugin</url>
- <name>DocBook XML Transformations</name>
- <description>Plugin for generating documentation from DocBook sources and either standard or custom XSL stylesheets.</description>
+ <developers>
+ <developer>
+ <name>Jose Gonzalez Gomez</name>
+ <email>jgonzalez.openinput(a)gmail.com</email>
+ <organization>OPEN input</organization>
+ <organizationUrl>http://www.openinput.com/</organizationUrl>
+ <timezone>+1</timezone>
+ </developer>
+ <developer>
+ <name>Steve Ebersole</name>
+ <email>steve(a)hibernate.org</email>
+ <organization>Hibernate</organization>
+ <organizationUrl>http://hibernate.org</organizationUrl>
+ <timezone>-5</timezone>
+ </developer>
+ </developers>
+ <licenses>
+ <license>
+ <name>GNU Lesser General Public License</name>
+ <url>http://www.gnu.org/copyleft/lesser.html</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+
+ <scm>
+ <connection>scm:svn:https://svn.codehaus.org/mojo/trunk/mojo/docbook-maven-plugin</connection>
+ <developerConnection>scm:svn:https://svn.codehaus.org/mojo/trunk/mojo/docbook-maven-plugin</developerConnection>
+ <url>https://svn.codehaus.org/mojo/trunk/mojo/docbook-maven-plugin</url>
+ </scm>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.4</source>
+ <target>1.4</target>
+ <encoding>UTF-8</encoding>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <minmemory>128m</minmemory>
+ <maxmemory>512</maxmemory>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jxr-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+
<dependencies>
+ <!-- todo : can we remove this and rely on the user project defining which docbook to use? -->
<dependency>
<groupId>net.sf.docbook</groupId>
<artifactId>docbook</artifactId>
@@ -39,6 +109,11 @@
<version>1.0.1</version>
</dependency>
<dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-archiver</artifactId>
+ <version>1.0-alpha-7</version>
+ </dependency>
+ <dependency>
<groupId>avalon-framework</groupId>
<artifactId>avalon-framework</artifactId>
<version>4.1.5</version>
@@ -100,7 +175,7 @@
<artifactId>saxon</artifactId>
<version>6.5.3</version>
</dependency>
-
+
<!-- todo : upgrade this to 0.93 or later once the fox: extension element issues are fixed -->
<dependency>
<groupId>fop</groupId>
@@ -125,16 +200,15 @@
<version>1.1.3</version>
<scope>runtime</scope>
</dependency>
+
+
+ <!-- dont think this is needed anymore -->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.2</version>
</dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-archiver</artifactId>
- <version>1.0-alpha-7</version>
- </dependency>
+
</dependencies>
<properties>
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/DocBookSupportResourcesMojo.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/DocBookSupportResourcesMojo.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/DocBookSupportResourcesMojo.java 2007-06-24 04:08:36 UTC (rev 11704)
@@ -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.plugin.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 );
+ }
+ }
+}
Modified: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/GenerationMojo.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/GenerationMojo.java 2007-06-22 23:40:50 UTC (rev 11703)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/GenerationMojo.java 2007-06-24 04:08:36 UTC (rev 11704)
@@ -25,8 +25,9 @@
import org.apache.maven.artifact.Artifact;
/**
- * A DocBook plugin based on the excellent docbkx-maven-plugin, but which
- * specifically handles language translations in a more transparent way.
+ * 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
Modified: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/PackageMojo.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/PackageMojo.java 2007-06-22 23:40:50 UTC (rev 11703)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/PackageMojo.java 2007-06-24 04:08:36 UTC (rev 11704)
@@ -22,8 +22,8 @@
import org.jboss.maven.plugin.docbook.gen.format.FormatHandlerFactory;
/**
- * This mojo's purpose within the plugin/packaging is to bundle the individual
- * formats into deployable formats. Note that some formats (PDF, e.g.) are
+ * 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
Modified: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/ResourceMojo.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/ResourceMojo.java 2007-06-22 23:40:50 UTC (rev 11703)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/ResourceMojo.java 2007-06-24 04:08:36 UTC (rev 11704)
@@ -31,10 +31,11 @@
import org.jboss.maven.plugin.docbook.gen.XSLTException;
/**
- * This mojo's purpose within the plugin/packaging is to process resources
- * defined by various inputs, moving them into a *single* staging directory for
- * use during XSLT processing; the DocBook XSLT only allow defining a single
- * <tt>img.src.path</tt> value.
+ * 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
@@ -109,8 +110,6 @@
getLog().info( "unpacking dependency resource [" + file.getAbsolutePath() + "] to staging-dir [" + target.getAbsolutePath() + "]" );
try {
target.mkdirs();
-// :(
-// UnArchiver unArchiver = archiverManager.getUnArchiver( file );
UnArchiver unArchiver = archiverManager.getUnArchiver( "jar" );
unArchiver.setSourceFile( file );
unArchiver.setDestDirectory( target );
Modified: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/resources/META-INF/plexus/components.xml
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/resources/META-INF/plexus/components.xml 2007-06-22 23:40:50 UTC (rev 11703)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/resources/META-INF/plexus/components.xml 2007-06-24 04:08:36 UTC (rev 11704)
@@ -2,12 +2,7 @@
<components>
- <component>
- <role>org.apache.maven.reporting.MavenReport</role>
- <role-hint>diff</role-hint>
- <implementation>org.jboss.maven.plugin.docbook.TranslationDiffReport</implementation>
- <instantiation-strategy>per-lookup</instantiation-strategy>
- </component>
+ <!-- Defines the lifecycle associated with the 'docbook' packaging -->
<component>
<role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
@@ -24,6 +19,47 @@
</configuration>
</component>
+ <!-- Defines the lifecycle associated with the 'docbook-support' packaging -->
+
+ <component>
+ <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
+ <role-hint>docbook-support</role-hint>
+ <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
+ <configuration>
+ <phases>
+ <process-resources>org.jboss.maven.plugins:maven-docbook-support-plugin:support-resources</process-resources>
+ <package>org.apache.maven.plugins:maven-jar-plugin:jar</package>
+ <install>org.apache.maven.plugins:maven-install-plugin:install</install>
+ <deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
+ </phases>
+ </configuration>
+ </component>
+
+ <!-- Defines the artifact handling associated with the 'docbook-support' packaging -->
+
+ <component>
+ <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+ <role-hint>docbook-support</role-hint>
+ <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+ <configuration>
+ <type>docbook-support</type>
+ <extension>jar</extension>
+ <packaging>jar</packaging>
+ <language>java</language>
+ <addedToClasspath>false</addedToClasspath>
+ <includesDependencies>true</includesDependencies>
+ </configuration>
+ </component>
+
+ <!-- Defines the 'diff' reporting goal -->
+
+ <component>
+ <role>org.apache.maven.reporting.MavenReport</role>
+ <role-hint>diff</role-hint>
+ <implementation>org.jboss.maven.plugin.docbook.TranslationDiffReport</implementation>
+ <instantiation-strategy>per-lookup</instantiation-strategy>
+ </component>
+
</components>
</component-set>
\ No newline at end of file
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/site/apt/index.apt
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/site/apt/index.apt (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/site/apt/index.apt 2007-06-24 04:08:36 UTC (rev 11704)
@@ -0,0 +1,75 @@
+ ------
+ Introduction
+ ------
+ Steve Ebersole
+ ------
+ 22 June 2007
+ ------
+
+~~ Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+~~
+~~ This copyrighted material is made available to anyone wishing to use, modify,
+~~ copy, or redistribute it subject to the terms and conditions of the GNU
+~~ Lesser General Public License, v. 2.1. This program is distributed in the
+~~ hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+~~ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+~~ Lesser General Public License for more details. You should have received a
+~~ copy of the GNU Lesser General Public License, v.2.1 along with this
+~~ distribution; if not, write to the Free Software Foundation, Inc.,
+~~ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+~~
+~~ Red Hat Author(s): Steve Ebersole
+
+Maven Docbook Plugin
+
+ DocBook is, in part, "an XML vocabulary that lets you create documents in a
+ presentation-neutral form that captures the logical structure of your
+ content". Another aspect of DocBook is the rendering of that content into
+ various formats using DocBook-supplied (or custom) XSLT stylesheets.
+ Basically, DocBook allows you to write and maintain a single source for
+ documentation, and to then render that single source into multiple formats
+ such as PDF or HTML.
+
+ The purpose of this plugin is to allow these DocBook transformations to
+ occur as a natural part of the users Maven build. The main difficulty with
+ this was the fact that DocBook transformations are usually very closely
+ tied to the user's local environment. The goal with this plugin was to
+ utilize Maven's dependency mechanism to bring all the pieces together on
+ demand; these pieces include (a) the DocBook distribution itself, (b) custom
+ XSLT, (c) fonts, (d) images, (e) css. These are the ingredients that when
+ mixed with the source file(s) and stirred with an XSLT transformer produce
+ the desired output(s).
+
+~~ todo : need to discuss the docbook-support stuff...
+
+* Goals Overview
+
+ The plugin defines a dedicated project packaging ("docbook"). That decision
+ was initially made because of the fact that a project of DocBook source would
+ not have an inherent "main artifact", just a bunch of "attached artifacts"
+ (one for each output format). The packaging is used to redefine a suitable
+ lifecycle with a series of mojos performing operations in stages. The
+ lifecycle/stages are as follows:
+ [process-resources] binds the {{{resources.html}docbook-maven-plugin:resources}}
+ goal which "stages" the resources need for the XSLT transformations such as
+ fonts, images and css.
+ [compile] binds the {{{generate.html}docbook-maven-plugin:generate}} goal
+ which performs the actual XSLT transformations.
+ [package] binds the {{{bundle.html}docbook-maven-plugin:bundle}} goal
+ which takes all the output formats, archives them as WARs and attaches the
+ WARs to the project with the format name as the artifact classifier.
+ [install] binds the standard install goal.
+ [deploy] binds the standard deploy goal.
+
+* Usage
+
+ Instructions on how to use the Maven Docbook Plugin can be found {{{usage.html}here}}.
+
+* Examples
+
+ To provide you with better understanding of some usages of the Plugin Name,
+ you can take a look into the following examples:
+
+ * {{{examples/example-one.html}Example Description One}}
+
+ * {{{examples/example-two.html}Example Description Two}}
\ No newline at end of file
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/site/apt/usage.apt
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/site/apt/usage.apt (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/site/apt/usage.apt 2007-06-24 04:08:36 UTC (rev 11704)
@@ -0,0 +1,30 @@
+ ------
+ Usage
+ ------
+ Steve Ebersole
+ ------
+ 22 June 2007
+ ------
+
+~~ Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+~~
+~~ This copyrighted material is made available to anyone wishing to use, modify,
+~~ copy, or redistribute it subject to the terms and conditions of the GNU
+~~ Lesser General Public License, v. 2.1. This program is distributed in the
+~~ hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+~~ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+~~ Lesser General Public License for more details. You should have received a
+~~ copy of the GNU Lesser General Public License, v.2.1 along with this
+~~ distribution; if not, write to the Free Software Foundation, Inc.,
+~~ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+~~
+~~ Red Hat Author(s): Steve Ebersole
+
+Usage
+
+ The Maven Docbook Plugin uses a combination of SAXON and DocBook XSLT
+ (plus some other stuff depending on the format) to produce the desired
+ outputs. The following sections describe the basic usage scenarios.
+
+* Minimal configuration
+
\ No newline at end of file
Added: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/site/site.xml
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/site/site.xml (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/site/site.xml 2007-06-24 04:08:36 UTC (rev 11704)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="Maven">
+
+ <bannerLeft>
+ <name>Mojo</name>
+ <src>http://mojo.codehaus.org/images/mojo_logo.png</src>
+ <href>http://mojo.codehaus.org/</href>
+ </bannerLeft>
+
+ <bannerRight>
+ <src>http://mojo.codehaus.org/images/codehaus-small.png</src>
+ </bannerRight>
+
+ <body>
+ <links>
+ <item name="Mojo" href="http://mojo.codehaus.org/" />
+ <item name="Maven" href="http://maven.apache.org/"/>
+ <item name="DocBook" href="http://docbook.sourceforge.net/"/>
+ </links>
+
+ <menu name="Overview">
+ <item name="Introduction" href="index.html"/>
+ <item name="Goals" href="plugin-info.html"/>
+ <item name="Usage" href="usage.html"/>
+ <item name="FAQ" href="faq.html"/>
+ </menu>
+
+ <menu name="Examples">
+ <item name="description1" href="examples/example-one.html"/>
+ <item name="description2" href="examples/example-two.html"/>
+ </menu>
+
+ ${reports}
+ </body>
+
+</project>
17 years, 5 months
Hibernate SVN: r11703 - in trunk/HibernateExt/search: src/java/org/hibernate/search and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-06-22 19:40:50 -0400 (Fri, 22 Jun 2007)
New Revision: 11703
Added:
trunk/HibernateExt/search/src/java/org/hibernate/search/jpa/
trunk/HibernateExt/search/src/java/org/hibernate/search/jpa/FullTextEntityManager.java
trunk/HibernateExt/search/src/java/org/hibernate/search/jpa/FullTextQuery.java
trunk/HibernateExt/search/src/java/org/hibernate/search/jpa/impl/
trunk/HibernateExt/search/src/java/org/hibernate/search/jpa/impl/FullTextEntityManagerImpl.java
Modified:
trunk/HibernateExt/search/build.xml
trunk/HibernateExt/search/src/java/org/hibernate/search/FullTextQuery.java
Log:
HSEARCH-89 JPA wrappers implementation
Modified: trunk/HibernateExt/search/build.xml
===================================================================
--- trunk/HibernateExt/search/build.xml 2007-06-22 20:58:27 UTC (rev 11702)
+++ trunk/HibernateExt/search/build.xml 2007-06-22 23:40:50 UTC (rev 11703)
@@ -29,8 +29,10 @@
value="${basedir}/../annotations/target/hibernate-annotations/hibernate-annotations.jar"/>
<property name="commons-annotations.jar"
value="${basedir}/../commons-annotations/target/hibernate-commons-annotations/hibernate-commons-annotations.jar"/>
+ <property name="entitymanager.jar"
+ value="${basedir}/../entitymanager/target/hibernate-entitymanager/hibernate-entitymanager.jar"/>
- <import file="${common.dir}/common-build.xml"/>
+ <import file="${common.dir}/common-build.xml"/>
<property name="build.testresources.dir" value="${build.dir}/testresources"/>
@@ -76,7 +78,8 @@
<pathelement location="${src.dir}"/>
<pathelement location="${test.dir}"/>
<pathelement location="${annotations.jar}"/>
- <fileset dir="${jdbc.dir}">
+ <pathelement location="${entitymanager.jar}"/>
+ <fileset dir="${jdbc.dir}">
<include name="*.jar"/>
<include name="*.zip"/>
</fileset>
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/FullTextQuery.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/FullTextQuery.java 2007-06-22 20:58:27 UTC (rev 11702)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/FullTextQuery.java 2007-06-22 23:40:50 UTC (rev 11703)
@@ -9,6 +9,7 @@
* The base interface for lucene powered searches.
*
* @author Hardy Ferentschik
+ * @author Emmanuel Bernard
*/
//TODO return FullTextQuery rather than Query in useful chain methods
public interface FullTextQuery extends Query {
Added: trunk/HibernateExt/search/src/java/org/hibernate/search/jpa/FullTextEntityManager.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/jpa/FullTextEntityManager.java (rev 0)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/jpa/FullTextEntityManager.java 2007-06-22 23:40:50 UTC (rev 11703)
@@ -0,0 +1,32 @@
+//$Id$
+package org.hibernate.search.jpa;
+
+import javax.persistence.EntityManager;
+
+import org.hibernate.search.SearchFactory;
+
+/**
+ * Extends an EntityManager with Full-Text operations
+ *
+ * @author Emmanuel Bernard
+ */
+public interface FullTextEntityManager extends EntityManager {
+ /**
+ * Create a Query on top of a native Lucene Query returning the matching objects
+ * of type <code>entities</code> and their respective subclasses.
+ * If no entity is provided, no type filtering is done.
+ */
+ FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery, Class... entities);
+
+ /**
+ * Force the (re)indexing of a given <b>managed</b> object.
+ * Indexation is batched per transaction
+ */
+ void index(Object entity);
+
+ /**
+ * return the SearchFactory
+ */
+ SearchFactory getSearchFactory();
+
+}
Added: trunk/HibernateExt/search/src/java/org/hibernate/search/jpa/FullTextQuery.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/jpa/FullTextQuery.java (rev 0)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/jpa/FullTextQuery.java 2007-06-22 23:40:50 UTC (rev 11703)
@@ -0,0 +1,65 @@
+//$Id$
+package org.hibernate.search.jpa;
+
+import javax.persistence.Query;
+
+import org.apache.lucene.search.Sort;
+import org.hibernate.Criteria;
+
+/**
+ * The base interface for lucene powered searches.
+ * This extends the JPA Query interface
+ *
+ * @author Hardy Ferentschik
+ * @author Emmanuel Bernard
+ */
+//TODO return FullTextQuery rather than Query in useful chain methods
+public interface FullTextQuery extends Query {
+ //todo Determine what other lucene specific features to expose via this
+ // interface. Maybe we should give access to the underlying lucene hit
+ // objects?
+
+ /**
+ * Allows to let lucene sort the results. This is useful when you have
+ * additional sort requirements on top of the default lucene ranking.
+ * Without lucene sorting you would have to retrieve the full result set and
+ * order the hibernate objects.
+ *
+ * @param sort The lucene sort object.
+ * @return this for method chaining
+ */
+ FullTextQuery setSort(Sort sort);
+
+ /**
+ * Returns the number of hits for this search
+ *
+ * Caution:
+ * The number of results might be slightly different from
+ * <code>list().size()</code> because list() if the index is
+ * not in sync with the database at the time of query.
+ */
+ int getResultSize();
+
+ /**
+ * Defines the Database Query used to load the Lucene results.
+ * Useful to load a given object graph by refining the fetch modes
+ *
+ * No projection (criteria.setProjection() ) allowed, the root entity must be the only returned type
+ * No where restriction can be defined either.
+ *
+ */
+ FullTextQuery setCriteriaQuery(Criteria criteria);
+
+ /**
+ * Defines the Lucene field names projected and returned in a query result
+ * Each field is converted back to it's object representation, an Object[] being returned for each "row"
+ * (similar to an HQL or a Criteria API projection).
+ *
+ * A projectable field must be stored in the Lucene index and use a {@link org.hibernate.search.bridge.TwoWayFieldBridge}
+ * Unless notified in their JavaDoc, all built-in bridges are two-way. All @DocumentId fields are projectable by design.
+ *
+ * If the projected field is not a projectable field, null is returned in the object[]
+ *
+ */
+ FullTextQuery setIndexProjection(String... fields);
+}
Added: trunk/HibernateExt/search/src/java/org/hibernate/search/jpa/impl/FullTextEntityManagerImpl.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/jpa/impl/FullTextEntityManagerImpl.java (rev 0)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/jpa/impl/FullTextEntityManagerImpl.java 2007-06-22 23:40:50 UTC (rev 11703)
@@ -0,0 +1,152 @@
+//$Id$
+package org.hibernate.search.jpa.impl;
+
+import javax.persistence.EntityManager;
+import javax.persistence.FlushModeType;
+import javax.persistence.LockModeType;
+import javax.persistence.Query;
+import javax.persistence.EntityTransaction;
+
+import org.hibernate.search.jpa.FullTextEntityManager;
+import org.hibernate.search.jpa.FullTextQuery;
+import org.hibernate.search.SearchFactory;
+import org.hibernate.search.SearchException;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.Search;
+import org.hibernate.Session;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class FullTextEntityManagerImpl implements FullTextEntityManager {
+ private EntityManager em;
+ private FullTextSession ftSession;
+
+ public FullTextEntityManagerImpl(EntityManager em) {
+ this.em = em;
+ Object delegate = em.getDelegate();
+ if ( delegate == null ) {
+ throw new SearchException("Trying to use Hibernate Search without an Hibernate EntityManager (no delegate)");
+ }
+ else if ( Session.class.isAssignableFrom( delegate.getClass() ) ) {
+ ftSession = Search.createFullTextSession( (Session) delegate );
+ }
+ else if ( EntityManager.class.isAssignableFrom( delegate.getClass() ) ) {
+ //Some app servers wrap the EM twice
+ delegate = ( (EntityManager) delegate).getDelegate();
+ if ( delegate == null ) {
+ throw new SearchException("Trying to use Hibernate Search without an Hibernate EntityManager (no delegate)");
+ }
+ else if ( Session.class.isAssignableFrom( delegate.getClass() ) ) {
+ ftSession = Search.createFullTextSession( (Session) delegate );
+ }
+ else {
+ throw new SearchException("Trying to use Hibernate Search without an Hibernate EntityManager: " + delegate.getClass() );
+ }
+ }
+ else {
+ throw new SearchException("Trying to use Hibernate Search without an Hibernate EntityManager: " + delegate.getClass() );
+ }
+ }
+
+ public FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery, Class... entities) {
+ return new FullTextQueryImpl( ftSession.createFullTextQuery( luceneQuery, entities ), ftSession );
+ }
+
+ public void index(Object entity) {
+ ftSession.index( entity );
+ }
+
+ public SearchFactory getSearchFactory() {
+ return ftSession.getSearchFactory();
+ }
+
+
+ public void persist(Object entity) {
+ em.persist( entity );
+ }
+
+ public <T> T merge(T entity) {
+ return em.merge( entity );
+ }
+
+ public void remove(Object entity) {
+ em.remove( entity );
+ }
+
+ public <T> T find(Class<T> entityClass, Object primaryKey) {
+ return em.find( entityClass, primaryKey );
+ }
+
+ public <T> T getReference(Class<T> entityClass, Object primaryKey) {
+ return em.getReference( entityClass, primaryKey );
+ }
+
+ public void flush() {
+ em.flush();
+ }
+
+ public void setFlushMode(FlushModeType flushMode) {
+ em.setFlushMode( flushMode );
+ }
+
+ public FlushModeType getFlushMode() {
+ return em.getFlushMode();
+ }
+
+ public void lock(Object entity, LockModeType lockMode) {
+ em.lock( entity, lockMode );
+ }
+
+ public void refresh(Object entity) {
+ em.refresh( entity );
+ }
+
+ public void clear() {
+ em.clear();
+ }
+
+ public boolean contains(Object entity) {
+ return em.contains( entity );
+ }
+
+ public Query createQuery(String ejbqlString) {
+ return em.createQuery( ejbqlString );
+ }
+
+ public Query createNamedQuery(String name) {
+ return em.createNamedQuery( name );
+ }
+
+ public Query createNativeQuery(String sqlString) {
+ return em.createNativeQuery( sqlString );
+ }
+
+ public Query createNativeQuery(String sqlString, Class resultClass) {
+ return em.createNativeQuery( sqlString, resultClass );
+ }
+
+ public Query createNativeQuery(String sqlString, String resultSetMapping) {
+ return em.createNativeQuery( sqlString, resultSetMapping );
+ }
+
+ public void joinTransaction() {
+ em.joinTransaction();
+ }
+
+ public Object getDelegate() {
+ return em.getDelegate();
+ }
+
+ public void close() {
+ em.close();
+ }
+
+ public boolean isOpen() {
+ return em.isOpen();
+ }
+
+ public EntityTransaction getTransaction() {
+ return em.getTransaction();
+ }
+}
17 years, 5 months
Hibernate SVN: r11702 - in trunk/sandbox/maven-poc/plugins: maven-docbook-support-plugin and 12 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-06-22 16:58:27 -0400 (Fri, 22 Jun 2007)
New Revision: 11702
Added:
trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/
trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/pom.xml
trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/src/
trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/src/main/
trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/src/main/java/
trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/src/main/java/org/
trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/src/main/java/org/jboss/
trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/src/main/java/org/jboss/maven/
trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/src/main/java/org/jboss/maven/plugin/
trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/src/main/java/org/jboss/maven/plugin/docbook/
trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/src/main/java/org/jboss/maven/plugin/docbook/support/
trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/src/main/java/org/jboss/maven/plugin/docbook/support/DocBookSupportResourcesMojo.java
trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/src/main/resources/
trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/src/main/resources/META-INF/
trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/src/main/resources/META-INF/plexus/
trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/src/main/resources/META-INF/plexus/components.xml
Log:
added the plugin for the docbook-support packaging
Added: trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/pom.xml
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/pom.xml (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/pom.xml 2007-06-22 20:58:27 UTC (rev 11702)
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-docbook-support-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>maven-plugin</packaging>
+
+ <name>DocBook Support Packaging</name>
+ <description>Plugin defining a docbook-support packaging for support of DocBook transformations.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>1.0.4</version>
+ </dependency>
+ </dependencies>
+
+</project>
Added: trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/src/main/java/org/jboss/maven/plugin/docbook/support/DocBookSupportResourcesMojo.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/src/main/java/org/jboss/maven/plugin/docbook/support/DocBookSupportResourcesMojo.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/src/main/java/org/jboss/maven/plugin/docbook/support/DocBookSupportResourcesMojo.java 2007-06-22 20:58:27 UTC (rev 11702)
@@ -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.plugin.docbook.support;
+
+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 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: trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/src/main/resources/META-INF/plexus/components.xml
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/src/main/resources/META-INF/plexus/components.xml (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-docbook-support-plugin/src/main/resources/META-INF/plexus/components.xml 2007-06-22 20:58:27 UTC (rev 11702)
@@ -0,0 +1,35 @@
+<component-set>
+
+ <components>
+
+ <component>
+ <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
+ <role-hint>docbook-support</role-hint>
+ <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
+ <configuration>
+ <phases>
+ <process-resources>org.jboss.maven.plugins:maven-docbook-support-plugin:resources</process-resources>
+ <package>org.apache.maven.plugins:maven-jar-plugin:jar</package>
+ <install>org.apache.maven.plugins:maven-install-plugin:install</install>
+ <deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
+ </phases>
+ </configuration>
+ </component>
+
+ <component>
+ <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+ <role-hint>docbook-support</role-hint>
+ <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+ <configuration>
+ <type>docbook-support</type>
+ <extension>jar</extension>
+ <packaging>jar</packaging>
+ <language>java</language>
+ <addedToClasspath>false</addedToClasspath>
+ <includesDependencies>true</includesDependencies>
+ </configuration>
+ </component>
+
+ </components>
+
+</component-set>
\ No newline at end of file
17 years, 5 months