- root project with two sub projects, test-api and test-impl
- ~/.m2/settings.xml defines a property in a profile, xxx.
- root/pom.xml defines a property, yyy, and a profile that defines another property, zzz.
- test-impl depends on test-api
- test-api declares a dependency that uses xxx as the groupId, yyy as the artifactId and zzz as the type.
- Compile the root project with Maven (mvn compile), making sure the profiles are active, one way or another.
When test-api is compiled, all goes well. When test-impl is compiled, Maven warns of the following:
Turning on debuggig (mvn -X compile) prints:
Apparently, property interpolation failed for xxx but not for yyy or zzz, and xxx fails only when it is referenced in a dependency of the current project. When it is referenced in the current project, it gets properly interpolated.
What actually happens is that the list of active profiles defined outside the reactor gets lost when resolving dependencies of the current project. They are available when the current project's POM is parsed but not when parsing the POM of the current project's dependencies.
Now, although this is just a warning in my sample scenario, the consequences in real life are more serious: "no transitive dependencies" means, e.g., modules not compiling that should, or JAR artifacts missing from a WAR artifact, etc., unless the user manually duplicates all the transitive dependencies missed by Maven, in the project that did not compile, or missed a few JAR files from its WAR artifact.
Attached is a sample multi-module project as described above, a settings.xml file required for the project to compile and a patch that shows how the problem could be eliminated on the maven-3 trunk (http://svn.apache.org/repos/asf/maven/maven-3/trunk).
The attached sample will give no warning prior to Maven 3.0 but if test-impl were to actually require test-api's dependencies to compile, the problem would surface also with Maven 2.2.1 and possibly earlier.
I don't think the attached patch is an elegant solution but it has the quality of touching very few files and having little or no side effect other than fixing the problem outlined above. In short, please, make a better fix.