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  import eu.simuline.m2latex.core.MetaInfo;
24  
25  import org.apache.maven.plugins.annotations.Mojo;
26  import org.apache.maven.plugins.annotations.LifecyclePhase;
27  
28  import org.apache.maven.plugin.MojoFailureException;
29  
30  import java.util.SortedSet;
31  //import java.util.EnumSet;
32  
33  /**
34   * Displays version info of this plugin but above all on all converters 
35   * (except makeindex). 
36   */
37  @Mojo(name = "vrs")
38  // TBD: maybe verify
39  // in fact, Metainfo can give more info than just versioning 
40  //, defaultPhase = LifecyclePhase.CLEAN
41  public class VersionMojo extends AbstractLatexMojo {
42  
43      // api-docs inherited from ParameterAdapter 
44      // FIXME: not required by ClearMojo, GraphicsMojo, ChkMojo  
45       public SortedSet<Target> getTargetSet() {
46      	throw new IllegalStateException();
47      }
48  
49       /**
50        * Prints meta information, mainly version information 
51        * on this software and on the converters used. 
52        * <p>
53        * WMI01: If the version string of a converter cannot be read. 
54        * WMI02: If the version of a converter is not as expected. 
55        * @return
56        *    whether a warning has been issued. 
57        * @throws MojoFailureException
58        *    <ul>
59        *    <li>TMI01: if the stream to either the manifest file 
60        *        or to a property file, either {@LINK #VERSION_PROPS_FILE} 
61        *        or {@link MetaInfo.GitProperties#GIT_PROPS_FILE} could not be created. </li>
62        *    <li>TMI02: if the properties could not be read 
63        *        from one of the two property files mentioned above. </li>
64        *    </ul>
65        */
66  
67      public void execute() throws MojoFailureException {
68  	// TBD: redesign 
69  	initialize();
70  	try {
71  	    // warnings: WMI01, WMI02
72  	    this.latexProcessor.printMetaInfo();
73  	} catch (BuildFailureException e) {
74  	    // may throw Exception TMI01, TMI02
75  	    throw new MojoFailureException(e.getMessage(), e.getCause());
76  	}
77      }
78  
79  }