If I want project A
to compile and tests to run but when I place it as a dependency into project B
then project A
's dependencies should not be available to project B
.
For example:
Add org.example.foo
as a dependency into project A
(not B
)
Add project A
as a dependency inside project B
Add this statement in a class inside project B
: import org.example.foo.*
You should get a compilation error on this line: import org.example.foo.*
You should specifiy the dependencies in project "A" with <scope>provided</scope>
. This way the respective dependency is used for compilation & testing, but is not transitively used in project "B".
Here you find the different scopes on maven dependencies: https://maven.apache.org/pom.html#Dependencies