All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.maven.plugins.jdocbook.PackageMojo 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 java.io.IOException;

import org.jboss.maven.plugins.jdocbook.gen.util.Formatting;
import org.jboss.maven.plugins.jdocbook.gen.RenderingException;
import org.jboss.maven.plugins.jdocbook.gen.format.FormatHandlerFactory;
import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.archiver.jar.JarArchiver;

/**
 * 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.
 * 

* 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() ); File projectArtifactFile = new File( targetDirectory, project.getBuild().getFinalName() + ".war" ); JarArchiver archiver = new JarArchiver(); archiver.setDestFile( projectArtifactFile ); try { for ( int i = 0; i < formattings.length; i++ ) { archiver.addDirectory( new File( targetDirectory, formattings[i].getFormatName() ), formattings[i].getFormatName() + "/" ); if ( attach ) { formatHandlerFactory.buildFormatHandler( formattings[i] ).attachOutput( source, projectHelper ); } } archiver.createArchive(); } catch ( IOException e ) { throw new RenderingException( "Unable to create archive [" + projectArtifactFile.getAbsolutePath() + "]", e ); } catch ( ArchiverException e ) { throw new RenderingException( "Unable to populate archive [" + projectArtifactFile.getAbsolutePath() + "]", e ); } project.getArtifact().setFile( projectArtifactFile ); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy