This message was deleted.
# community-support
s
This message was deleted.
r
I have dependencies like this:
Copy code
sourceSets {
...
        val jvmMain by getting {
            dependencies {
 ...
                implementation("org.hotswapagent:hotswap-agent-core:1.4.0")
And my gradle run attempt is:
Copy code
application {
    mainClass.set("ah.MainKt")

    tasks.named<JavaExec>("run") {
        doFirst {
            val hotswapAgentJar = project.configurations
                .matching { it.name == "jvmMainImplementation" }
                .flatMap { it.files }
                .find { it.name.startsWith("hotswap-agent-core") }

            if (hotswapAgentJar != null) {
                jvmArgs(
                    "-javaagent:${hotswapAgentJar.absolutePath}",
                )
                println("Added to jvm args: ${hotswapAgentJar.absolutePath}")
            } else {
                throw IllegalStateException("Hotswap Agent Core dependency not found in the 'implementation' configuration.")
            }
        }

        val main by sourceSets.getting
        args = main.output.asPath.split(":")
    }
}
the attempt of accessing "jvmMainImplementation" results in the error at the top of thread. i've tried a few ways of getting at it. I can iterate over dependencies with:
Copy code
val hotswapAgentCore = configurations.getByName("jvmMainImplementation")
                .dependencies
                .find { it.name.startsWith("hotswap-agent-core") }
...but I couldn't figure out how to turn this into a file path
v
As the error says, you must not resolve that configuration. You probably want
jvmMainRuntimeClasspath
, assuming it follows the usual standard. But actually you should probably not add it to
implementation
at all anyway. Better declare a custom configuration for that.
r
I don't understand why it's complaining though - why the limitation? And what does this mean? "Better declare a custom configuration for that." What would this look like?
v
I don't understand why it's complaining though - why the limitation?
Configurations have different roles. The role of the
implementation
configuration is only to be a bucket on which to declare dependencies, but not to resolve them. There are also configurations that are meant to be consumed by downstream projects, and there are configuration that are meant to resolve configurations. It is explained in detail at https://docs.gradle.org/current/userguide/declaring_dependencies.html and that also shows how to use custom configurations like you should do here.
r
ok, thanks
v
Something like this for example:
Copy code
val hotswapAgent = configurations.dependencyScope("hotswapAgent").get()
val hotswapAgentClasspath = configurations.resolvable("hotswapAgentClasspath") {
    extendsFrom(hotswapAgent)
}
dependencies {
    hotswapAgent("foo:bar:+")
}
println(hotswapAgentClasspath.get().files)