[英]How to add DefaultImplementationEntries to MANIFEST when using maven-shade-plugin?
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?找到这个关于如何向 manifest.mf 添加版本的问题: 如何使用 Maven 将实现版本值添加到 jar 清单? , but how to add them when using shade plugin?
,但是在使用 shade 插件时如何添加它们?
What i tried in my pom.xml maven-shade-plugin:我在我的 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
With these standard maven properties set:使用这些标准 maven 属性集:
<name>Project Name</name>
<organization.name>Company</organization.name>
<groupId>Group ID</groupId>
<version>1.0.0</version>
And the following maven shade configuration:以及以下maven灯罩配置:
<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.对于多模块项目中的“设置并忘记它”配置,请在父 pom
<properties>
部分中设置<organization.name>
,在每个模块 pom.xml 中设置<name>
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.