我有一个多模块的maven项目,以及许多构建标准jar文件的代码模块,我有一个模块使用maven-assembly-plugin将测试工具作为zip文件构建,另一个模块使用rpm-maven-plugin构建应用程序rpm。我希望在rpm中包含test harness zip文件。
目前,我在rpm模块中执行以下操作:
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>appn</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>test-harness</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>rpm-maven-plugin</artifactId>
<configuration>
:
<mapping>
<directory>/opt/app/installed/${rpmSoftwareName}-${project.version}/utils</directory>
<username>${rpmUsername}</username>
<groupname>${rpmGroupname}</groupname>
<filemode>0755</filemode>
<sources>
<source>
<location>${project.build.directory}/../../test-harness/target/test-harness-${project.version}-dist.zip</location>
</source>
</sources>
</mapping>
<mapping>
<directory>/opt/app/installed/${rpmSoftwareName}-${project.version}/lib</directory>
<username>${rpmUsername}</username>
<groupname>${rpmGroupname}</groupname>
<filemode>0755</filemode>
<dependency />
</mapping>我遇到的问题是rpm的lib目录包含test-harness及其传递依赖项。如果我从lib映射中排除test-harness,我不会得到test-harness,但我会得到它的传递依赖项。如果我将test-harness作为依赖项删除,那么我必须依赖父pom中的模块顺序来确保首先构建test-harness,这似乎有点弱,因为依赖于在映射中包含test-harness的相对路径...一定有更好的办法。
发布于 2012-04-24 13:32:56
最好的做法是首先不要使用访问其他模块的相对路径(../target/等)。最好在rpm-module中使用依赖项。例如,将zip文件定义为具有适当分类器的依赖项。
<dependencies>
<dependency>
<groupId>project.com.domain</groupId>
<artifactId>test-harness</artifactId>
<version>${project.version}</version>
<classifier>dist</classifier>
<type>zip</type>
</dependency>
</dependencies>之后,只需将依赖项添加到rpm-configuration中,如下所示:
<mapping>
<directory>/usr/local/lib</directory>
<filemode>750</filemode>
<username>dumper</username>
<groupname>dumpgroup</groupname>
<dependency>
<includes>
<include>...:test-harness:dist:zip:${project.version}</include>
<include>...</include>
</includes>
<excludes>
<exclude>...</exclude>
</excludes>
</dependency>
</mapping>我不能100%确定include (artifactId:classifier:type:version?)的确切顺序。
https://stackoverflow.com/questions/10285805
复制相似问题