i have a library which uses all of our apps. except for shared code and resources i wanted to share gradle code. each app is constructed: some_app/ | - settings.gradle - build.gradle | - mylib/ | -build.gradle - other_lib/ - app/ | - build.gradle
right now i'm talking about the build.gradle in the root dir. The one that defines buildScript closure with dependecies and allprojects{} closure as well.
i tried to use apply from: './mylib/gradle_files/baseProject.gradle' it works, but then my app can't find the android plugin. for some reason the classpath dependencies were not injected into the build script! i then tried to create a list and use that:
ext.projectBaseDependencies = ['com.android.tools.build:gradle:2.1.2', 'com.google.gms:google-services:3.0.0']
I then used the list in my closure:
apply from: './mylib/gradle_files/baseProject.gradle'
buildscript { repositories { jcenter() } dependencies { classpath projectBaseDependencies } }
it doesn't work, gradle does not find my variable defined in baseProject.gradle. I have a hunch that apply from works AFTER buildScript closure is evaluated :-(
Is there any way to share gradle script code across ALL apps ? if not apply from, what CAN work ? skip configuration and config in afterEvaluate {} clause ?