Multi-project build Sample
version 6.3-rc-2
You can open this sample inside an IDE using the IntelliJ native importer or Eclipse Buildship. |
This sample shows how to use dependencies within a JVM multi-project build in Gradle. This is the same pattern used by all JVM languages (Java, Groovy, Scala).
The application
project has an implementation dependency on the utilities
project:
application/build.gradle
plugins {
id 'application'
}
dependencies {
implementation project(':utilities')
}
application {
mainClassName = 'org.gradle.sample.Main'
}
application/build.gradle.kts
plugins {
application
}
dependencies {
implementation(project(":utilities"))
}
application {
mainClassName = "org.gradle.sample.Main"
}
Which in turn has an API dependency on the list
project:
utilities/build.gradle
plugins {
id 'java-library'
}
dependencies {
api project(':list')
}
utilities/build.gradle.kts
plugins {
`java-library`
}
dependencies {
api(project(":list"))
}
To build the projects, you simply need to build the application:
$ ./gradlew :application:run > Task :application:run Hello, World! BUILD SUCCESSFUL 6 actionable tasks: 6 executed
For more information, see dependency management chapters.