Sometimes you have a local JAR file you need to add as a dependency to your Gradle build. Here's how you can do this:
dependencies {
compile files('path/local_dependency.jar')
}
Where path
is a directory path on your filesystem and local_dependency.jar
is the name of your local JAR file. The path
can be relative to the build file.
It's also possible to add a directory of jars to compile. This can be done like so:
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
Where libs
would be the directory containing the jars and *.jar
would be the filter of which files to include.
If you only want to lookup jars in a repository instead of directly adding them as a dependency with their path you can use a flatDir repository.
repositories {
flatDir {
dirs 'libs'
}
}
Looks for jars in the libs
directory and its child directories.