I am running into a problem with trying to include a Git submodule in my Gradle project and depend on a single Gradle module within the Git submodule.
The submodule is a library that has the following structure:
MappingLib
-BaseLib
-AndroidLib
Where the settings.gradle file for MappingLib contains:
include ':BaseLib', ':AndroidLib'
and the AndroidLib's build.gradle file contains (among other things):
dependencies {
...
compile project(':BaseLib')
...
}
The submodule builds fine when it is developed independently.
I then have another project that is including MappingLib as a submodule. This project has the following structure:
MyCoolApp
-app
-MappingLib (this is the submodule)
-BaseLib
-AndroidLib
What I would like to accomplish is to have ':app' depend on ':MappingLib:AndroidLib' (which in turn depends on the BaseLib). However, I cannot seem to get this working.
Attempt #1
MyCoolApp/settings.gradle:
include ':app', ':MappingLib'
MyCoolApp/app/build.gradle
dependencies {
...
compile project(':MappingLib:AndroidLib')
...
}
This yields the error Project with path ':MappingLib:AndroidLib' could not be found in project ':app'
Attempt #2
So I tried to explicitly call out the MappingLib modules...
MyCoolApp/settings.gradle:
include ':app', ':MappingLib:AndroidLib', ':MappingLib:BaseLib'
This yields the error Project with path ':BaseLib' could not be found in project ':MappingLib:AndroidLib'
. This made me think that the problem is the dependency paths inside the MappingLib project, i.e. the root dir of the project (MyCoolApp) is one level higher than what the gradle files in the MappingLib submodule expect.
So...
Attempt #3
MyCoolApp/settings.gradle:
include ':app', ':MappingLib:AndroidLib', ':MappingLib:BaseLib'
project(':MappingLib:AndroidLib').projectDir = file(new File(rootDir, 'MappingLib'))
This yields the error: Configuration with name 'default' not found.
From this post (https://stackoverflow.com/a/22547615/4708255) it seems that this means that gradle cannot find a build.gradle file somewhere, but I am not sure where to go from here.
What is the proper way to achieve the result that I am looking for?