Skip to content

Commit

Permalink
fix(gradle-plugin): Guard dependencyResolutionManagement usage
Browse files Browse the repository at this point in the history
Do not use that feature before it was added in Gradle 6.8, see [1]. This
is a fixup for 8deb4b3.

Fixes #9282.

[1]: https://docs.gradle.org/6.8/release-notes.html#central-declaration-of-repositories

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Oct 15, 2024
1 parent b54962b commit 47f73b4
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ internal class OrtModelBuilder : ToolingModelBuilder {
override fun canBuild(modelName: String): Boolean = modelName == OrtDependencyTreeModel::class.java.name

override fun buildAll(modelName: String, project: Project): OrtDependencyTreeModel {
// There currently is no way to access Gradle settings without using internal API, see
// https://github.com/gradle/gradle/issues/18616.
val settings = (project.gradle as GradleInternal).settings
if (GradleVersion.current() >= GradleVersion.version("6.8")) {
// There currently is no way to access Gradle settings without using internal API, see
// https://github.com/gradle/gradle/issues/18616.
val settings = (project.gradle as GradleInternal).settings

settings.dependencyResolutionManagement.repositories.associateNamesWithUrlsTo(repositories)
}

settings.dependencyResolutionManagement.repositories.associateNamesWithUrlsTo(repositories)
project.repositories.associateNamesWithUrlsTo(repositories)

val relevantConfigurations = project.configurations.filter { it.isRelevant() }
Expand Down

0 comments on commit 47f73b4

Please sign in to comment.