Found this Q about how to add version to manifest.mf: How do I add an Implementation-Version value to a jar manifest using Maven? , but how to add them when using shade plugin?
What i tried in my pom.xml maven-shade-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>ispf-win</finalName>
<shadedArtifactAttached>shade</shadedArtifactAttached>
<outputDirectory>${project.build.directory}/ispf-win</outputDirectory>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>desktop.win.main.Main</mainClass>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
However i can an error:
Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade (default) on project desktop.win:
Unable to parse configuration of mojo org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade for parameter addDefaultI
mplementationEntries: Cannot find 'addDefaultImplementationEntries' in class java.util.jar.Manifest
I think you should maybe rather be using <manifestEntries>
See this example: THIS
With these standard maven properties set:
<name>Project Name</name>
<organization.name>Company</organization.name>
<groupId>Group ID</groupId>
<version>1.0.0</version>
And the following maven shade configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<!-- Add entries to the manifest. -->
<transformer implementation = "org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Implementation-Title>${project.name}</Implementation-Title>
<Implementation-Version>${project.version}</Implementation-Version>
<Implementation-Vendor-Id>${project.groupId}</Implementation-Vendor-Id>
<Implementation-Vendor>${project.organization.name}</Implementation-Vendor>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
You will get the desired result:
Manifest-Version: 1.0
Created-By: Maven Jar Plugin 3.2.0
Build-Jdk-Spec: 11
Implementation-Title: Project Name
Implementation-Vendor: Company
Implementation-Vendor-Id: Group ID
Implementation-Version: 1.0.0
For a "set it and forget it" configuration in a multi-module project, set <organization.name>
in the parent pom <properties>
section and <name>
in each module pom.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.