ChrLipp
ChrLipp

Reputation: 15678

Gradle multiproject and lib jar directory

I have a Gradle multi-project build and have to inlcude a JAR file which has to come from a lib directory.

First I had the following structure:

- Directory "project"
  - Directory "sub project 1"
    - Directory "lib"
      - File "A.jar"
  - Directory "sub project 2"

And the following ´gradle.build´ (only an excerp) for "sub project 1":

repositories {
    flatDir {
        dirs 'lib'
    }
}

When I compile "sub project 2" I get an error because A.jar cannot be resolved. To solve this I took the following approach:

1: I moved the lib dir in the project root

- Directory "project"
  - Directory "sub project 1"
  - Directory "sub project 2"
  - Directory "lib"
    - File "A.jar"

2: I defined the lib dir in the ´gradle.build´ for "project" like

subprojects {
    repositories {
        flatDir {
            dirs '../lib'
        }
    }
}

3: I removed the lib dir entry from the ´gradle.build´ for "sub project 1".

Now the question: is this a reasonable approach or if not, what is the recommended way to solve this?

Upvotes: 3

Views: 705

Answers (1)

Peter Niederwieser
Peter Niederwieser

Reputation: 123986

If you want the projects to declare individual dependencies on the libraries in the lib directory, like you would when working with a Maven or Ivy repository, then the approach is fine.

Upvotes: 3

Related Questions