Local dependencies
Gradle allows to use dependencies from the local binaries or other projects.
dependencies {
// dependency on a subproject (module)
implementation(project(":mylibrary"))
// dependency on a local binary file
implementation(files("libs/lib.jar"))
// dependency on local binaries
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
}
dependencies {
// dependency on a subproject (module)
implementation project(":mylibrary")
// dependency on a local binary file
implementation files('libs/lib.jar')
// dependency on local binaries
implementation fileTree(dir: 'libs', include: ['*.jar'])
}
For adding local module as dependency you must have module in the top-level settings.gradle file:
include ':mylibrary', ':mymodule'
You can add directory with binaries as repository.
// looks for jars in the libs directory and its child directories.
repositories {
flatDir {
dirs ("libs")
}
}
// looks for jars in the libs directory and its child directories.
repositories {
flatDir {
dirs 'libs'
}
}
dependency on project
You can add dependency on other project like module in build.gradle.
implementation project( ':mylib' )
Also you should include project in the top-level settings.gradle file.
include ':mylib', ...
project(':mylib').projectDir = file('~/workspace/mylib/')
// project(':mylib').projectDir = file('../mylib/')