Class TestJarMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.maven.plugins.jar.AbstractJarMojo
org.apache.maven.plugins.jar.TestJarMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="test-jar", defaultPhase=PACKAGE, requiresProject=true, threadSafe=true, requiresDependencyResolution=TEST) public class TestJarMojo extends AbstractJarMojo
Build a JAR of the test classes for the current project.
Version:
$Id$
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private String
    Classifier to use for test-jar.
    private boolean
    Set this to true to bypass test-jar generation.
    private File
    Directory containing the test classes and resource files that should be packaged into the JAR.

    Fields inherited from interface org.apache.maven.plugin.Mojo

    ROLE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Generates the JAR.
    protected File
    Return the specific output directory to serve as the root for the archive.
    protected String
    Overload this to produce a jar with another classifier, for example a test-jar.
    protected String
    Overload this to produce a test-jar, for example.

    Methods inherited from class org.apache.maven.plugins.jar.AbstractJarMojo

    createArchive, getJarFile, getProject, hasClassifier

    Methods inherited from class org.apache.maven.plugin.AbstractMojo

    getLog, getPluginContext, setLog, setPluginContext

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • skip

      @Parameter(property="maven.test.skip") private boolean skip
      Set this to true to bypass test-jar generation. Its use is NOT RECOMMENDED, but quite convenient on occasion.
    • testClassesDirectory

      @Parameter(defaultValue="${project.build.testOutputDirectory}", required=true) private File testClassesDirectory
      Directory containing the test classes and resource files that should be packaged into the JAR.
    • classifier

      @Parameter(defaultValue="tests") private String classifier
      Classifier to use for test-jar.
  • Constructor Details

    • TestJarMojo

      public TestJarMojo()
  • Method Details

    • getClassifier

      protected String getClassifier()
      Overload this to produce a jar with another classifier, for example a test-jar.
      Specified by:
      getClassifier in class AbstractJarMojo
      Returns:
      get the classifier.
    • getType

      protected String getType()
      Overload this to produce a test-jar, for example.
      Specified by:
      getType in class AbstractJarMojo
      Returns:
      return the type.
    • getClassesDirectory

      protected File getClassesDirectory()
      Return the specific output directory to serve as the root for the archive.
      Specified by:
      getClassesDirectory in class AbstractJarMojo
      Returns:
      get classes directory.
    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException
      Generates the JAR.
      Specified by:
      execute in interface org.apache.maven.plugin.Mojo
      Overrides:
      execute in class AbstractJarMojo
      Throws:
      org.apache.maven.plugin.MojoExecutionException - in case of an error.