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
    • Constructor Detail

      • AbstractJarMojo

        public AbstractJarMojo()
    • Method Detail

      • getClassesDirectory

        protected abstract 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()
        Returns:
        the project
      • getClassifier

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

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

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

        public 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()
        Returns:
        true in case where the classifier is not null and contains something else than white spaces.