Package org.apache.maven.plugins.jar
Class AbstractJarMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.apache.maven.plugins.jar.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.AbstractMojoBase class for creating a jar from project classes.- Version:
- $Id$
-
-
Field Summary
Fields Modifier and Type Field Description private org.apache.maven.archiver.MavenArchiveConfigurationarchiveThe archive configuration to use.private java.util.Map<java.lang.String,org.codehaus.plexus.archiver.Archiver>archiversThe Jar archiver.private static java.lang.String[]DEFAULT_EXCLUDESprivate static java.lang.String[]DEFAULT_INCLUDESprivate java.lang.String[]excludesList of files to exclude.private java.lang.StringfinalNameName of the generated JAR.private booleanforceCreationRequire the jar plugin to build a new JAR even if none of the contents appear to have changed.private java.lang.String[]includesList of files to include.private static java.lang.StringMODULE_DESCRIPTOR_FILE_NAMEprivate java.io.FileoutputDirectoryDirectory containing the generated JAR.private org.apache.maven.project.MavenProjectprojectThe {@link {MavenProject}.private org.apache.maven.project.MavenProjectHelperprojectHelperprivate org.apache.maven.execution.MavenSessionsessionTheMavenSession.private booleanskipIfEmptySkip creating empty archives.private booleanuseDefaultManifestFileDeprecated.For version 3.0.0 this parameter is only defined here to break the build if you use it!
-
Constructor Summary
Constructors Constructor Description AbstractJarMojo()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.io.FilecreateArchive()Generates the JAR.voidexecute()Generates the JAR.protected abstract java.io.FilegetClassesDirectory()Return the specific output directory to serve as the root for the archive.protected abstract java.lang.StringgetClassifier()Overload this to produce a jar with another classifier, for example a test-jar.private java.lang.String[]getExcludes()private java.lang.String[]getIncludes()protected java.io.FilegetJarFile(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.MavenProjectgetProject()protected abstract java.lang.StringgetType()Overload this to produce a test-jar, for example.protected booleanhasClassifier()private booleanprojectHasAlreadySetAnArtifact()
-
-
-
Field Detail
-
DEFAULT_EXCLUDES
private static final java.lang.String[] DEFAULT_EXCLUDES
-
DEFAULT_INCLUDES
private static final java.lang.String[] DEFAULT_INCLUDES
-
MODULE_DESCRIPTOR_FILE_NAME
private static final java.lang.String MODULE_DESCRIPTOR_FILE_NAME
- See Also:
- Constant Field Values
-
includes
@Parameter private java.lang.String[] includes
List of files to include. Specified as fileset patterns which are relative to the input directory whose contents is being packaged into the JAR.
-
excludes
@Parameter private java.lang.String[] excludes
List of files to exclude. Specified as fileset patterns which are relative to the input directory whose contents is being packaged into the JAR.
-
outputDirectory
@Parameter(defaultValue="${project.build.directory}", required=true) private java.io.File outputDirectoryDirectory containing the generated JAR.
-
finalName
@Parameter(defaultValue="${project.build.finalName}", readonly=true) private java.lang.String finalNameName of the generated JAR.
-
archivers
@Component private java.util.Map<java.lang.String,org.codehaus.plexus.archiver.Archiver> archivers
The Jar archiver.
-
project
@Parameter(defaultValue="${project}", readonly=true, required=true) private org.apache.maven.project.MavenProject projectThe {@link {MavenProject}.
-
session
@Parameter(defaultValue="${session}", readonly=true, required=true) private org.apache.maven.execution.MavenSession sessionTheMavenSession.
-
archive
@Parameter private org.apache.maven.archiver.MavenArchiveConfiguration archive
The archive configuration to use. See Maven Archiver Reference.
-
useDefaultManifestFile
@Parameter(property="jar.useDefaultManifestFile", defaultValue="false") private boolean useDefaultManifestFileDeprecated.For version 3.0.0 this parameter is only defined here to break the build if you use it!Using this property will fail your build cause it has been removed from the plugin configuration. See the Major Version Upgrade to version 3.0.0 for the plugin.
-
projectHelper
@Component private org.apache.maven.project.MavenProjectHelper projectHelper
-
forceCreation
@Parameter(property="maven.jar.forceCreation", defaultValue="false") private boolean forceCreationRequire the jar plugin to build a new JAR even if none of the contents appear to have changed. By default, this plugin looks to see if the output jar exists and inputs have not changed. If these conditions are true, the plugin skips creation of the jar. This does not work when other plugins, like the maven-shade-plugin, are configured to post-process the jar. This plugin can not detect the post-processing, and so leaves the post-processed jar in place. This can lead to failures when those plugins do not expect to find their own output as an input. Set this parameter to true to avoid these problems by forcing this plugin to recreate the jar every time.
Starting with 3.0.0 the property has been renamed fromjar.forceCreationtomaven.jar.forceCreation.
-
skipIfEmpty
@Parameter(defaultValue="false") private boolean skipIfEmpty
Skip creating empty archives.
-
-
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()
- Returns:
- the
project
-
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 directoryresultFinalName- the name of the ear fileclassifier- an optional classifier- Returns:
- the file to generate
-
createArchive
public java.io.File createArchive() throws org.apache.maven.plugin.MojoExecutionExceptionGenerates 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.MojoExecutionExceptionGenerates the JAR.- Throws:
org.apache.maven.plugin.MojoExecutionException- in case of an error.
-
projectHasAlreadySetAnArtifact
private boolean projectHasAlreadySetAnArtifact()
-
hasClassifier
protected boolean hasClassifier()
- Returns:
- true in case where the classifier is not
nulland contains something else than white spaces.
-
getIncludes
private java.lang.String[] getIncludes()
-
getExcludes
private java.lang.String[] getExcludes()
-
-