maven-shade-plugin 可以为具有包装类型 pom 的模块创建阴影 pom 吗?
我有一个多模块 Maven 项目,其中包含一个单独的 xyz-distribution 模块,其中包含多个程序集。该模块依赖于进入程序集的所有工件。
在我的父 pom 中,我默认禁用了部署,因为我只想部署我的分发程序集。
由于我的生产存储库中不会有单独的工件(只有分发程序集),因此部署的分发 pom 也不应列出任何依赖项。我尝试通过在我的配置中包含 maven-shade-plugin 来实现此目标。
但是调用“mvn install”总是会产生以下错误
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing null with C:\...\xyz-distribution\target\xyz-distribution-1.0-shaded.pom
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error creating shaded jar: null
有什么想法如何解决我的问题吗?
父pom(简化):
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>x.y.z</groupId>
<artifactId>xyz-parent</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<inherited>true</inherited>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
分发pom:
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>x.y.z</groupId>
<artifactId>xyz-parent</artifactId>
<version>1.0</version>
</parent>
<artifactId>xyz-distribution</artifactId>
<packaging>pom</packaging>
<dependencies>
<!-- assembly descriptors will reference this dependencies -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>xyz-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>distro-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/assemble/bin.xml</descriptor>
<descriptor>src/assemble/doc.xml</descriptor>
<descriptor>src/assemble/src.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>*</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
I have a multi module maven project with a seperate xyz-distribution module that contains multiple assemblies. This module depends on all artifacts that go into the assemblies.
In my parent pom I have disabled deployment per default as I want only my distribution assemblies deployed.
Since there will be no individual artifacts in my production repository (only the distribution assemblies), the deployed distribution pom should also not list any dependencies. I tried to achieve this goal by including the maven-shade-plugin in my configuration.
But calling 'mvn install' always yields the following error
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing null with C:\...\xyz-distribution\target\xyz-distribution-1.0-shaded.pom
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error creating shaded jar: null
Any ideas how to solve my problem?
parent pom (simplified):
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>x.y.z</groupId>
<artifactId>xyz-parent</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<inherited>true</inherited>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
distribution pom:
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>x.y.z</groupId>
<artifactId>xyz-parent</artifactId>
<version>1.0</version>
</parent>
<artifactId>xyz-distribution</artifactId>
<packaging>pom</packaging>
<dependencies>
<!-- assembly descriptors will reference this dependencies -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>xyz-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>distro-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/assemble/bin.xml</descriptor>
<descriptor>src/assemble/doc.xml</descriptor>
<descriptor>src/assemble/src.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>*</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论