Skip to content

Commit

Permalink
Fixed Gradle script for dependency downloading (joernio#4567)
Browse files Browse the repository at this point in the history
`configurations.default` can not be resolved by default.
The previous hack with `.setCanBeResolved(true)` will be deprecated with Gradle 9 and finally removed / disabled in future releases (same for `implementation`). The proper way to do this is by re-using a resolvable configuration (resolvable by default) in the `from` clause of the task.

More info: https://docs.gradle.org/current/userguide/declaring_dependencies.html#sec:resolvable-consumable-configs and https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_configurations_graph
  • Loading branch information
max-leuthaeuser authored May 17, 2024
1 parent 6a78c9e commit 6a42e46
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,22 @@ object GradleDependencies {
|""".stripMargin
}

// this init script _should_ work with Gradle 4-8, but has not been tested thoroughly
// this init script _should_ work with Gradle >=4, but has not been tested thoroughly
// TODO: add test cases for older Gradle versions
private def gradle5OrLaterInitScript(
taskName: String,
destination: String,
gradleConfigurationName: String
): String = {
val into = destination.replaceAll("\\\\", "/")
val fromConfigurations =
Set(s"from configurations.$gradleConfigurationName", "from configurations.runtimeClasspath").mkString("\n")
s"""
|allprojects {
| apply plugin: 'java'
| task $taskName(type: Copy) {
| configurations.$gradleConfigurationName.setCanBeResolved(true)
| configurations.implementation.setCanBeResolved(true)
| configurations.default.setCanBeResolved(true)
| into "${destination.replaceAll("\\\\", "/")}"
| from configurations.default
| $fromConfigurations
| into "$into"
| }
|}
|""".stripMargin
Expand Down

0 comments on commit 6a42e46

Please sign in to comment.