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.Target;
22 import eu.simuline.m2latex.core.BuildFailureException;
23
24 import org.apache.maven.plugins.annotations.Mojo;
25
26 import org.apache.maven.plugin.MojoFailureException;
27
28 import java.util.SortedSet;
29 //import java.util.EnumSet;
30
31 /**
32 * Transforms all graphic files into formats
33 * which can be included into LaTeX files
34 * for the goal <code>grp</code> which is not tied to a lifecycle phase.
35 */
36 @Mojo(name = "grp")
37 public class GraphicsMojo extends AbstractLatexMojo {
38
39 // api-docs inherited from ParameterAdapter
40 // FIXME: not required by ClearMojo, GraphicsMojo, ChkMojo
41 public SortedSet<Target> getTargetSet() {
42 throw new IllegalStateException();
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 file
52 * <li> EFU07, EFU08, EFU09: if filtering a file fails.
53 * <li> WPP02: tex file may be latex main file
54 * <li> WPP03: Skipped processing of files with suffixes ...
55 * <li> EEX01, EEX02, EEX03, WEX04, WEX05:
56 * if running graphic processors failed.
57 * </ul>
58 *
59 * @throws MojoFailureException
60 * <ul>
61 * <li>
62 * TSS02 if the tex source processing directory does either not exist
63 * or is not a directory.
64 * <li>
65 * TEX01 invoking FIXME
66 * </ul>
67 */
68 public void execute() throws MojoFailureException {
69 initialize();
70 try {
71 // may throw BuildFailureException TSS02, TEX01
72 // may log warnings WFU01, WFU03, WPP02, WPP03,
73 // EEX01, EEX02, EEX03, WEX04, WEX05: EFU07, EFU08, EFU09
74 this.latexProcessor.processGraphics();
75 } catch (BuildFailureException e) {
76 throw new MojoFailureException(e.getMessage(), e.getCause());
77 }
78 }
79 }