首页 > 解决方案 > 使用 maven-shade-plugin 时如何将 DefaultImplementationEntries 添加到 MANIFEST?

问题描述

发现这个关于如何向 manifest.mf 添加版本的问题:如何使用 Maven 向 jar 清单添加一个 Implementation-Version 值?,但是在使用 shade 插件时如何添加它们?

我在我的 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>

但是我可能会出错:

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

标签: javamavenmanifestmaven-shade-plugin

解决方案


我认为您可能更应该使用<manifestEntries> See eg THIS


推荐阅读