I have a root gradle project and 10 subprojects. I want 5 dependencies to be specified in root project only, without copy-pasting them to all 10 modules. If I write:
subprojects{
dependencies{
compile 'org.codehaus.groovy:groovy-all:2.3.11'
compile 'org.springframework:spring-core:4.1.2.RELEASE'
compile 'org.springframework:spring-context:4.1.2.RELEASE'
}
}
it says to me that compile()
method has not been found. How to make it work so I should specify deps only in one place?
Have you applied java plugin with:
allprojects {
apply plugin: 'java'
}
or:
subprojects {
apply plugin: 'java'
}
?
Please remember that you also need to add repositories block. It will be:
repositories {
mavenCentral()
jcenter()
}
Gradle Doc Reference: 8.2. Declaring your dependencies
You must wrap the compile dependencies with the dependencies
keyword like so:
subprojects {
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.11'
compile 'org.springframework:spring-core:4.1.2.RELEASE'
compile 'org.springframework:spring-context:4.1.2.RELEASE'
}
}
This applies to your root-only libraries as well.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.