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.Parameter; 25 import org.apache.maven.plugins.annotations.LifecyclePhase; 26 27 import org.apache.maven.plugin.MojoFailureException; 28 29 // documentation occurs in latex:help 30 /** 31 * Displays version info of this plugin but above all on all converters. 32 * The goal is tied to the lifecycle phase <code>validate</code> by default. 33 */ 34 @Mojo(name = "vrs", defaultPhase = LifecyclePhase.VALIDATE) 35 // TBD: maybe verify 36 // in fact, Metainfo can give more info than just versioning 37 public class VersionMojo extends AbstractLatexMojo { 38 39 /** 40 * Indicates whether the goal <code>vrs</code> displays warnings only; 41 * else also creates infos. 42 * Infos refer to the version of this plugin, 43 * but also on the versions of the converters found 44 * and on the converters excluded. 45 * Warnings are emitted e.g. if a version does not fit the expectations. 46 * This defaults to <code>false</code> displaying also info. 47 * The latter is appropriate for using in command line 48 * <code>mvn latex:vrs</code>, whereas in builds by default 49 * the pom overwrites this to have output only 50 * in case something goes wrong. 51 */ 52 @Parameter(name = "versionsWarnOnly", defaultValue = "false") 53 private boolean versionsWarnOnly = false; 54 55 /** 56 * Prints meta information, mainly version information 57 * on this software and on the converters used. 58 * <p> 59 * WMI01: If the version string of a converter cannot be read. 60 * WMI02: If the version of a converter is not as expected. 61 * 62 * @throws MojoFailureException 63 * <ul> 64 * <li>TMI01: if the stream to either the manifest file 65 * or to a property file, either {@LINK #VERSION_PROPS_FILE} 66 * or {@link eu.simuline.m2latex.core.MetaInfo.GitProperties#GIT_PROPS_FILE} could not be created. </li> 67 * <li>TMI02: if the properties could not be read 68 * from one of the two property files mentioned above. </li> 69 * <li>TSS05: if converters are excluded in the pom which are not known. </li> 70 * </ul> 71 */ 72 public void execute() throws MojoFailureException { 73 // TBD: redesign 74 initialize(); 75 try { 76 // warnings: WMI01, WMI02, 77 // may throw build failure exception TSS05 78 this.latexProcessor.printMetaInfo(!this.versionsWarnOnly); 79 } catch (BuildFailureException e) { 80 // may throw Exception TMI01, TMI02, TSS05 81 throw new MojoFailureException(e.getMessage(), e.getCause()); 82 } 83 } 84 85 }