Reputation: 13
I'm creating a news downloading gradle project with the following directory structure.
news-feed (root)
|-bbc-plugin (sub-project)
I want to use the jsoup library for my sub-projects so I add the dependency to my root build.gradle file as follows.
import org.gradle.api.artifacts.*
apply plugin: 'base' // To add "clean" task to the root project.
apply plugin: 'application'
mainClassName = 'newsFeed.MainMenu'
subprojects {
apply from: rootProject.file('common.gradle')
apply plugin: 'java'
dependencies {
compile 'org.jsoup:jsoup:1.10.3'
}
}
dependencies {
compile project(':bbc-plugin')
}
I can't build the project because of the error
* What went wrong:
Could not resolve all files for configuration ':bbc-plugin:compileClasspath'.
> Can't resolve external dependency org.jsoup:jsoup:1.10.3 because no repositories are defined.
Required by:
project :bbc-plugin
Is there are way to specify the dependency in the root build file without having to specify in the build.gradle file of each sub-project?
Upvotes: 1
Views: 1433
Reputation: 4021
You need to tell gradle from which repository it can download your dependency. To achieve this, you need to add a repositories
section to your build script.
To use Maven Central, for instance, you need to add the following lines to your to root build.gradle:
repositories {
mavenCentral()
}
See here and here in the Gradle user guide for a more detailed description.
Upvotes: 1