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.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   * Clears all created files in the folders containing the LaTeX sources 
34   * for the goal <code>clr</code> 
35   * tied to the lifecycle phase <code>clean</code>. 
36   */
37  @Mojo(name = "clr", defaultPhase = LifecyclePhase.CLEAN)
38  public class ClearMojo 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       * </ul>
56       *
57       * @throws BuildFailureException 
58       *    TSS02 if the tex source processing directory does either not exist 
59       *    or is not a directory. 
60       */
61      public void execute() throws MojoFailureException {
62  	initialize();
63  	try {
64  	    // may throw BuildFailureException TSS02 
65  	    // may log warnings WPP02, WFU01, WFU03, EFU05 
66  	    this.latexProcessor.clearAll();
67  	} catch (BuildFailureException e) {
68  	    throw new MojoFailureException(e.getMessage(), e.getCause());
69  	}
70      }
71  
72  }