假设我有一个模块A:jar,其依赖项的运行时和编译集取决于JDK版本.在我的示例中,我有一个pre-jdk6-profilefor JAXB API:在JDK 1.6.0之前,我需要包含jaxb-api-nnn.jar作为编译依赖项.此个人资料被放置A.pom.
我也有模块B:war,这取决于A:jar.我希望能够在构建服务器上激活此配置文件以构建JDK 1.5.x可交付项.当我在激活给定配置文件的情况下执行Maven时,我收到消息:
mvn -Ppre-jdk6-profile -o install
[WARNING]
Profile with id: 'pre-jdk6-profile' has not been activated.
Run Code Online (Sandbox Code Playgroud)
并且jaxb-api-nnn.jar在结果中缺失B.war.但是,如果我在从父级构建时激活此配置文件pom.xml,则一切正常.这意味着配置文件不是从依赖项继承的,并且父多模块pom.xml能够正确构建所有内容,因为它似乎所有配置文件都在reactor中合并.
将配置文件转换为父pom会使事情变得更糟,因为依赖关系应用于所有其他项目(例如C:ear).对于此任务是否有很好的解决方案,即,如果任何模块A依赖于模块B,那么由配置文件激活的所有编译和运行时依赖关系是否都能正确处理?
项目简介A:jar如下:
<project ...>
<artifactId>A</artifactId>
<packaging>jar</packaging>
...
<parent>
<artifactId>P</artifactId>
...
</parent>
<profiles>
<profile>
<id>pre-jdk6-profile</id>
<activation>
<jdk>(,1.6.0)</jdk>
</activation>
<dependencies>
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>
...
</project>
Run Code Online (Sandbox Code Playgroud) maven-2 ×1