Copy all dependencies of implementation configuration fails

How can I copy all configurations of the implementation configuration into a separate folder?
Since “compile” configuration is deprecated I changed all dependencies to “implementation”, but now the copy job fails. I also changed my copy task from configurations.compile to configurations.implementation:

ext.libDir = ‘build/lib’
task copyDependencies(type: Copy) {
into libDir
from configurations.implementation
}

When I execute the task, I get an error:

  • What went wrong:
    Could not determine the dependencies of task ‘:mobile:copyDependencies’.

Resolving configuration ‘implementation’ directly is not allowed

It worked before with configurations.compile.

I’m using Gradle 4.1 and Android Gradlre Plugin 3.0.1

If there is another way to copy all dependencies of my project in a separate folder I would be very happy for any idea.

Thanks

implementation can’t be resolved, because it doesn’t know if you want the api or runtime dependencies. Use compileClasspath or runtimeClasspath instead, depending on what you need.

2 Likes

Thanks for the response.
I already tried these properties but won’t work.
In both cases I get the error:

A problem occurred evaluating project ‘:mobile’.

Could not get unknown property ‘compileClasspath’ for configuration container of type org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer.
or
Could not get unknown property ‘runtimeClasspath’ for configuration container of type org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer.

I’m using flavors (beta and production) and, of course, build types (debug and release). Maybe this is a relevant information

You’ll need to use the Configuration for the Android variant that you care about then. Or create a task that collects the dependencies from all variants. It depends on what you are trying to do.

If I try this

from configurations.productionReleaseRuntimeClasspath

I get the following error:

Could not get unknown property ‘productionReleaseRuntimeClasspath’ for configuration container of type org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer.

Your code is running before the Android plugin creates its configurations. It only creates them once it knows all the flavors and build types. You’ll have to use some lazy construct to forward-reference it, e.g configurations.matching { name == ... } or you have to use afterEvaluate {} to be called after the Android plugin has created its configurations and tasks.

1 Like