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  
23  import org.apache.maven.plugins.annotations.Mojo;
24  import org.apache.maven.plugins.annotations.LifecyclePhase;
25  
26  import org.apache.maven.plugin.MojoFailureException;
27  
28  // documentation occurs in latex:help
29  /**
30   * Clears all created files in the folders containing the LaTeX sources. 
31   * The goal is tied to the lifecycle phase <code>clean</code> by default.  
32   */
33  @Mojo(name = "clr", defaultPhase = LifecyclePhase.CLEAN)
34  // TBD: research: 
35  // https://maven.apache.org/plugin-tools/maven-plugin-tools-annotations/index.html
36  // @Execute( goal = "<goal-name>",
37  //           phase = LifecyclePhase.<phase>,
38  //           lifecycle = "<lifecycle-id>" )
39  public class ClearMojo extends AbstractLatexMojo {
40  
41    /**
42     * Invoked by maven executing the plugin. 
43     * <p>
44     * Logging: 
45     * <ul>
46     * <li> WPP02: tex file may be latex main file 
47     * <li> WFU01: Cannot read directory...
48     * <li> WFU03: cannot close tex file 
49     * <li> EFU05: Failed to delete file 
50     * <li> WFU10, WFU11: if a config file is not written by this software 
51     * or it is not clear or the reader cannot close. 
52     * </ul>
53     *
54     * @throws BuildFailureException 
55     *    TSS02 if the tex source processing directory does either not exist 
56     *    or is not a directory. 
57     */
58    public void execute() throws MojoFailureException {
59      initialize();
60      try {
61        // may throw BuildFailureException TSS02 
62        // may log warnings WPP02, WFU01, WFU03, EFU05, WFU10, WFU11
63        this.latexProcessor.clearAll();
64      } catch (BuildFailureException e) {
65        throw new MojoFailureException(e.getMessage(), e.getCause());
66      }
67    }
68  
69  }