Suppose I have a module A:jar
, whose runtime and compilation set of dependencies depends on the JDK version. In my example, I have a pre-jdk6-profile
a) In a multi-module build, you should always build from the top pom, never from an individual module. If you want to build only one module, use advanced reactor options (see mvn --help) like this:
mvn -pl mymodule
b) Define and activate the profile in the parent pom, but add the configuration in the child pom.
parent pom.xml
<profiles>
<profile>
<id>pre-jdk-6</id>
<activation>
<jdk>(,1.6.0)</jdk>
</activation>
</profile>
</profiles>
child pom.xml
<profiles>
<profile>
<id>pre-jdk-6</id>
<dependencies>
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>
Several notes way after the fact:
-P profName
, it activates a profile named 'profName'<activation>
tag for them. It doesn't matter whether they are activated by the java version, as in the example, or by default or env value or anything.Solution: Either use <activation><jdk>...</jdk></activation>
or use -P
but do not use both.