I have a POM that according to the Maven best practises should group the dependencies of a component/system to declare any dependencies required to use said component/system. (Only the grouping itself is a best practise ;))
Normaly this pom will just declare the components (in this example systemA) service (interface) module as compile
scoped dependency and its according implementation module as runtime
scoped dependencie like this:
<dependencies>
<dependency>
<groupId>ch.jeeguy.systemA</groupId>
<artifactId>systemA-service</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.jeeguy.systemA</groupId>
<artifactId>systemA-implementations</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
(Of course the POM of the service module as well as the POM of the implementation-module will declare further dependencies to modules of systemA like for example a DTO-Module of systemA required with a scope compile etc.)
So if i now plan to build a new systemB that needs to interact with systemA or reuses certain parts of systemA i dont want systemB to have dependencies on internas of systemA such as its DTO-module but only the dependencie to the above POM. This is how i add the above POM as dependencie in systemB:
<dependency>
<groupId>ch.jeeguy.systemA</groupId>
<artifactId>systemA</artifactId>
<type>pom</type>
<version>${systemA.version}</version>
</dependency>
As faar as i understood everything correctly to this point my componentB will now get systemA's service module as a compile
scoped depencency and the implementation module as runtime
scoped dependency - Each of which define their own dependencies which will become transitive dependencies for systemB and behave like defined here (scope matrix): http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope.
My Question:
If i apply a scope ... overriding the default commpile
... say test
to the POM-typed dependencie of systemA in systemB's POM like this:
<dependency>
<groupId>ch.jeeguy.systemA</groupId>
<artifactId>systemA</artifactId>
<type>pom</type>
<scope>test</scope>
<version>${systemA.version}</version>
</dependency>
What exactly am i applying the test
scope on now? Is it something of the selection below?
i apply the
scope
to the entire POM-dependencie - considered i applyiedtest
the entire information defined in the POM of systemA wont be considered at all unless the contexttest
is given (if systemB is compiled skipping tests whatever information is defined in the group-POM is not consulted). Once the contexttest
is given it will result in systemB gettingcompile
andruntime
dependencies that in this context dont make any sence... . -> "Scope is applied on the POM itself"i override the
scope
of any dependencies defined in the POM of systemA - which in this example results in systemB only depending on systemA's modules for its tests. The compile/runtime scopes of the two dependencies of systemA are in the context of systemB both set totest
. (E.g. "i dont care you want me to use your service-module withscope
compile, i want it to havescope
test!") -> "Scope is applied to the dependencies inside the according POM and thus affects the behaviour of transitive dependencies"
Could you help me out of my confusion i put myself in trying to figure this out?
What i tryied so faar
Even thus i am new to Maven i dont fear to read the entire documentation as well as a book about Maven3 i ordered. I invested aprox. 80-100 hours into my Maven "skills" so faar. I also more or less "fully" understand the behaviour of at least the scope
import
when it comes to dependencyManagement
information like described here: difference between scope "import" and "pom" type dependency yet i cannot manage to find a (official) source to my question. Leaving two possibillies in my eyes: I just overread the according part in the documentation OR (and this unfortunately is more likely) i already have a huge missunderstanding of the concepts of Maven. Especially in the case of the later one i would realy appreciate clarification :) Btw. i am currently trying to reverseengineer the behaviour by just applying the different scopes and analyze the build output ... but i am working with 15 systems and hundreds of modules...