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?