maven程序集插件模块集源指令不包括任何文件,也不匹配包含的模块 [英] The maven assembly plugin moduleset sources instructions are not including any files and not matching the included modules
问题描述
我有一个多模块maven项目,我正在尝试使程序集插件的模块集源部分工作。
I have a multi-module maven project, and I'm trying to get the moduleset sources portion of the assembly plugin to work.
我有模块 module_parent , module_a 和 module_assembly 。
module_a 和 module_assembly 是 module_parent 的子项。
module_assembly 在 module_a 上声明了pom依赖。
module_assembly has a declared pom dependency on module_a.
module_assmebly 具有程序集插件,其assembly.xml类似于:
module_assmebly has the assembly plugin, with the assembly.xml looking like:
<?xml version="1.0"?>
<assembly>
<id>bin</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>com.mystuff:module_a</include>
</includes>
<sources>
<fileSets>
<fileSet>
<outputDirectory>/</outputDirectory>
<excludes>
<exclude>**/target/**</exclude>
</excludes>
<directory>/</directory>
</fileSet>
</fileSets>
</sources>
</moduleSet>
</moduleSets>
</assembly> <!-- -->
我对module_a的module_assembly有明确的依赖关系。 module_assembly的pom中的依赖关系如下所示:
<dependencies>
<dependency>
<groupId>com.mystuff</groupId>
<artifactId>module_a</artifactId>
<version>1.0</version>
<type>pom</type>
</dependency>
</dependencies>
我打开调试时从mvn包获得的错误是:
The error I get from mvn package with debug turned on is:
[DEBUG] All known ContainerDescritporHandler components: [metaInf-services, plexus, metaInf-spring, file-aggregator]
[DEBUG] No dependency sets specified.
[WARNING] The following patterns were never triggered in this artifact inclusion filter:
o 'com.mystuff:module_a'
[DEBUG] Cannot find ArtifactResolver with hint: project-cache-aware
org.codehaus.plexus.component.repository.exception.ComponentLookupException: java.util.NoSuchElementException
role: org.apache.maven.artifact.resolver.ArtifactResolver
roleHint: project-cache-aware
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:257)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:233)
at
<snip>
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: java.util.NoSuchElementException
at java.util.Collections$EmptyIterator.next(Collections.java:3006)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:253)
... 43 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
<snip>
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2:single (make-assembly) on project apm-server-distribution: Failed to create assembly: Error creating assembly archive bin: You must set at least one file. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2:single (make-assembly) on project apm-server-distribution: Failed to create assembly: Error creating assembly archive bin: You must set at least one file.
我认为主要问题是这条警告线:
I think the main problem is this warning line:
[WARNING] The following patterns were never triggered in this artifact inclusion filter:
o 'com.mystuff:module_a'
如何更正?
推荐答案
如果module_assembly没有对模块的子引用,它不算作模块。请注意,此处的内容仅指儿童: http: //maven.apache.org/plugins/maven-assembly-plugin/advanced-module-set-topics.html
If module_assembly doesn't have a child reference to your module, it's not counted as a module. Note the content here refers to children only: http://maven.apache.org/plugins/maven-assembly-plugin/advanced-module-set-topics.html
如果你想这样做,你需要使用dependencySet而不是moduleSet。
If you want to do this, you need to use a dependencySet rather than a moduleSet.
PS - 谢谢你的赏金!
PS - Thank you for the bounty!
这篇关于maven程序集插件模块集源指令不包括任何文件,也不匹配包含的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!