org.jboss.maven.plugins.jdocbook.GenerationMojo Maven / Gradle / Ivy
/*
* Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, v. 2.1. This program is distributed in the
* hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. You should have received a
* copy of the GNU Lesser General Public License, v.2.1 along with this
* distribution; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Red Hat Author(s): Steve Ebersole
*/
package org.jboss.maven.plugins.jdocbook;
import java.io.File;
import org.codehaus.plexus.util.FileUtils;
import org.jboss.maven.plugins.jdocbook.gen.util.Formatting;
import org.jboss.maven.plugins.jdocbook.gen.format.FormatHandlerFactory;
import org.jboss.maven.plugins.jdocbook.gen.RenderingException;
import org.jboss.maven.plugins.jdocbook.gen.XSLTException;
import org.apache.maven.artifact.Artifact;
/**
* This mojo's responsibility within the plugin/packaging is actually performing
* the DocBook transformations. At the highest level, it takes the source and
* process it via the specified DocBook XSLT to produce output.
*
* @goal generate
* @phase compile
* @requiresDependencyResolution
*
* @author Steve Ebersole
*/
public class GenerationMojo extends AbstractDocBookMojo {
protected void process(Formatting[] formattings) throws XSLTException, RenderingException {
if ( !sourceDirectory.exists() ) {
getLog().info( "sourceDirectory [" + sourceDirectory.getAbsolutePath() + "] did not exist" );
return;
}
File source = new File( sourceDirectory, sourceDocumentName );
if ( !source.exists() ) {
getLog().info( "source [" + source.getAbsolutePath() + "] did not exist" );
return;
}
if ( !targetDirectory.exists() ) {
FileUtils.mkdir( targetDirectory.getAbsolutePath() );
}
if ( options.getDocbookVersion() == null ) {
processArtifacts(
new ArtifactProcessor() {
public void process(Artifact artifact) {
if ( "net.sf.docbook".equals( artifact.getGroupId() ) &&
"docbook".equals( artifact.getArtifactId() ) ) {
getLog().debug( "Found docbook version : " + artifact.getVersion() );
if ( options.getDocbookVersion() != null ) {
getLog().warn( "found multiple docbook versions" );
}
options.setDocbookVersion( artifact.getVersion() );
}
}
}
);
}
File fontConfigFile = null;
if ( fontConfig != null ) {
getLog().debug( "checking for fontConfig existence [" + fontConfig + "]" );
if ( stagingDirectory != null ) {
File tmp = new File( stagingDirectory, fontConfig );
if ( tmp.exists() ) {
getLog().info( "using font configuration : " + tmp.getAbsolutePath() );
fontConfigFile = tmp;
}
}
}
FormatHandlerFactory formatHandlerFactory = new FormatHandlerFactory(
options,
source,
targetDirectory,
stagingDirectory,
fontConfigFile,
project,
getLog()
);
for ( int i = 0; i < formattings.length; i++ ) {
formatHandlerFactory.buildFormatHandler( formattings[i] ).render( source );
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy