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.ParameterAdapter;
23 import eu.simuline.m2latex.core.Target;
24 import eu.simuline.m2latex.core.LatexProcessor;
25
26 import org.apache.maven.plugin.MojoFailureException;
27
28 import org.apache.maven.plugins.annotations.Mojo;
29 import org.apache.maven.plugins.annotations.LifecyclePhase;
30
31 import java.util.SortedSet;
32
33 /**
34 * Builds documents in the formats configured in the pom from LaTeX sources
35 * for the goal <code>cfg</code>
36 * tied to the lifecycle phase <code>site</code>.
37 */
38 @Mojo(name = "cfg", defaultPhase = LifecyclePhase.SITE)
39 public class CfgLatexMojo extends AbstractLatexMojo {
40
41 // api-docs inherited from ParameterAdapter
42 // FIXME: not required by ClearMojo
43 public SortedSet<Target> getTargetSet() {
44 return this.settings.getTargetSet();
45 }
46
47 /**
48 * Invoked by maven executing the plugin.
49 * <p>
50 * Logging:
51 * <ul>
52 * <li> WFU01: Cannot read directory...
53 * <li> WFU03: cannot close
54 * <li> EFU05: Cannot delete
55 * <li> EFU07, EFU08, EFU09: if filtering a file fails.
56 * <li> WPP02: tex file may be latex main file
57 * <li> WPP03: Skipped processing of files with suffixes ...
58 * <li> EEX01, EEX02, EEX03, WEX04, WEX05:
59 * applications for preprocessing graphic files
60 * or processing a latex main file fails.
61 * </ul>
62 * @throws MojoFailureException
63 * <ul>
64 * <li> TSS01 if
65 * the tex source directory does either not exist
66 * or is not a directory.
67 * <li> TSS02 if
68 * the tex source processing directory does either not exist
69 * or is not a directory.
70 * <li> TSS03 if
71 * the output directory exists and is no directory.
72 * <li> TEX01 if
73 * invocation of applications for preprocessing graphic files
74 * or processing a latex main file fails
75 * <li> TFU01 if
76 * the target directory that would be returned
77 * exists already as a regular file.
78 * <li> TFU03, TFU04, TFU05, TFU06 if
79 * copy of output files to target folder fails.
80 * For details see {@link LatexProcessor#create()}.
81 * </ul>
82 */
83 public void execute() throws MojoFailureException {
84 initialize();
85 try {
86 // may throw BuildFailureException
87 // TSS01, TSS02, TSS03, TEX01, TFU01, TFU03, TFU04, TFU05, TFU06
88 // may log WFU01, WFU03, EFU05, EFU07, EFU08, EFU09
89 // WPP02, WPP03,
90 // EEX01, EEX02, EEX03, WEX04, WEX05
91 this.latexProcessor.create();
92 } catch (BuildFailureException e) {
93 throw new MojoFailureException(e.getMessage(), e.getCause());
94 }
95 }
96
97 }