Reputation: 2291
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?
Upvotes: 1
Views: 164
Reputation: 84756
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()
}
Upvotes: 3
Reputation: 10244
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.
Upvotes: 1