Gradle multiproject (android) repositories issue


(Eyal Gal) #1

Hi.
I have multi project gradle project for android. the structure is:

my-app-root
      |
      ===app
      |
      ===core(git submodule)
               |
               ====demoapp(uses core-lib)
               |
               ====core-lib

the app is android app (uses the application plugin), the lib is an android library.
the demo app belongs to the submodule and is not used in the main project, also an android app.
To prevent from the gradle to parse my submodule settings and build gradle i’ve written the following to the settings.gradle:

include ':corelib'
project('corelib').projectDir = new File('./core/corelib')

This worked though i can’t understand why includeFlat(’/core/corelib’) didn’t work…

The lib uses a public bintray repo that is not used in the app. For some reason the app, when evaluated tries to resolve thecorelib dependencies using it’s own RepositoriesHandler, of course it fails…
there for i’ve added the following to the build.gradle of my corelib:
rootProject.allprojects.each { project -> project.repositories.maven ({ url "http://dl.bintray.com/mrepo/maven" }) }
since it’s easier to add it to all project then to search for the app plugin project…

This approach does not really work since the ‘app’ project is evaluated before the lib project and there for searches for it’s dependencies before the lib code has a change to setup the maven repos right.

what’s strange to be is that the dependencies are transitive by default and there for the app SHOULD have access to all dependencies from the lib but it’s not the case for some reason.
i probably can get away by using apply from: ‘…/core/gradle_scripts/’ but i’d rather understand how it should be done properly.

The main point is, i have functionality i want to insert into every app that uses my library, apparently if this functionality requires dependencies\repositories then it can’t be included in the build.gradle of the library. so how should i approach the problem ?


(Eyal Gal) #2

no help ? advice ? too long ?