Q: Could not get unknown property 'runtime' for configuration container of type org.gradle.api.internal.artifacts.configurations 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?

A: As mentioned in previous answer(s) support for runtime configuration has been stopped gradle-7.0, so configurations.runtime is not working.
Task copyAllDependencies worked for me in gradle-7.0.
Here is the example to copy dependencies into ${buildDir}/output/libs:
Add following to build.gradle.
task copyAllDependencies(type: Copy) {
    from configurations.compileClasspath
    into "${buildDir}/output/libs"
}
build.dependsOn(copyAllDependencies)

I hope it helps.

A: 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

A: Use runtimeOnly as mentioned in the upgrade documentation of gradle:
https://docs.gradle.org/current/userguide/upgrading_version_6.html#sec:configuration_removal
