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.AbstractMojo
Base class for creating a jar from project classes.
- Version:
- $Id$
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.apache.maven.archiver.MavenArchiveConfiguration
The archive configuration to use.The Jar archiver.private static final String[]
private static final String[]
private String[]
List of files to exclude.private String
Name of the generated JAR.private boolean
Require the jar plugin to build a new JAR even if none of the contents appear to have changed.private String[]
List of files to include.private static final String
private File
Directory containing the generated JAR.private String
Timestamp for reproducible output archive entries, either formatted as ISO 8601 extended offset date-time (e.g.private org.apache.maven.project.MavenProject
The {@link {MavenProject}.private org.apache.maven.project.MavenProjectHelper
private org.apache.maven.execution.MavenSession
TheMavenSession
.private boolean
Skip creating empty archives.private boolean
Deprecated.For version 3.0.0 this parameter is only defined here to break the build if you use it!Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGenerates the JAR.void
execute()
Generates the JAR.protected abstract File
Return the specific output directory to serve as the root for the archive.protected abstract String
Overload this to produce a jar with another classifier, for example a test-jar.private String[]
private String[]
protected File
getJarFile
(File basedir, String resultFinalName, String classifier) Returns the Jar file to generate, based on an optional classifier.protected final org.apache.maven.project.MavenProject
protected abstract String
getType()
Overload this to produce a test-jar, for example.protected boolean
private boolean
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
DEFAULT_EXCLUDES
-
DEFAULT_INCLUDES
-
MODULE_DESCRIPTOR_FILE_NAME
- See Also:
-
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
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
Directory containing the generated JAR. -
finalName
Name of the generated JAR. -
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 archiveThe 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.forceCreation
tomaven.jar.forceCreation
. -
skipIfEmpty
@Parameter(defaultValue="false") private boolean skipIfEmptySkip creating empty archives. -
outputTimestamp
Timestamp for reproducible output archive entries, either formatted as ISO 8601 extended offset date-time (e.g. in UTC such as '2011-12-03T10:15:30Z' or with an offset '2019-10-05T20:37:42+06:00'), or as an int representing seconds since the epoch (like SOURCE_DATE_EPOCH).- Since:
- 3.2.0
-
-
Constructor Details
-
AbstractJarMojo
public AbstractJarMojo()
-
-
Method Details
-
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
Overload this to produce a jar with another classifier, for example a test-jar.- Returns:
- get the classifier.
-
getType
Overload this to produce a test-jar, for example.- Returns:
- return the type.
-
getJarFile
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
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.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
null
and contains something else than white spaces.
-
getIncludes
-
getExcludes
-