When replacing a transitive project dependency with an external dependency, you still get the transitive dependency built, because the direct dependency still depends on the project, and not on the replacement. While this can be argued to be the correct behavior, it might also be pretty confusing if this is not your intention.
Question: do we want to do something about this?
Example:
Take the following three Java projects and their configurations (-> means "depends on", => means configuration extends other configuration):
But what should happen when you run :test:jar? I'd expect :api:jar not to run, because we just replaced the :api project dependency with an external dependency:
However, when we build the task graph, we calculate :impl:jar's dependencies from the :impl:compile configuration, and not from :test:compile. So we end up still running :api:jar. Only we won't use the Jar produced that way in the :test project, but we'd use the external dependency.
When replacing a transitive project dependency with an external dependency, you still get the transitive dependency built, because the direct dependency still depends on the project, and not on the replacement. While this can be argued to be the correct behavior, it might also be pretty confusing if this is not your intention.
Question: do we want to do something about this?
Example:
Take the following three Java projects and their configurations (
->
means "depends on",=>
means configuration extends other configuration):The
:test
project'scompile
configuration dependency chain looks like this:From the
:impl
project's point of view the world looks like this:Now, in
:test:compile
, replace the:api
project dependency with an external dependency. But do NOT replace it in:impl
.So now
:test
sees things like this:...while for
:impl
things remain unchanged:When you run
:impl:jar
, you get:api:jar
executed as well, because of the Jar artifact on:api:compile
.But what should happen when you run
:test:jar
? I'd expect:api:jar
not to run, because we just replaced the:api
project dependency with an external dependency:However, when we build the task graph, we calculate
:impl:jar
's dependencies from the:impl:compile
configuration, and not from:test:compile
. So we end up still running:api:jar
. Only we won't use the Jar produced that way in the:test
project, but we'd use the external dependency.