# Why are compile dependencies of java plugin transitive?

**URL:** <https://discuss.gradle.org/t/why-are-compile-dependencies-of-java-plugin-transitive/4975>\
**Category:** Old Forum Archive\
**Created:** [March 15, 2014, 3:20pm UTC](https://discuss.gradle.org/t/why-are-compile-dependencies-of-java-plugin-transitive/4975 "2014-03-15T15:20:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rado\_Onex](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@Rado\_Onex](https://discuss.gradle.org/u/Rado_Onex)\
**Post date:** [March 15, 2014, 3:20pm UTC](https://discuss.gradle.org/t/why-are-compile-dependencies-of-java-plugin-transitive/4975/1 "2014-03-15T15:20:00Z")

</div>

Hi!

I was wondering, if there is a reason for the java compile dependencies to be transitive by default. Transitivity makes it easy to forget declaring direct compile dependencies of a project. Your code compiles successfully because some declared dependency (D1) brought in (transitively) another dependency (D2) your module directly depends on, but you have not declared D2 explicitly. Now imagine D1 stops depending on D2. Your build gets broken for no apparent reason. This makes the build brittle.

Maybe I’m missing something, but I think you shouldn’t need transitive compile dependencies (maybe except for annotations), so why make it default? I know I can change the behavior easily setting transitive to false, but I’d like to get the full picture (with possible consequences) before making that decision.

Thans, Rado

---

<div class="post-metadata">

**Author:** ![luke\_daley](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/luke_daley/32/9890_2.png) [@luke\_daley](https://discuss.gradle.org/u/luke_daley)\
**Post date:** [March 17, 2014, 12:56am UTC](https://discuss.gradle.org/t/why-are-compile-dependencies-of-java-plugin-transitive/4975/2 "2014-03-17T00:56:00Z")

</div>

Hi Rado,

In the early days of Gradle (and in Maven 1.x), compile dependencies were non transitive by default, but over time a pragmatic decision was made to favour convenience over correctness. Maven 2 made compile dependencies transitive, and given that the majority of Java based projects in the wild using dependency management were based on Maven 2, it was considered more useful to be transitive by default.

You are right in that being non transitive is more correct though, and many Gradle users choose to opt in to this more correct mode.

---

<div class="post-metadata">

**Author:** ![carlo\_lf](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/carlo_lf/32/1881_2.png) [@carlo\_lf](https://discuss.gradle.org/u/carlo_lf)\
**Post date:** [March 17, 2014, 6:45pm UTC](https://discuss.gradle.org/t/why-are-compile-dependencies-of-java-plugin-transitive/4975/3 "2014-03-17T18:45:00Z")

</div>

Maybe this should go at least as a hint (“better be explicit…”) into the User Guide?
