0

I have a custom build version of a common library that I want my Gradle build to use instead of downloading standard version from any repository.

Ideally, I need to place *jar files of the library in a project's subfolder and make gradle to use that copy of library when building and later running my project.

How can I achieve that?

Opal
  • 81,889
  • 28
  • 189
  • 210
onkami
  • 8,791
  • 17
  • 90
  • 176

1 Answers1

2

Please have a look at the docs. You can define a flat directory repository, which is explained here:

repositories {
    flatDir {
        dirs 'lib'
    }
    flatDir {
        dirs 'lib1', 'lib2'
    }
}

or you can also include a flat jar file as a dependency, see here:

dependencies {
    runtime files('libs/a.jar', 'libs/b.jar')
    runtime fileTree(dir: 'libs', include: '*.jar')
}
Opal
  • 81,889
  • 28
  • 189
  • 210
  • 1
    Flat Dir repositories should be a last resort as this DOES NOT support dependency meta data (eg transitive dependencies). You should explore composite build and also local directory based maven repository rather than flatDir – lance-java Apr 10 '17 at 12:27
  • Thanks @LanceJava for the important comment. – Opal Apr 10 '17 at 12:28
  • it seems it only works when lib directory is at current directory if it is at parent directory it will fail ''' repositories { flatDir { dirs '../lib' } } – stewchicken Nov 16 '19 at 11:10