001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2012-2015 ForgeRock AS. 015 */ 016 017package org.forgerock.doc.maven; 018 019import org.apache.maven.plugin.MojoExecutionException; 020import org.apache.maven.plugin.MojoFailureException; 021import org.apache.maven.plugins.annotations.LifecyclePhase; 022import org.apache.maven.plugins.annotations.Mojo; 023import org.forgerock.doc.maven.build.ChunkedHtml; 024import org.forgerock.doc.maven.build.Epub; 025import org.forgerock.doc.maven.build.Manpage; 026import org.forgerock.doc.maven.build.Pdf; 027import org.forgerock.doc.maven.build.Rtf; 028import org.forgerock.doc.maven.build.SingleHtml; 029import org.forgerock.doc.maven.build.Webhelp; 030import org.forgerock.doc.maven.build.Xhtml5; 031import org.forgerock.doc.maven.build.HtmlForBootstrap; 032import org.forgerock.doc.maven.post.Html; 033import org.forgerock.doc.maven.post.Bootstrap; 034import org.forgerock.doc.maven.post.ManpagePost; 035import org.forgerock.doc.maven.post.NoOp; 036import org.forgerock.doc.maven.post.WebhelpPost; 037import org.forgerock.doc.maven.post.Xhtml; 038import org.forgerock.doc.maven.pre.ArbitraryResourceCopier; 039import org.forgerock.doc.maven.pre.Branding; 040import org.forgerock.doc.maven.pre.Fop; 041 042import java.util.List; 043 044/** 045 * Call other classes to perform pre-site build. 046 */ 047@Mojo(name = "build", defaultPhase = LifecyclePhase.PRE_SITE) 048public class PreSiteMojo extends AbstractDocbkxMojo { 049 050 /** 051 * Call other classes to perform pre-site build. 052 * 053 * @throws MojoExecutionException Failed to build successfully. 054 * @throws MojoFailureException Failed to build successfully. 055 */ 056 @Override 057 public void execute() throws MojoExecutionException, MojoFailureException { 058 059 // Must start with pre-processed sources. 060 if (getDocbkxModifiableSourcesDirectory() == null 061 || !getDocbkxModifiableSourcesDirectory().exists()) { 062 throw new MojoExecutionException("Preprocessed sources unavailable."); 063 } 064 065 // Prepare for build. 066 new Branding(this).execute(); 067 068 final List<Format> formats = getFormats(); 069 070 if (formats.contains(Format.pdf) || formats.contains(Format.rtf)) { 071 new Fop(this).execute(); 072 } 073 074 // Perform build. 075 if (formats.contains(Format.epub)) { 076 new Epub(this).execute(); 077 } 078 if (formats.contains(Format.html)) { 079 new SingleHtml(this).execute(); 080 new ChunkedHtml(this).execute(); 081 } 082 if (formats.contains(Format.man)) { 083 new Manpage(this).execute(); 084 } 085 if (formats.contains(Format.pdf)) { 086 new Pdf(this).execute(); 087 } 088 if (formats.contains(Format.rtf)) { 089 new Rtf(this).execute(); 090 } 091 if (formats.contains(Format.webhelp)) { 092 new Webhelp(this).execute(); 093 } 094 if (formats.contains(Format.xhtml5)) { 095 new Xhtml5(this).execute(); 096 } 097 if (formats.contains(Format.bootstrap)) { 098 new HtmlForBootstrap(this).execute(); 099 } 100 101 // Perform post-processing. 102 if (formats.contains(Format.epub)) { 103 new NoOp(this).execute(); 104 } 105 if (formats.contains(Format.html)) { 106 new Html(this).execute(); 107 } 108 if (formats.contains(Format.man)) { 109 new ManpagePost(this).execute(); 110 } 111 if (formats.contains(Format.pdf)) { 112 new NoOp(this).execute(); 113 } 114 if (formats.contains(Format.rtf)) { 115 new NoOp(this).execute(); 116 } 117 if (formats.contains(Format.webhelp)) { 118 new WebhelpPost(this).execute(); 119 } 120 if (formats.contains(Format.xhtml5)) { 121 new Xhtml(this).execute(); 122 } 123 if (formats.contains(Format.bootstrap)) { 124 new Bootstrap(this).execute(); 125 } 126 127 // Optionally copy arbitrary resources. 128 new ArbitraryResourceCopier(this).execute(); 129 } 130}