简体   繁体   English

Maven Assembly插件父描述符共享

[英]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.

相关问题 Maven程序集插件未根据描述符构建文件 - Maven assembly plugin not building files from descriptor 为什么Maven程序集插件会将描述符ref附加到finalName值? - Why does the Maven assembly plugin append the descriptor ref to the finalName value? Maven程序集描述符属性 - Maven assembly descriptor properties Maven无法找到插件描述符 - Maven not able to find plugin descriptor 如何使用带有预定义“ src”描述符的maven组件插件制作单个zip存档? - How to make single zip archive with maven assembly plugin with predefined “src” descriptor? Maven Assesmnly插件的jar-with-dependencies descriptorRef的内容是否在任何地方都记录为示例程序集描述符文件? - Is the content of the Maven Assesmnly plugin's jar-with-dependencies descriptorRef documented as an example assembly descriptor file anywhere? 使用相同的描述符Maven程序集插件针对不同格式自定义文件夹名称 - Customize folder name using same descriptor maven assembly plugin for different format 为什么maven-assembly-plugin描述符会说 <!— TODO: a jarjar format would be better --> 在其示例网站? - Why does the maven-assembly-plugin descriptor say <!— TODO: a jarjar format would be better --> in its example site? 从maven汇编描述符中的jar中排除包 - Excluding packages from jars in maven assembly descriptor Maven 程序集插件 NoClassDefFoundError - Maven Assembly Plugin NoClassDefFoundError
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM