beerBear
beerBear

Reputation: 979

How to include a library module from another project's repo?

I tried to do the same by creating a submodule from SmartGit but it actually copies the full project; moreover I am not able to include it as I have to try using: :old_project_name:common_lib which doesn't work. Kindly read below for more details:

The new project's structure I want:
- lib 1 module
- lib 2 module
- ....
- application module
- common lib module (I want this module from an existing project which has the same structure as this new project but the common lib is part of the old project itself)

Upvotes: 0

Views: 944

Answers (1)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 363895

Just use:

Project
|__build.gradle
|__settings.gradle
|__app (application module)
   |__build.gradle
|__lib1 (lib 1)
   |__build.gradle
|__lib2 (library 2)
   |__build.gradle

In settings.gradle:

include ':app' , ':lib1' , 'lib2'
include ':commonLib'
project(':commonLib').projectDir=new   File('pathLibrary')

In app/build.gradle:

dependencies {
    compile project(':lib1')
    compile project(':lib2')
    compile project(':commonLib')
}

Pay attention to commonLib. You have to use the path of the library inside the other project, not the root of the project

Upvotes: 1

Related Questions