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 import org.apache.maven.plugins.annotations.LifecyclePhase;
26
27 import org.apache.maven.plugin.MojoFailureException;
28
29 import java.util.SortedSet;
30 //import java.util.EnumSet;
31
32 /**
33 * Checks all latex main files after having created all graphical files.
34 * <p>
35 * Defines the goal <code>chk</code> which is not tied to a lifecycle phase.
36 */
37 @Mojo(name = "chk")
38 public class ChkMojo extends AbstractLatexMojo {
39
40 // api-docs inherited from ParameterAdapter
41 // FIXME: not required by ClearMojo, GraphicsMojo, ChkMojo
42 public SortedSet<Target> getTargetSet() {
43 throw new IllegalStateException();
44 }
45
46 /**
47 * Invoked by maven executing the plugin.
48 * <p>
49 * Logging:
50 * <ul>
51 * <li> WPP02: tex file may be latex main file
52 * <li> WFU01: Cannot read directory...
53 * <li> WFU03: cannot close tex file
54 * <li> EFU05: Failed to delete file
55 * <li> EFU07, EFU08, EFU09: if filtering a file fails.
56 * </ul>
57 *
58 * @throws BuildFailureException
59 * TSS02 if the tex source processing directory does either not exist
60 * or is not a directory.
61 */
62 public void execute() throws MojoFailureException {
63 initialize();
64 try {
65 // may throw BuildFailureException TSS02
66 // may log warnings WPP02, WFU01, WFU03, EFU05
67 // EFU07, EFU08, EFU09: if filtering a file fails.
68 this.latexProcessor.checkAll();
69 } catch (BuildFailureException e) {
70 throw new MojoFailureException(e.getMessage(), e.getCause());
71 }
72 }
73
74 }