How to add local .jar file dependency to build.gradle file?

To add a local JAR file dependency to a build.gradle file, you can use the compile fileTree() method and specify the directory where the JAR file is located.

Here is an example of how to do this:

dependencies {
  compile fileTree(dir: '/path/to/jar/dir', include: '*.jar')
}

This will include all JAR files in the specified directory as dependencies.

You can also specify a single JAR file by using the compile files() method and specifying the path to the JAR file:

dependencies {
  compile files('/path/to/jar/file.jar')
}

Note that the path to the JAR file or directory should be specified as an absolute path or a path relative to the root directory of the project.

If you want to exclude certain JAR files from the dependency, you can use the exclude parameter to specify the names of the JAR files that you want to exclude. For example:

dependencies {
  compile fileTree(dir: '/path/to/jar/dir', include: '*.jar', exclude: ['jar1.jar', 'jar2.jar'])
}

This will include all JAR files in the specified directory except for jar1.jar and jar2.jar.