模块(APP1)的汇编描述符是:
<?xml version="1.0" encoding="UTF-8"?>
<assembly>
<id>report</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
<moduleSet>
<includes>
<include>*-APP2</include>[trying to refer to another module ie module-APP2]
</includes>
<sources>
<fileSets>
<fileSet>
<directory>/</directory>
<includes>
<include>**/target</include>
</includes>
</fileSet>
</fileSets>
<excludeSubModuleDirectories>false</excludeSubModuleDirectories>
<outputDirectoryMapping>/</outputDirectoryMapping>
</sources>
</moduleSet>
</moduleSets>
</assembly>
当我运行mvn install cmd时,我正在
[WARNING] The following patterns were never triggered in this artifact inclusion filter:
o '*-APP2'
我哪里出错了?
我修改为:
<?xml version="1.0" encoding="UTF-8"?><assembly>
<id>report</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
<moduleSet>
<includes>
<include>sampleMaven:module-APP2</include>
</includes>
<sources>
<fileSets>
<fileSet>
<directory>/</directory>
<includes>
<include>target/*</include>
</includes>
</fileSet>
</fileSets>
<excludeSubModuleDirectories>false</excludeSubModuleDirectories>
<outputDirectoryMapping>/</outputDirectoryMapping>
</sources>
</moduleSet>
</moduleSets>
</assembly>
仍在:
[WARNING] The following patterns were never triggered in this artifact inclusion filter:
o 'sampleMaven:module-APP2'
18 / sep更新: 主要项目 - &gt;
http://maven.apache.org/maven-v4_0_0.xsd“&GT; 4.0.0 sampleMaven 阿努 0.0.1-SNAPSHOT POM
APP1
<module>APP2</module>
2)对于APP1,pom.xml是 - &gt;
<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">
阿努
sampleMaven
0.0.1-SNAPSHOT
4.0.0
sampleMaven
APP1
APP1
0.0.1-SNAPSHOT
POM
../APP2
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-3</version>
<executions>
<execution>
<id>assemblyone</id>
<phase>compile</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>App1</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>${basedir}/src/main/resources/assemblies/report.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> ...
3)汇编描述符是 - &gt;
报告
罐
假
<sources>
<fileSets>
<fileSet>
<directory>/</directory>
<includes>
<include>target/*</include>
</includes>
</fileSet>
</fileSets>
<excludeSubModuleDirectories>false</excludeSubModuleDirectories>
<outputDirectoryMapping>/</outputDirectoryMapping>
</sources>
<binaries>
<outputDirectory>
${module.artifactId}-${module.version}
</outputDirectory>
<dependencySets>
<dependencySet/>
</dependencySets>
</binaries>
</moduleSet>
关于运行gettting - &gt;错误堆栈跟踪:
org.apache.maven.project.DuplicateProjectException:项目'sampleMaven:APP2'在反应堆中重复
答案 0 :(得分:3)
更新:Maven书中有一个关于程序集中including moduleSets的部分。您的示例中的方法已弃用。从父级定义moduleSets时,构建顺序也存在问题。必须首先构建父级,以便子级可以继承它,但必须构建子级,以便父级可以在其程序集中包含它。 以下方法解决了这个问题。
定义引用装配模块的父pom。
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>name.seller.rich</groupId>
<artifactId>test-parent</artifactId>
<packaging>pom</packaging>
<version>1.0.0</version>
<modules>
<module>test-assembly</module>
</modules>
<dependencies>
</project>
在汇编模块中,定义一个模块,该模块具有指向实际应用程序模块的相对路径,并定义汇编插件配置:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>name.seller.rich</groupId>
<artifactId>test-assembly</artifactId>
<packaging>pom</packaging>
<version>1.0.0-SNAPSHOT</version>
<modules>
<module>../my-app2</module>
</modules>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-4</version>
<executions>
<execution>
<id>assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>App1</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/my-assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
和my-assembly.xml定义如下:
<?xml version="1.0" encoding="UTF-8"?><assembly>
<id>my-assembly</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
<moduleSet>
<binaries>
<outputDirectory>
${module.artifactId}-${module.version}
</outputDirectory>
<dependencySets>
<dependencySet/>
</dependencySets>
</binaries>
</moduleSet>
</moduleSets>
</assembly>
构建父模块将导致构建顺序为:
因此,当程序集打包时,my-app2已构建完成,并且可以包含在内。二进制声明将包括jar。
答案 1 :(得分:2)
我仍在寻找构建mutli模块应用程序的解决方案,我想我几乎就在那里! : - )
诀窍是构建一个单独的模块,不要将它添加到父模块,因为你想构建你的父模块(构建所有模块),然后调用程序集。
我有一个zip文件,其中包含我需要的所有内容,只有可执行jar不包含源代码......但我会尽快解决它。如果我能使它工作,我会在这里粘贴解决方案:)
和平