Gradle - Could not get unknown property 'scm&#

2020-07-27 12:19发布

问题:

Execution failed for task ':app:iterateDeclaredDependencies'.
> Could not get unknown property 'scm' for configuration container of type org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer.

I'm using the exact code snippet from Working with Dependencies

I don't know what scm is here but autocompletion seems to suggests that all is good, no?

Versions I'm using:

------------------------------------------------------------
Gradle 5.4.1
------------------------------------------------------------

Build time:   2019-04-26 08:14:42 UTC
Revision:     261d171646b36a6a28d5a19a69676cd098a4c19d

Kotlin:       1.3.21
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          1.8.0_191 (Oracle Corporation 25.191-b12)
OS:           Mac OS X 10.14.6 x86_64

回答1:

To query specific dependency sets, they must be declared first. scm doesn't exist, thus Gradle fails with an error message. Additional dependency sets can be added like this:

configurations {
    scm
}

(Defining custom configurations)

Try with one of the defaults instead, for example implementation.

I'm not an IntelliJ IDEA user, so cannot tell exactly why autocompletion works in this case.