When setting an existing build-configuration to resolvable, eg. in order to generate :javadocs
...
configurations.getByName("implementation").isCanBeResolved = true
This leads to the following deprecation warning:
Calling setCanBeResolved(true) on configuration ':implementation' has been deprecated.
This will fail with an error in Gradle 9.0.
This configuration's role was set upon creation and its usage should not be changed.
Consult the upgrading guide for further information:
https://docs.gradle.org/8.14.2/userguide/upgrading_version_8.html#configurations_allowed_usage
at Build_gradle.<init>(build.gradle.kts:55)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
Source: build.gradle.kts
When following the given link to the documentation, it doesn't really tell what to do about it.
So how to clone configuration implementation
and set property isCanBeResolved = true
?
The issue is rather related to Gradle than Android, but may well happen in an Android project.
In Kotlin DSL, this means by configurations.creating
combined with extendsFrom()
.
val implCls: Configuration by configurations.creating {
extendsFrom(configurations.getByName("implementation"))
isCanBeResolved = true
}
Obviously, one also has refer to implCls
instead of implementation
then.
classpath += implCls.asFileTree.filter {it.extension == "jar"}
Now there's also two specific Configuration
sub-classes (incubating):