Class AbstractJarMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
    Direct Known Subclasses:
    JarMojo, TestJarMojo

    public abstract class AbstractJarMojo
    extends org.apache.maven.plugin.AbstractMojo
    Base class for creating a jar from project classes.
    Version:
    $Id$
    Author:
    Emmanuel Venisse
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean attach
      Specifies whether to attach the jar to the project.
      • Fields inherited from interface org.apache.maven.plugin.Mojo

        ROLE
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      java.io.File createArchive()
      Generates the JAR.
      void execute()
      Generates the JAR.
      protected abstract java.io.File getClassesDirectory()
      Return the specific output directory to serve as the root for the archive.
      protected abstract java.lang.String getClassifier()
      Overload this to produce a jar with another classifier, for example a test-jar.
      protected java.io.File getJarFile​(java.io.File basedir, java.lang.String resultFinalName, java.lang.String classifier)
      Returns the Jar file to generate, based on an optional classifier.
      protected org.apache.maven.project.MavenProject getProject()
      Return the MavenProject
      protected abstract java.lang.String getType()
      Overload this to produce a test-jar, for example.
      protected boolean hasClassifier()
      Return true if the classifier is not null and contains something other than white spaces.
      • 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 Detail

      • attach

        @Parameter(property="maven.jar.attach",
                   defaultValue="true")
        protected boolean attach
        Specifies whether to attach the jar to the project.
        Since:
        3.5.0
    • Method Detail

      • getClassesDirectory

        protected abstract java.io.File getClassesDirectory()
        Return the specific output directory to serve as the root for the archive.
        Returns:
        get classes directory.
      • getProject

        protected final org.apache.maven.project.MavenProject getProject()
        Return the MavenProject
        Returns:
        the MavenProject.
      • getClassifier

        protected abstract java.lang.String getClassifier()
        Overload this to produce a jar with another classifier, for example a test-jar.
        Returns:
        get the classifier.
      • getType

        protected abstract java.lang.String getType()
        Overload this to produce a test-jar, for example.
        Returns:
        return the type.
      • getJarFile

        protected java.io.File getJarFile​(java.io.File basedir,
                                          java.lang.String resultFinalName,
                                          java.lang.String classifier)
        Returns the Jar file to generate, based on an optional classifier.
        Parameters:
        basedir - the output directory
        resultFinalName - the name of the JAR file
        classifier - an optional classifier
        Returns:
        the file to generate
      • createArchive

        public java.io.File createArchive()
                                   throws org.apache.maven.plugin.MojoExecutionException
        Generates the JAR.
        Returns:
        The instance of File for the created archive file.
        Throws:
        org.apache.maven.plugin.MojoExecutionException - in case of an error.
      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException
        Generates the JAR.
        Throws:
        org.apache.maven.plugin.MojoExecutionException - in case of an error.
      • hasClassifier

        protected boolean hasClassifier()
        Return true if the classifier is not null and contains something other than white spaces.
        Returns:
        true if the classifier is set.