Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildSrc dependencies leaks are not visible in gradlew buildEnvironment #8301

Open
Tracked by #25616
Tolriq opened this issue Jan 22, 2019 · 7 comments
Open
Tracked by #25616

Comments

@Tolriq
Copy link

Tolriq commented Jan 22, 2019

Expected Behavior

I have read #4741 and understood that it's normal that the buildSrc dependencies currently leak even if using implementation.

But due to the lack of resolution this can cause build issues because any dependency declared in buildSrc will override later declarations.
While this is an issue the main issue is that gradlew buildEnvironment does not report the dependencies from buildSrc but the normal declarations. Making very very hard to debug dependencies issues when there's no direct build issues.

Current Behavior

gradlew buildEnvironment does not return the real dependencies that are used!

Context

My project is build with wrong dependencies used and since there was no errors I had no way to know that I was using the wrong ones.

Steps to Reproduce (for bugs)

Gradle 5.1.1 / Windows

In buildSrc/build.gradle.kts

dependencies {
    implementation("com.android.tools.build:gradle:3.3.0")
}

in the application root build.gradle.kts

buildscript {
    dependencies {
        classpath("com.android.tools.build:gradle:3.4.0-beta1")
     }
}

Running gradlew buildEnvironment will produce

classpath
+--- com.android.tools.build:gradle:3.4.0-beta01

But in reality version 3.3.0 will be used. If the plugin does not log it's version it's virtually impossible to know that wrong dependency is used.

@bigdaz
Copy link
Member

bigdaz commented Jun 18, 2019

Unfortunately, the buildEnvironment task only reports on the resolved classpath of the project itself: the buildSrc dependencies leak in via classloader hierarchy, not via dependency resolution.

So the best idea I have to fix the reporting would be for buildEnvironment to include an additional report of buildSrc.compileClasspath. (You can see this by running gradle dependencies from inside the buildSrc directory).

Unfortunately the Gradle team have limited capacity to work on improvements, and prioritization is hard. @Tolriq would you be interested in helping out with a fix?

@rkrisztian
Copy link

rkrisztian commented Jul 20, 2019

In a big Gradle project this can be really confusing and time consuming to debug. Guava versions below 21 have been causing issues for so long, and so many libraries depend on such versions. It is not straightforward at all to look into buildSrc too. Please give this ticket more priority.

@TWiStErRob
Copy link
Contributor

@Tolriq long time no see 👋.

@Tolriq @rkrisztian @autonomousapps @martinbonnin @deeTEEcee What's the reason for having a mix of buildSrc and classpath dependencies? For us, it's simply a long migration to buildSrc in progress.

@bigdaz Do you think that moving all the dependencies to be declared in buildSrc is a viable workaround? In that case buildEnvironment would still give a bad output, but buildSrc > dependencies will always give a full picture because there would be no buildscript.dependencies.classpaths mixing things up.

@autonomousapps
Copy link
Contributor

Lots of plugins don't publish proper descriptors, and so you have to use the classpath approach. I don't think I should be forced to declare all dependencies in buildSrc?

@martinbonnin
Copy link
Contributor

For what it's worth, when I'm in need of a buildSrc directory, I usually move all the plugins to the dependencies {} block there to avoid having conflicting dependencies. I do this using the old implementation("$group:$artifact:$version") syntax, but I can still use the plugins {} block in the rootProject modules since the plugins are then in the classpath.

I know the Gradle team is moving to convention-plugins and using them from regular included builds (and not buildSrc). I haven't wrapped my head 100% around this but there's a good exemple there: https://github.com/jjohannes/idiomatic-gradle

@ljacomet ljacomet added the in:reporting-tasks help dependencyInsight dependencies label Nov 19, 2021
vmishenev added a commit to Kotlin/dokka that referenced this issue Jul 19, 2023
vmishenev added a commit to Kotlin/dokka that referenced this issue Jul 21, 2023
* Update Kotlin Gradle Plugin to 1.9.0

* Update Android Gradle Plugin to 4.2.2

* Introduce convention plugin for Gradle runner

gradle/gradle#8301

* Fix unit test `common, jvm and macos source sets with kotlin multiplatform`

* Update compiler to 1.9.0

* Update integration test

* Add empty target for WASM integration test to avoid single target project

See #3038

* Remove unused `plugins.shadow` from toml
IgnatBeresnev pushed a commit to Kotlin/dokka that referenced this issue Jul 21, 2023
* Update Kotlin Gradle Plugin to 1.9.0

* Update Android Gradle Plugin to 4.2.2

* Introduce convention plugin for Gradle runner

gradle/gradle#8301

* Fix unit test `common, jvm and macos source sets with kotlin multiplatform`

* Update compiler to 1.9.0

* Update integration test

* Add empty target for WASM integration test to avoid single target project

See #3038

* Remove unused `plugins.shadow` from toml

(cherry picked from commit f5393dd)
@ov7a ov7a added the a:bug label Sep 5, 2023
@mlopatkin
Copy link
Member

The issue is in the backlog of the relevant team and is prioritized by them.


We may probably fix this before doing any changes to the classloader structure, but this is unlikely to happen in the short or medium term.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests