I've got the error (Could not get unknown property 'runtime' for configuration container of type org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer.) when I followed answer to how to copy all source jars using gradle, added the below code to build.gradle and run that task in IJ IDEA:
task copySourceJars( type: Copy ) {
def sources = configurations.runtime.resolvedConfiguration.resolvedArtifacts.collect { artifact ->
project.dependencies.create( [
group: artifact.moduleVersion.id.group,
name: artifact.moduleVersion.id.name,
version: artifact.moduleVersion.id.version,
classifier: 'sources'
] )
}
from configurations.detachedConfiguration( sources as Dependency[] )
.resolvedConfiguration.lenientConfiguration.getFiles( Specs.SATISFIES_ALL )
into file( 'some-directory/' )
}
I did a web search for the error but found on stackoverflow only Gradle - Could not get unknown property 'scm' for configuration container where it is advised to add configuration like what I did after reading that post:
configurations {
runtime
}
After that on task copySourceJars
run it wrote BUILD SUCCESSFUL, but no files appeared in specific directory on hard drive. Build output for some reason do not list copySourceJars
:
Executing tasks: [:app:generateDebugSources]
Gradle Daemon started in 1 s 427 ms
> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:checkDebugManifest UP-TO-DATE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :app:prepareLintJar UP-TO-DATE
> Task :app:generateDebugSources UP-TO-DATE
BUILD SUCCESSFUL in 9s
4 actionable tasks: 4 up-to-date
Then I again chose run
from IDEA menu and got another error:
Could not open init remapped class cache for dulrvlqnmf04w7h3gseaejvhm (/Users/user/.gradle/caches/5.2.1/scripts-remapped/ijresolvers_8btlazswoejgb1uwugudd695x/dulrvlqnmf04w7h3gseaejvhm/init3ca90766b0adfce53d4b035e7e9dc5fe).
Could not open init generic class cache for initialization script '/private/var/folders/g7/2zrjv4hd04v4vkhkbm3stchjwwbz27/T/ijresolvers.gradle' (/Users/user/.gradle/caches/5.2.1/scripts/dulrvlqnmf04w7h3gseaejvhm/init/init3ca90766b0adfce53d4b035e7e9dc5fe). BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 57
Am I doing all correctly to download dependancies using IJ IDEA? Maybe that adding configuration runtime
was not done properly?
The runtime configuration has been removed in Gradle 7.0 after it has been deprecated for a while. If the error is caused by the com.github.onslip.gradle-one-jar please open an issue there. Sorry, something went wrong. Sign up for free to join this conversation on GitHub .
From Gradle 6.x, the use of the parameter configurations.runtime to get configurations of program execution is disabled. Instead, you can use configurations.runtimeClasspath to achieve the same ability. Gradle7 docs After that, I succeeded in compilitation and get the true constructure of project.
Assuming that the gradle task is trying to compile some java code, you have to replace configurations.compile with configurations.compileClasspath. It points out to the list of dependencies that the JDK requires to compile the java code.
I ended out using disconnectionist's answer - insetad of upgrading from 4.2.1 to 7.0.3 I only upgraded to 4.2.2. it should be runtimeClasspath and not implementation. about configurations.implementation: Resolving dependency configuration 'implementation' is not allowed as it is defined as 'canBeResolved=false'.
This is because of the differences between your gradle version and gradle7. From Gradle 6.x, the use of the parameter configurations.runtime
to get configurations of program execution is disabled. Instead, you can use configurations.runtimeClasspath
to achieve the same ability.
Gradle7 docs
After that, I succeeded in compilitation and get the true constructure of project.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.1/userguide/command_line_interface.html#sec:command_line_warnings
Project Constructure
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With