jar:jar

Full name:

org.apache.maven.plugins:maven-jar-plugin:3.0.2:jar

Description:

Build a JAR from the current project.

Attributes:

  • Requires a Maven project to be executed.
  • Requires dependency resolution of artifacts in scope: runtime.
  • The goal is thread-safe and supports parallel builds.
  • Binds by default to the lifecycle phase: package.

Required Parameters

Name Type Since Description
classesDirectory File - Directory containing the classes and resource files that should be packaged into the JAR.
Default value is: ${project.build.outputDirectory}.
outputDirectory File - Directory containing the generated JAR.
Default value is: ${project.build.directory}.

Optional Parameters

Name Type Since Description
archive MavenArchiveConfiguration - The archive configuration to use. See Maven Archiver Reference.
classifier String - Classifier to add to the artifact generated. If given, the artifact will be attached as a supplemental artifact. If not given this will create the main artifact which is the default behavior. If you try to do that a second time without using a classifier the build will fail.
excludes String[] - List of files to exclude. Specified as fileset patterns which are relative to the input directory whose contents is being packaged into the JAR.
forceCreation boolean - Require 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 from jar.forceCreation to maven.jar.forceCreation.
Default value is: false.
User property is: maven.jar.forceCreation.
includes String[] - List of files to include. Specified as fileset patterns which are relative to the input directory whose contents is being packaged into the JAR.
skipIfEmpty boolean - Skip creating empty archives.
Default value is: false.
useDefaultManifestFile boolean - Deprecated. For version 3.0.0 this parameter is only defined here to break the build if you use it!
Default value is: false.
User property is: jar.useDefaultManifestFile.

Parameter Details

archive:

The archive configuration to use. See Maven Archiver Reference.
  • Type: org.apache.maven.archiver.MavenArchiveConfiguration
  • Required: No

classesDirectory:

Directory containing the classes and resource files that should be packaged into the JAR.
  • Type: java.io.File
  • Required: Yes
  • Default: ${project.build.outputDirectory}

classifier:

Classifier to add to the artifact generated. If given, the artifact will be attached as a supplemental artifact. If not given this will create the main artifact which is the default behavior. If you try to do that a second time without using a classifier the build will fail.
  • Type: java.lang.String
  • Required: No

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.
  • Type: java.lang.String[]
  • Required: No

forceCreation:

Require 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 from jar.forceCreation to maven.jar.forceCreation.
  • Type: boolean
  • Required: No
  • User Property: maven.jar.forceCreation
  • Default: false

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.
  • Type: java.lang.String[]
  • Required: No

outputDirectory:

Directory containing the generated JAR.
  • Type: java.io.File
  • Required: Yes
  • Default: ${project.build.directory}

skipIfEmpty:

Skip creating empty archives.
  • Type: boolean
  • Required: No
  • Default: false

useDefaultManifestFile:

Deprecated. 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.
  • Type: boolean
  • Required: No
  • User Property: jar.useDefaultManifestFile
  • Default: false