我有以下问题.我有一个多模块项目.我想在顶层pom上运行maven-assembly插件,它也是其模块的父pom.我希望插件只在顶级pom上执行.目前它也试图在所有子模块上执行.我不想要这个,因为我只需要从一个地方(顶层目标目录)中获取所有模块和子模块的所有源代码.
这是我的描述符:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>src</id>
<formats>
<format>zip</format>
</formats>
<moduleSets>
<moduleSet>
<includeSubModules>true</includeSubModules>
<sources>
<useDefaultExcludes>true</useDefaultExcludes>
<includeModuleDirectory>false</includeModuleDirectory>
<fileSets>
<fileSet>
<outputDirectory>/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
<includes>
<include>src/main/**</include>
<include>src/test/**</include>
<include>target/classes/**</include>
</includes>
</fileSet>
</fileSets>
</sources>
</moduleSet>
</moduleSets>
Run Code Online (Sandbox Code Playgroud)
pom文件如下所示:
<?xml version="1.0"?>
<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>myid</groupId>
<artifactId>myartid</artifactId>
<version>1.1</version>
</parent>
<groupId>myid2</groupId>
<artifactId>TopLevelBuild</artifactId>
<packaging>pom</packaging>
<version>5.5-SNAPSHOT</version>
<name>Some Application</name>
<modules>
<module>1</module>
<module>2</module>
<module>3</module>
<module>4</module>
<module>5</module>
<module>6</module>
</modules>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
<version>4.8.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
父pom只包含一些我希望在所有模块中继承的依赖项.子模块将当前pom作为父级.现在,如果我跑:
mvn程序集:单-Ddescriptor = somedes.xml
它在顶级pom上运行正常并收集我需要的所有资源.但它不会停止并开始在所有子项目上执行此目标,当然也没有为此定义描述符.如何强制执行仅在顶层pom上执行?
...
[INFO] Processing sources for module …Run Code Online (Sandbox Code Playgroud)