Coverage Report - org.apache.maven.plugin.jar.TestJarMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
TestJarMojo
0%
0/8
0%
0/2
1,25
 
 1  
 package org.apache.maven.plugin.jar;
 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 java.io.File;
 23  
 import org.apache.maven.plugin.MojoExecutionException;
 24  
 
 25  
 /**
 26  
  * Build a JAR of the test classes for the current project.
 27  
  *
 28  
  * @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
 29  
  * @version $Id: TestJarMojo.java 740305 2009-02-03 13:59:02Z bentmann $
 30  
  * @goal test-jar
 31  
  * @phase package
 32  
  * @requiresProject
 33  
  * @requiresDependencyResolution test
 34  
  */
 35  0
 public class TestJarMojo
 36  
     extends AbstractJarMojo
 37  
 {
 38  
 
 39  
     /**
 40  
      * Set this to <code>true</code> to bypass unit tests entirely.
 41  
      * Its use is <b>NOT RECOMMENDED</b>, but quite convenient on occasion.
 42  
      *
 43  
      * @parameter expression="${maven.test.skip}"
 44  
      */
 45  
     private boolean skip;
 46  
 
 47  
     /**
 48  
      * Directory containing the test classes and resource files that should be packaged into the JAR.
 49  
      *
 50  
      * @parameter expression="${project.build.testOutputDirectory}"
 51  
      * @required
 52  
      */
 53  
     private File testClassesDirectory;
 54  
 
 55  
     protected String getClassifier()
 56  
     {
 57  0
         return "tests";
 58  
     }
 59  
 
 60  
     /**
 61  
      * @return type of the generated artifact
 62  
      */
 63  
     protected String getType()
 64  
     {
 65  0
         return "test-jar";
 66  
     }
 67  
 
 68  
     /**
 69  
      * Return the test-classes directory, to serve as the root of the tests jar.
 70  
      */
 71  
     protected File getClassesDirectory()
 72  
     {
 73  0
         return testClassesDirectory;
 74  
     }
 75  
 
 76  
         public void execute()
 77  
         throws MojoExecutionException
 78  
     {
 79  0
         if ( skip )
 80  
         {
 81  0
             getLog().info( "Skipping packaging of the test-jar" );
 82  
         }
 83  
         else
 84  
         {
 85  0
             super.execute();
 86  
         }
 87  0
     }
 88  
 }