Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include jars files from the sub folders in gradle

Tags:

gradle

We maintain different folders to keep all the jars.

Ex:

Repo
\-- lib
    \-- test
        \-- junit.jar
    \-- hibernate
        \-- hibernate.jar

I used the bellow code.

repositories {
    flatDir {dirs "../Repo/lib/*"}      
}

If I put all the jars in lib it works fine. But If I put it in different folders it give the compilation error.

I tried with this

repositories {
        flatDir {dirs "../Repo/lib/**"}     
    }

Please guide me.

like image 262
Java-Seekar Avatar asked Jan 28 '14 15:01

Java-Seekar


People also ask

How do I add a jar file to Gradle?

First, we go to Project Structure: Then we click on the plus button on top of the list and select Java: Then a dialogue window asks us to locate the JAR file. After selecting it, we can click on OK, and our project can access the methods and classes in the archive.

Where are Gradle dependency JARs?

Gradle declares dependencies on JAR files inside your project's module_name /libs/ directory (because Gradle reads paths relative to the build.gradle file). This declares a dependency on version 12.3 of the "app-magic" library, inside the "com.example.android" namespace group.


1 Answers

When declaring a flatDir repository, you need to pass a (relative or absolute) directory path. You can't use wildcards, but may pass multiple directory paths. For example:

repositories {
    flatDir {
        dirs "../Repo/lib/lib1", "../Repo/lib/lib2"
    }
}

For further details, see the Gradle Build Language Reference.

like image 192
Peter Niederwieser Avatar answered Oct 22 '22 13:10

Peter Niederwieser