So, I guess you were trying to run "mvn dependency:tree" using maven < 3.1.0. The default dependency plugin version was
. So, what you had was actually the exactly tree generated by maven 2.x (not maven 3.x).
(Friendly warning, even version 2.8 of the plugin will show maven 2 resolution if -Dverbose=true is turned on. I raised
an issue for that).
So, running the latest version of dependency tree (2.8, regardless of which maven 3.x) in the omod reporting project will show the following non-provided deps for openmrs-api:
[INFO] +- org.openmrs.api:openmrs-api:jar:1.9.7:provided
[INFO] | +- log4j:log4j:jar:1.2.15:runtime
[INFO] | +- stax:stax-api:jar:1.0.1:compile
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | +- xml-apis:xml-apis:jar:1.3.03:compile
Incredibly enough, maven 3.2.1 will NOT bring log4j as runtime, it will be a provided scope (I guess that bug was fixed), so I didn't took the time to look at it.
Both dom4j and stax come from poi-ooxml, so no big deal (I will come back to these guys later).
Here be dragons.
xml-apis is the only one causing trouble here. But my gut feeling is that maven is just working as designed. I might be wrong, I guess I should raise an issue and let maven people decide it by themselves.
I will try to explain it below, but I attached an example (better to play with it).
Reporting omod module is including two relevant dependencies:
<dependency>
<groupId>org.openmrs.api</groupId>
<artifactId>openmrs-api</artifactId>
<version>${openMRSVersion}</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
And:
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
So, maven is trying to parse the dependencies. It's looking at 'openmrs-api', and it finds a "dom4j". Yeah, it was supposed to be provided (the same as openmrs-api), but hold on! You added 'poi-ooxml' as a compile dependency, which will bring 'dom4j' as a compile dependency. So, maven decide it's a compile dependency when analysing 'openmrs-api'. Turns out that other 'openmrs-api', 'xml-apis' is a compile dependency of 'dom4j', so YEY, let's change it to compile as well. Look, you excluded the 'xml-apis' for 'poi-ooxml', but not when including 'dom4j' which became a compile dependency of 'openmrs-api'.
The sane thing I guess it to do is exclude 'dom4j' from 'poi-ooxml'. I guess it should not break anything, as you can use the provided one, right?
To do some tests using the example attached, download the tar.gz, unzip it, and go to the example-excluding-jar (it is like the reporting omod). The other project, example-provided-jar, mimics openmrs-api.
Feel free to remove the 'dom4j' exclusion to reproduce the same behaviour you have currently.
To run it:
$ (cd ../example-provided-jar/; mvn3 clean install); ~mvn3 org.apache.maven.plugins:maven-dependency-plugin:2.8:tree
I hope that answers the question.
Cheers,