Setting hotswapagent dependency jar as javaagent of tomcat for war project lead to a deprecation warning

I’m using the gradle cargo plugin to launch tomcat, and i need to set the hotswapagent jar in the JVM args “-javaagent” of tomcat for hot reload to take place.
I’m doing it in my main build.gradle for every war subproject :

gradle.projectsEvaluated {
    configure(webProjects()) { Project project ->
        apply plugin: 'com.bmuschko.cargo-base'

        configurations {
            tomcat
            hotswapagent
        }

        dependencies {
            tomcat group: 'org.apache.tomcat', name: 'tomcat', version: "${tomcatVersion}", ext: 'zip'
            hotswapagent group: 'org.hotswapagent', name: 'hotswap-agent-core', version: '1.+'
        }

        def deployable = new Deployable(
            files: tasks.getByName(WarPlugin.WAR_TASK_NAME).outputs.files,
            context: project.name
        )

        task localEmbedTomcatRun(type: CargoRunLocal) { task ->
            def jvmArgsLst = ['-Dfile.encoding=UTF-8']
            if (rootProject.properties.getOrDefault('tomcatEmbedDebug', false) as boolean) {
                jvmArgsLst.addAll(["-XXaltjvm=dcevm", "-javaagent:${configurations.hotswapagent.asPath}=autoHotswap=true", "-agentlib:jdwp=transport=dt_socket,address=${rootProject.properties.getOrDefault('tomcatEmbedDebugPort', '5005')},suspend=n,server=y"])
            }
            port = rootProject.properties.getOrDefault('tomcatEmbedPort', '8080') as Integer
            containerProperties.put('cargo.tomcat.ajp.port', rootProject.properties.getOrDefault('tomcatEmbedAJPPort', '8009'))
            containerProperties.put('cargo.rmi.port', rootProject.properties.getOrDefault('tomcatEmbedRMIPort', '8205'))
            deployables = [deployable]
            containerId = 'tomcat8x'
            zipUrlInstaller = new ZipUrlInstaller(
                installConfiguration: configurations.tomcat,
                downloadDir: file("$buildDir/tomcatDownload"),
                extractDir: file("$buildDir/tomcatExtract")
            )
            jvmArgs = jvmArgsLst.join(' ')
        }
    }
}

During the build, i get this warning :

The configuration :mywarproject:hotswapagent was resolved without accessing the project in a safe manner. This may happen when a configuration is resolved from a different project

I don’t understand since i’m in the context of adding a task to a subproject and reading it’s own config, it seems to me that i’m not resolving it from outside.

How can i get rid of this warning ? Thanks

I understand my use case may be overcomplicated, so here is a small reproductible example.
I’m joining a sample project to this message.

gradle.projectsEvaluated {
    configure(webProjects()) { Project project ->
        configurations {
            hotswapagent
        }
        dependencies {
            hotswapagent group: 'org.hotswapagent', name: 'hotswap-agent-core', version: '1.+'
        }
        task myTask() {
            logger.info(configurations.hotswapagent.asPath)
        }
    }
}

The error i get is

The configuration :sub_project:hotswapagent was resolved without accessing the project in a safe manner. This may happen when a configuration is resolved from a different project. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0.

main_project.zip (57.3 KB)

While running this

./gradlew.bat sub_project:mytask -i --warning-mode all