[英]Maven Assembly plugin parent descriptor sharing
I have a project, with a parent module. 我有一个带有父模块的项目。 Parent and child both using maven-assembly-plugin. 父母和孩子都使用maven-assembly-plugin。
Parent uses it's own descriptor (zip.xml): 父级使用它自己的描述符(zip.xml):
<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>bin</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>${svn.scripts}</directory>
<includes>
<include>query.*</include>
</includes>
</fileSet>
<fileSet>
<directory>${cfgreader.dist}</directory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
</fileSets>
</assembly>
this way: 这条路:
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptor>${basedir}/descriptors/zip.xml</descriptor>
<finalName>${patch.prefix}_rev</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
while my child's module pom.xml has: 而我孩子的模块pom.xml具有:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.test.cfgReader</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>cfgreader</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
The problem is that the child module tries to use zip.xml descriptor and it causes errors: 问题在于子模块尝试使用zip.xml描述符,并且会导致错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.
2-beta-5:single (make-assembly) on project dist: Error reading assemblies: Error
locating assembly descriptor: D:\dist/descriptors/zip.xml
[ERROR]
[ERROR] [1] [INFO] Searching for file location: D:\dist\D\dist\D:\dist\descriptors\zip.xml
[ERROR]
[ERROR] [2] [INFO] File: D:\\dist\D:\\dist\descriptors\zip.xml does not exist.
[ERROR]
[ERROR] [3] [INFO] Invalid artifact specification: 'D:\\dist\D:\\dist\descriptors\zip.xml'. Must contain at le
ast three fields, separated by ':'.
[ERROR]
[ERROR] [4] [INFO] Failed to resolve classpath resource: assemblies/D:\dist/descriptors/zip.xml from
classloader: ClassRealm[plugin>org.apache.maven.plugins:maven-assembly-plugin:2
.2-beta-5, parent: sun.misc.Launcher$AppClassLoader@33d626a4]
[ERROR]
[ERROR] [5] [INFO] Failed to resolve classpath resource: D:\dist/descriptors/zip.xml from classloade
r: ClassRealm[plugin>org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5,
parent: sun.misc.Launcher$AppClassLoader@33d626a4]
[ERROR]
[ERROR] [6] [INFO] File: D:\D\descriptors\zip.xml does not exist.
[ERROR]
[ERROR] [7] [INFO] Building URL from location: D:\dist/descriptors/zip.xml
[ERROR] Error:
[ERROR] java.net.MalformedURLException: unknown protocol: d
[ERROR] at java.net.URL.<init>(URL.java:592)
[ERROR] at java.net.URL.<init>(URL.java:482)
[ERROR] at java.net.URL.<init>(URL.java:431)
[ERROR] at org.apache.maven.shared.io.location.URLLocatorStrategy.resolve(URLLoc
atorStrategy.java:54)
.... and if i delete maven-assembly-plugin
from parent pom.xml
everything is fine, if i add again, parent task works fine, while child - fails. ....并且如果我从父pom.xml
删除maven-assembly-plugin
,一切都很好,如果我再次添加,父任务也可以正常工作,而子任务却失败了。 how to disable descriptor propagation to childs? 如何禁用描述符传播给孩子?
First create a separate module like mod-assembly and put all the descriptors and configuration for the maven-assembly-plugin into that module and make this mod-assembly and other child of your parent. 首先创建一个单独的模块,例如mod-assembly,然后将maven-assembly-plugin的所有描述符和配置放入该模块中,并使该mod-assembly和您父代的其他子代成为可能。 Apart from that use a more up-to-date version maven-assembly-plugin (2.4 instead of 2.2-beta-5). 除此之外,请使用最新版本的maven-assembly-plugin(2.4代替2.2-beta-5)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.