Coverage Report - org.apache.maven.plugin.plugin.HelpGeneratorMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
HelpGeneratorMojo
0 %
0/7
0 %
0/4
1,667
 
 1  
 package org.apache.maven.plugin.plugin;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *   http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import org.apache.maven.plugin.MojoExecutionException;
 23  
 import org.apache.maven.plugins.annotations.Component;
 24  
 import org.apache.maven.plugins.annotations.LifecyclePhase;
 25  
 import org.apache.maven.plugins.annotations.Mojo;
 26  
 import org.apache.maven.plugins.annotations.Parameter;
 27  
 import org.apache.maven.tools.plugin.generator.Generator;
 28  
 import org.apache.maven.tools.plugin.generator.PluginHelpGenerator;
 29  
 import org.codehaus.plexus.velocity.VelocityComponent;
 30  
 
 31  
 import java.io.File;
 32  
 
 33  
 /**
 34  
  * Generates a <code>HelpMojo</code> class.
 35  
  *
 36  
  * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
 37  
  * @version $Id: HelpGeneratorMojo.java 1345787 2012-06-03 21:58:22Z hboutemy $
 38  
  * @since 2.4
 39  
  */
 40  
 @Mojo( name = "helpmojo", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true )
 41  0
 public class HelpGeneratorMojo
 42  
     extends AbstractGeneratorMojo
 43  
 {
 44  
     /**
 45  
      * The directory where the generated <code>HelpMojo</code> file will be put.
 46  
      */
 47  
     @Parameter( defaultValue = "${project.build.directory}/generated-sources/plugin" )
 48  
     protected File outputDirectory;
 49  
 
 50  
     /**
 51  
      * The name of the package for the generated <code>HelpMojo</code>. By default, the package will be calculated based
 52  
      * on the packages of the other plugin goals.
 53  
      *
 54  
      * @since 2.6
 55  
      */
 56  
     @Parameter
 57  
     private String helpPackageName;
 58  
 
 59  
     /**
 60  
      * Velocity component.
 61  
      */
 62  
     @Component
 63  
     private VelocityComponent velocity;
 64  
 
 65  
     /**
 66  
      * {@inheritDoc}
 67  
      */
 68  
     protected File getOutputDirectory()
 69  
     {
 70  0
         return outputDirectory;
 71  
     }
 72  
 
 73  
     /**
 74  
      * {@inheritDoc}
 75  
      */
 76  
     protected Generator createGenerator()
 77  
     {
 78  0
         return new PluginHelpGenerator().setHelpPackageName( helpPackageName ).setVelocityComponent( this.velocity );
 79  
     }
 80  
 
 81  
     /**
 82  
      * {@inheritDoc}
 83  
      */
 84  
     public void execute()
 85  
         throws MojoExecutionException
 86  
     {
 87  0
         super.execute();
 88  
 
 89  0
         if ( !project.getCompileSourceRoots().contains( outputDirectory.getAbsolutePath() ) && !skip )
 90  
         {
 91  0
             project.addCompileSourceRoot( outputDirectory.getAbsolutePath() );
 92  
         }
 93  
 
 94  0
     }
 95  
 
 96  
 }