{"action":"opened","issue":{"url":"https://api.github.com/repos/gradle/gradle/issues/4741","repository_url":"https://api.github.com/repos/gradle/gradle","labels_url":"https://api.github.com/repos/gradle/gradle/issues/4741/labels{/name}","comments_url":"https://api.github.com/repos/gradle/gradle/issues/4741/comments","events_url":"https://api.github.com/repos/gradle/gradle/issues/4741/events","html_url":"https://github.com/gradle/gradle/issues/4741","id":305667590,"number":4741,"title":"buildSrc leaks dependencies into the main project's build script classpath","user":{"login":"hungvietnguyen","id":24703754,"avatar_url":"https://avatars2.githubusercontent.com/u/24703754?v=4","gravatar_id":"","url":"https://api.github.com/users/hungvietnguyen","html_url":"https://github.com/hungvietnguyen","followers_url":"https://api.github.com/users/hungvietnguyen/followers","following_url":"https://api.github.com/users/hungvietnguyen/following{/other_user}","gists_url":"https://api.github.com/users/hungvietnguyen/gists{/gist_id}","starred_url":"https://api.github.com/users/hungvietnguyen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hungvietnguyen/subscriptions","organizations_url":"https://api.github.com/users/hungvietnguyen/orgs","repos_url":"https://api.github.com/users/hungvietnguyen/repos","events_url":"https://api.github.com/users/hungvietnguyen/events{/privacy}","received_events_url":"https://api.github.com/users/hungvietnguyen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-15T18:21:14Z","updated_at":"2018-03-15T18:21:14Z","closed_at":null,"author_association":"NONE","body":"### Expected Behavior\r\nbuildSrc should not leak dependencies into the main project's build script classpath\r\n\r\n### Current Behavior\r\nbuildSrc leaks dependencies into the main project's build script classpath\r\n\r\n### Context\r\nBuild fails at configuration time due to Gradle loading the wrong version of Guava. Example bugs in Android Studio: https://issuetracker.google.com/70970475, https://issuetracker.google.com/71441014, https://issuetracker.google.com/71536362, https://issuetracker.google.com/72880673\r\n\r\n### Steps to Reproduce\r\nI've also attached a project: \r\n[buildSrcLeakedDependency.zip](https://github.com/gradle/gradle/files/1816614/buildSrcLeakedDependency.zip)\r\n\r\n 1. Create a new empty Gradle project\r\n 2. Create buildSrc/build.gradle and add a dependency on guava 18:\r\n```\r\nrepositories {\r\n    jcenter()\r\n}\r\ndependencies {\r\n    implementation 'com.google.guava:guava:18.0'\r\n}\r\n```\r\n\r\n 3. In the root project's build.gradle, add a dependency on guava 22, and call a method that exists in guava 22 but not in guava 18:\r\n```\r\nbuildscript {\r\n    repositories {\r\n        jcenter()\r\n    }\r\n    dependencies {\r\n        classpath 'com.google.guava:guava:22.0'\r\n    }\r\n}\r\nprintln com.google.common.collect.ImmutableSet.toImmutableSet() \r\n```\r\n\r\n 4. Run ./gradlew help to trigger the call to guava.\r\n 5. Observe that the build fails, saying that the method does not exist.\r\n 6. Remove the dependency on guava 18 in buildSrc/build.gradle, rerun ./gradlew help, and observe that the build succeeds.\r\n\r\n### Your Environment\r\nGradle version: 4.5\r\n\r\n### Notes\r\nThis issue is mentioned at \"Central plugin classpath management\" (https://github.com/gradle/gradle/issues/1370), but because that proposal aims to solve multiple issues at the same time, I wanted to create this bug for users who are coping specifically with this issue.\r\n\r\nIn particular, I'd like to learn Gradle's thoughts on the way forward with this issue and workarounds for the moment.\r\n\r\nThe current workarounds seem to include:\r\n - Declare all plugin dependencies in buildSrc (if using buildSrc), or\r\n - Upgrade the versions of the problematic dependency to a common version. In the example, that would mean adding the following to buildSrc/build.gradle\r\n\r\n```\r\ndependencies {\r\n    implementation 'com.google.guava:guava:22.0'\r\n}\r\n```"}}
{"actor":{"display_login":"hungvietnguyen"}}