我在部署由 maven-shade-plugin 创建的 jar 文件时遇到问题。它曾经工作,但它已经停止工作。根据我的研究,问题似乎是安装步骤正在覆盖阴影 jar。
如果我使用以下设置:
<shadedArtifactAttached>true</shadedArtifactAttached>
它会为我创建一个胖罐子,但如果我把它改成
<shadedArtifactAttached>false</shadedArtifactAttached>
安装/部署将删除主类的依赖项和清单条目。
我不想使用“true”设置,因为文件重命名会破坏我所有依赖于通用脚本的工具,该通用脚本将通过 cURL 部署工件。
所以,当我跑步时
$ mvn -s ../.m2/settings.xml --batch-mode --errors --fail-at-end --show-version clean package shade:shade
我得到正确的文件:(ontology-merger-0.3.31.jar
大文件)和original-ontology-merger-0.3.31
(小文件)
当我跑步时
$ mvn -s ../.m2/settings.xml --batch-mode --errors --fail-at-end --show-version clean package shade:shade install
安装步骤将丢弃阴影 jar。我假设发生这种情况是因为它正在运行maven-jar-plugin
它,尽管我没有提到maven-jar-plugin
我的pom.xml
. 我不知道如何关闭它。
日志中的重要部分:
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing C:\dev\allotrope\source\ontology-qa-tools\merger\target\ontology-merger-0.3.31.jar with C:\dev\allotrope\source\ontology-qa-tools\merger\target\ontology-merger-0.3.31-shaded.jar
[INFO] Dependency-reduced POM written at: C:\dev\allotrope\source\ontology-qa-tools\merger\dependency-reduced-pom.xml
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ ontology-merger --- [INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ ontology-merger --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ ontology-merger --- [INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 30 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ ontology-merger --- [INFO] No sources to compile [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ ontology-merger --- [INFO] Skipping execution of surefire because it has already been run for this configuration [INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ ontology-merger --- [INFO] Building jar: C:\dev\allotrope\source\ontology-qa-tools\merger\target\ontology-merger-0.3.31.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ ontology-merger --- [INFO] Installing C:\dev\allotrope\source\ontology-qa-tools\merger\target\ontology-merger-0.3.31.jar to C:\Users\User\.m2\repository\com\osthus\ontology-merger\0.3.31\ontology-merger-0.3.31.jar
[INFO] Installing C:\dev\allotrope\source\ontology-qa-tools\merger\dependency-reduced-pom.xml to C:\Users\User\.m2\repository\com\osthus\ontology-merger\0.3.31\ontology-merger-0.3.31.pom
我pom.xml
目前的部分如下所示:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.osthus.ontology_merger.MergerMain</mainClass>
<manifestEntries>
<Main-Class>com.osthus.ontology_merger.MergerMain</Main-Class>
</manifestEntries>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer
implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer" />
<transformer
implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer">
<addHeader>false</addHeader>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<!-- Some jars are signed but shading breaks that. Don't include
signing files. -->
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
我的各种修复尝试都在这个分支中:
https://gitlab.com/allotrope-open-source/ontology-qa-tools/-/tree/deployment-test
pom.xml 的路径:
https://gitlab.com/allotrope-open-source/ontology-qa-tools/-/blob/deployment-test/merger/pom.xml
一点历史:
我的部署已经运行了多年而没有出现问题,最近我已经崩溃了,我上个月通过
和
我必须在pom.xml
文件中添加一些样板并进行更改
$ mvn -s ../.m2/settings.xml --batch-mode --errors --fail-at-end --show-version clean deploy
至
$ mvn -s ../.m2/settings.xml --batch-mode --errors --fail-at-end --show-version clean package shade:shade deploy
谢谢你的时间