Maven和maven-shade-plugin的小坑

环境

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)

finalName 到底是什么

<finalName>${project.name}.${scala.binary.version}-${flink.version}</finalName>

经过测试project.name如果没有定义,则pom.name和pom的artifactId一致,
这就是finalName不生效的原因。

所以需要定义name,他不会继承父Pom的name.

<name></name>

验证方法

mvn help:evaluate

输入${project.name}

pom.name和project.name 均不会继承parent的名称(IDEA提示的是继承过来的,IDEA的提示可能有bug)


<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>3.2.4</version>
    <configuration>
        <createDependencyReducedPom>false</createDependencyReducedPom>
    </configuration>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
            <configuration>
                <!--<shadedArtifactAttached>true</shadedArtifactAttached>-->
                <!--<shadedClassifierName>pfc</shadedClassifierName>-->
                <finalName>${project.name}.${scala.binary.version}</finalName>
                <transformers>
                    <transformer
                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                        <manifestEntries>
                            <original-GAV>slankka:${groupId}:${artifactId}:${version}</original-GAV>
                        </manifestEntries>
                    </transformer>
                </transformers>
            </configuration>
        </execution>
    </executions>
</plugin>
posted @ 2021-05-20 11:56  一杯半盏  阅读(899)  评论(0编辑  收藏  举报