我有以下問題。我有一個多模塊項目。我想在頂層pom上運行maven-assembly插件,這也是其模塊的父pom。我希望插件只能在頂級pom上執行。目前它也嘗試在所有子模塊上執行。我不想這樣,我只需要抓住從所有模塊的所有源代碼和子模塊在一個地方Maven Assembly Plugin在子項目上執行
這裏是我的描述符(頂層目標目錄):
<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>
的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>
父POM只包含一些依賴,我想在所有模塊進行inheritaed。子模塊將當前的pom作爲父項。 現在,如果我運行:
MVN裝配:單-Ddescriptor = somedes.xml
其上運行的頂層POM確定並收集所有我需要的資源。但它並沒有停止,並開始在所有子項目上執行這個目標,當然也沒有定義描述符。我怎樣才能強制執行只在頂級POM?
...
[INFO] Processing sources for module project: LAST MODULE
[INFO] Building zip: ..../target/TopLevelBuild-5.5-SNAPSHOT-src.zip
[INFO] ------------------------------------------------------------------------
[INFO] Building deploy
[INFO] task-segment: [assembly:single]
[INFO] ------------------------------------------------------------------------
[INFO] [assembly:single {execution: default-cli}]
[INFO] Processing sources for module project: module1-submodule1:jar:5.5-SNAPSHOT
[INFO] Processing sources for module project: module1-submodule1:jar:5.5-SNAPSHOT
[INFO] Building zip: .../module1/target/module1-5.5-SNAPSHOT-src.zip
[INFO] ------------------------------------------------------------------------
[INFO] Building module1
[INFO] task-segment: [assembly:single]
[INFO] ------------------------------------------------------------------------
[INFO] [assembly:single {execution: default-cli}]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to create assembly: Error creating assembly archive src: You must set at least one file.
我已嘗試添加:
-Dexecution.inherited =假
,但它不help.Adding
-Dassembly.ignoreMissingDescriptor = true
也沒有幫助。有任何想法嗎?
你會寫你所談論的標籤,和你在哪裏指定。無論如何,應該有另一種解決方案,因爲當你有300個項目需要一些時間,除此之外,我不想阻止其他事情的繼承。 – alexmaig 2011-09-08 08:50:29
其實,IMO false 需要在** parent ** pom.xml中 - 這樣子模塊纔不會繼承那個執行。不確定是否適用於您的情況。看到我的答案。 –
2011-11-01 03:49:09
將無法工作:(這正是什麼-Dexecution.inherited = false。 – alexmaig 2011-12-07 09:24:36