Caleb Cushing
04/03/2024, 8:23 AMVampire
04/03/2024, 8:39 AMdependencyScope configuration on which you define the dependency and a custom resolvable configuration extending from it, then use the resolution result of that configuration to get the jar and use it however you likeCaleb Cushing
04/03/2024, 8:49 AMThomas Broyer
04/03/2024, 8:57 AMdependencyScope and resolvable to help create those: https://docs.gradle.org/8.4/release-notes.html#configuration-roleThomas Broyer
04/03/2024, 8:59 AMval server = configurations.dependencyScope("server")
val serverClasspath = configurations.resolvable("serverClasspath") {
extendsFrom(server.get())
// add attributes here for variant selection if needed
}
dependencies {
server("…")
}
tasks {
register<JavaExec>("runServer") {
classpath = serverClasspath.get()
mainClass = "…"
}
}Vampire
04/03/2024, 9:01 AMVampire
04/03/2024, 9:04 AMval server by instead of val server =, then you can save the .get(), as configurations are not treated lazily anyway.Caleb Cushing
04/03/2024, 9:14 AMThomas Broyer
04/03/2024, 9:18 AMby such providers. Will refactor a few build scripts, thanks! 😉Vampire
04/03/2024, 9:19 AMby all providers to .get() them.Vampire
04/03/2024, 9:20 AMby but just get the original variable. But in some situations like here it is quite handy 🙂