Reputation: 383
I am defining a module with only two dependencies in the pom file, but the generated .classpath file(using mvn eclipse:eclipse) contains other dependencies also.
I checked the dependencies of the modules added in this pom, but not all of them were added.
So the scenario is:
When I run mvn eclipse:eclipse on Project A, the .classpath file contains Project B and Projects X and Y, but not Z.
This is not causing any problems, but is this the expected behavior?
Upvotes: 2
Views: 1839
Reputation: 61538
Yes, this is the expected behaviour. Project B needs X, Y and Z to work properly, so these dependencies (called transitive dependencies) are effectively part of your project.
See this for a detailed explanation of maven dependency resolution.
You can call mvn dependency:tree
or mvn dependency:list
from command line to see all dependencies, including the transitive ones.
If you know that you are depending on an artifact, but it will be available at runtime, like it is the case with Java EE libraries on an application server, you can mark them as provided
in your pom
:
<dependency>
<groupId>group</groupId>
<artifactId>artifact</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
These dependencies will not be included in your resulting atrifact.
EDIT: please excuse my poor reading skills :) I have overseen the 'not' before the 'Z'.
This may still be normal behaviour if the dependency for Z is defined as provided
or the optional
flag is set to true
, or if it is excluded. See this for maven's handling of optional and excluded dependencies.
If neither of these options applies, then I would expect Z to be there with the other dependencies. The best way to check would be to run mvn dependency:tree
or mvn dependency:list
and grep the output for Z.
Upvotes: 3