View Javadoc
1   /*
2    * The akquinet maven-latex-plugin project
3    *
4    * Copyright (c) 2011 by akquinet tech@spree GmbH
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  package eu.simuline.m2latex.mojo;
20  
21  import eu.simuline.m2latex.core.BuildFailureException;
22  import eu.simuline.m2latex.core.Target;
23  import eu.simuline.m2latex.core.LatexProcessor;// for javadoc only 
24  
25  import org.apache.maven.plugin.MojoFailureException;
26  
27  import org.apache.maven.plugins.annotations.Mojo;
28  import org.apache.maven.plugins.annotations.LifecyclePhase;
29  
30  import java.util.SortedSet;
31  
32  // documentation occurs in latex:help
33  /**
34   * Builds documents in the formats configured in the pom from LaTeX sources. 
35   * The goal is tied to the lifecycle phase <code>site</code> by default. 
36   */
37  @Mojo(name = "cfg", defaultPhase = LifecyclePhase.SITE)
38  // https://maven.apache.org/plugin-tools/maven-plugin-tools-annotations/index.html
39  public class CfgLatexMojo extends AbstractLatexMojo {
40  
41    public SortedSet<Target> getTargetSet() throws BuildFailureException {
42      return this.settings.getTargets();
43    }
44  
45    /**
46     * Invoked by maven executing the plugin. 
47     * <p>
48     * Logging: 
49     * <ul>
50     * <li> WFU01: Cannot read directory... 
51     * <li> WFU03: cannot close
52     * <li> EFU05: Cannot delete
53     * <li> EFU07, EFU08, EFU09: if filtering a file fails. 
54     * <li> WPP02: tex file may be latex main file 
55     * <li> WPP03: Skipped processing of files with suffixes ... 
56     * <li> WPP05: Included tex files which are no latex main files 
57     * <li> WPP06: Included tex files which are no latex main files 
58     * <li> WPP07: inluded/excluded files not identified by their names.
59     * <li> EEX01, EEX02, EEX03, WEX04, WEX05: 
60     *      applications for preprocessing graphic files 
61     *      or processing a latex main file fails. 
62     * </ul>
63     * @throws MojoFailureException
64     *    <ul>
65     *    <li> TSS01 if 
66     *    the tex source directory does either not exist 
67     *    or is not a directory. 
68     *    <li> TSS02 if 
69     *    the tex source processing directory does either not exist 
70     *    or is not a directory. 
71     *    <li> TSS03 if 
72     *    the output directory exists and is no directory. 
73     *    <li> TEX01 if 
74     *    invocation of applications for preprocessing graphic files 
75     *    or processing a latex main file fails 
76     *    <li> TFU01 if 
77     *    the target directory that would be returned 
78     *    exists already as a regular file. 
79     *    <li> TFU03, TFU04, TFU05, TFU06 if 
80     *    copy of output files to target folder fails. 
81     *    For details see {@link LatexProcessor#create(SortedSet)}. 
82     *    </ul>
83     */
84    public void execute() throws MojoFailureException {
85      initialize();
86      try {
87        // may throw BuildFailureException 
88        // TSS01, TSS02, TSS03, TEX01, TFU01, TFU03, TFU04, TFU05, TFU06, TLP01 
89        // may log WFU01, WFU03, EFU05, EFU07, EFU08, EFU09 
90        // WPP02, WPP03, WPP05, WPP06, WPP07, 
91        // EEX01, EEX02, EEX03, WEX04, WEX05 
92        this.latexProcessor.create(getTargetSet());
93      } catch (BuildFailureException e) {
94        throw new MojoFailureException(e.getMessage(), e.getCause());
95      }
96    }
97  
98  }