Coverage Report - org.codehaus.plexus.maven.plugin.PlexusTestDescriptorMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
PlexusTestDescriptorMojo
0 %
0/14
N/A
3
 
 1  
 package org.codehaus.plexus.maven.plugin;
 2  
 
 3  
 /*
 4  
  * Copyright (c) 2004-2005, Codehaus.org
 5  
  * 
 6  
  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
 7  
  * associated documentation files (the "Software"), to deal in the Software without restriction,
 8  
  * including without limitation the rights to use, copy, modify, merge, publish, distribute,
 9  
  * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
 10  
  * furnished to do so, subject to the following conditions:
 11  
  * 
 12  
  * The above copyright notice and this permission notice shall be included in all copies or
 13  
  * substantial portions of the Software.
 14  
  * 
 15  
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
 16  
  * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 17  
  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
 18  
  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 19  
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 20  
  */
 21  
 
 22  
 import java.io.File;
 23  
 
 24  
 import org.apache.maven.plugin.MojoExecutionException;
 25  
 import org.codehaus.plexus.metadata.MetadataGenerationRequest;
 26  
 
 27  
 /**
 28  
  * Generates a Plexus <tt>components.xml</tt> component descriptor file from test source (javadoc)
 29  
  * or test class annotations.
 30  
  * 
 31  
  * @goal generate-test-metadata
 32  
  * @phase process-test-classes
 33  
  * @requiresDependencyResolution test
 34  
  * @author Jason van Zyl
 35  
  * @author Trygve Laugst&oslash;l
 36  
  * @version $Id$
 37  
  */
 38  0
 public class PlexusTestDescriptorMojo
 39  
     extends AbstractDescriptorMojo
 40  
 {
 41  
     /**
 42  
      * The output location for the generated descriptor.
 43  
      * 
 44  
      * @parameter default-value="${project.build.testOutputDirectory}/META-INF/plexus/components.xml"
 45  
      * @required
 46  
      */
 47  
     protected File testGeneratedMetadata;
 48  
 
 49  
     /**
 50  
      * The location of manually crafted component descriptors. The contents of the descriptor files in this directory is
 51  
      * merged with the information extracted from the project's sources/classes.
 52  
      * 
 53  
      * @parameter default-value="${basedir}/src/test/resources/META-INF/plexus"
 54  
      * @required
 55  
      */
 56  
     protected File testStaticMetadataDirectory;
 57  
 
 58  
     /**
 59  
      * The output location for the intermediary descriptor. This descriptors contains only the information extracted
 60  
      * from the project's sources/classes.
 61  
      * 
 62  
      * @parameter default-value="${project.build.directory}/test-components.xml"
 63  
      * @required
 64  
      */
 65  
     protected File testIntermediaryMetadata;
 66  
 
 67  
     public void execute()
 68  
         throws MojoExecutionException
 69  
     {
 70  0
         MetadataGenerationRequest request = new MetadataGenerationRequest();
 71  
 
 72  
         try
 73  
         {
 74  0
             request.classpath = mavenProject.getTestClasspathElements();
 75  0
             request.classesDirectory = new File( mavenProject.getBuild().getTestOutputDirectory() );
 76  0
             request.sourceDirectories = mavenProject.getTestCompileSourceRoots();
 77  0
             request.sourceEncoding = sourceEncoding;
 78  0
             request.componentDescriptorDirectory = testStaticMetadataDirectory;
 79  0
             request.intermediaryFile = testIntermediaryMetadata;
 80  0
             request.outputFile = testGeneratedMetadata;
 81  
             
 82  0
             metadataGenerator.generateDescriptor( request );
 83  
         }
 84  0
         catch ( Exception e )
 85  
         {
 86  0
             throw new MojoExecutionException( "Error generating test metadata: ", e );
 87  0
         }
 88  0
     }
 89  
 }