jar:test-jar

Full name:

org.apache.maven.plugins:maven-jar-plugin:3.4.0:test-jar

Description:

Build a JAR of the test classes for the current project.

Attributes:

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

Required Parameters

Name Type Since Description
<outputDirectory> File - Directory containing the generated JAR.
Default: ${project.build.directory}
<testClassesDirectory> File - Directory containing the test classes and resource files that should be packaged into the JAR.
Default: ${project.build.testOutputDirectory}

Optional Parameters

Name Type Since Description
<addDefaultExcludes> boolean 3.4.0 If set to false, the files and directories that by default are excluded from the resulting archive, like .gitignore, .cvsignore etc. will be included. This means all files like the following will be included.
  • Misc: **/*~, **/#*#, **/.#*, **/%*%, **/._*
  • CVS: **/CVS, **/CVS/**, **/.cvsignore
  • RCS: **/RCS, **/RCS/**
  • SCCS: **/SCCS, **/SCCS/**
  • VSSercer: **/vssver.scc
  • MKS: **/project.pj
  • SVN: **/.svn, **/.svn/**
  • GNU: **/.arch-ids, **/.arch-ids/**
  • Bazaar: **/.bzr, **/.bzr/**
  • SurroundSCM: **/.MySCMServerInfo
  • Mac: **/.DS_Store
  • Serena Dimension: **/.metadata, **/.metadata/**
  • Mercurial: **/.hg, **/.hg/**
  • Git: **/.git, **/.git/**
  • Bitkeeper: **/BitKeeper, **/BitKeeper/**, **/ChangeSet, **/ChangeSet/**
  • Darcs: **/_darcs, **/_darcs/**, **/.darcsrepo, **/.darcsrepo/****/-darcs-backup*, **/.darcs-temp-mail

See also: DEFAULTEXCLUDES
Default: true
<archive> MavenArchiveConfiguration - The archive configuration to use. See Maven Archiver Reference.
<classifier> String - Classifier to use for test-jar.
Default: tests
<detectMultiReleaseJar> boolean 3.4.0 If the JAR contains the META-INF/versions directory it will be detected as a multi-release JAR file ("MRJAR"), adding the Multi-Release: true attribute to the main section of the JAR MANIFEST.MF.
Default: true
User Property: maven.jar.detectMultiReleaseJar
<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: false
User Property: 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.
<outputTimestamp> String 3.2.0 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).
Default: ${project.build.outputTimestamp}
<skip> boolean - Set this to true to bypass test-jar generation. Its use is NOT RECOMMENDED, but quite convenient on occasion.
User Property: maven.test.skip
<skipIfEmpty> boolean - Skip creating empty archives.
Default: false
<useDefaultManifestFile> boolean - Deprecated. 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.
Default: false
User Property: jar.useDefaultManifestFile

Parameter Details

<addDefaultExcludes>

If set to false, the files and directories that by default are excluded from the resulting archive, like .gitignore, .cvsignore etc. will be included. This means all files like the following will be included.
  • Misc: **/*~, **/#*#, **/.#*, **/%*%, **/._*
  • CVS: **/CVS, **/CVS/**, **/.cvsignore
  • RCS: **/RCS, **/RCS/**
  • SCCS: **/SCCS, **/SCCS/**
  • VSSercer: **/vssver.scc
  • MKS: **/project.pj
  • SVN: **/.svn, **/.svn/**
  • GNU: **/.arch-ids, **/.arch-ids/**
  • Bazaar: **/.bzr, **/.bzr/**
  • SurroundSCM: **/.MySCMServerInfo
  • Mac: **/.DS_Store
  • Serena Dimension: **/.metadata, **/.metadata/**
  • Mercurial: **/.hg, **/.hg/**
  • Git: **/.git, **/.git/**
  • Bitkeeper: **/BitKeeper, **/BitKeeper/**, **/ChangeSet, **/ChangeSet/**
  • Darcs: **/_darcs, **/_darcs/**, **/.darcsrepo, **/.darcsrepo/****/-darcs-backup*, **/.darcs-temp-mail

See also: DEFAULTEXCLUDES
  • Type: boolean
  • Since: 3.4.0
  • Required: report.plugin.goal.no
  • Default: true

<archive>

The archive configuration to use. See Maven Archiver Reference.
  • Type: org.apache.maven.archiver.MavenArchiveConfiguration
  • Required: report.plugin.goal.no

<classifier>

Classifier to use for test-jar.
  • Type: java.lang.String
  • Required: report.plugin.goal.no
  • Default: tests

<detectMultiReleaseJar>

If the JAR contains the META-INF/versions directory it will be detected as a multi-release JAR file ("MRJAR"), adding the Multi-Release: true attribute to the main section of the JAR MANIFEST.MF.
  • Type: boolean
  • Since: 3.4.0
  • Required: report.plugin.goal.no
  • User Property: maven.jar.detectMultiReleaseJar
  • Default: true

<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: report.plugin.goal.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: report.plugin.goal.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: report.plugin.goal.no

<outputDirectory>

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

<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).
  • Type: java.lang.String
  • Since: 3.2.0
  • Required: report.plugin.goal.no
  • Default: ${project.build.outputTimestamp}

<skip>

Set this to true to bypass test-jar generation. Its use is NOT RECOMMENDED, but quite convenient on occasion.
  • Type: boolean
  • Required: report.plugin.goal.no
  • User Property: maven.test.skip

<skipIfEmpty>

Skip creating empty archives.
  • Type: boolean
  • Required: report.plugin.goal.no
  • Default: false

<testClassesDirectory>

Directory containing the test classes and resource files that should be packaged into the JAR.
  • Type: java.io.File
  • Required: report.plugin.goal.yes
  • Default: ${project.build.testOutputDirectory}

<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: report.plugin.goal.no
  • User Property: jar.useDefaultManifestFile
  • Default: false