this one works
allprojects {
apply plugin: ServicePlugin
configurations {
service
}
}
class ServicePlugin implements Plugin<Project> {
void apply(Project theProject) {
theProject.configurations.whenObjectAdded{o ->
if (o.name.contains('service')){
o.dependencies.whenObjectAdded{ d ->
theProject.dependencies {
println "adding dependency"
compile
project(path: ":"+d.dependencyProject.name, configuration: 'compile')
compile
project(path: ":"+d.dependencyProject.name, configuration: 'archives')
runtime
project(path: ":"+d.dependencyProject.name, configuration: 'runtime')
runtime
project(path: ":"+d.dependencyProject.name, configuration: 'archives')
}
}
}
}
}
}
settings.gradle include ‘app’ include ‘library’ include ‘baseLibrary’ include ‘util’
app:build.gradle apply plugin: ‘java’ apply plugin: ‘application’
mainClassName=“com.example.android.multiproject.MainActivity” dependencies {
service project(’:library’) } library:build.gradle apply plugin: ‘java’
dependencies {
service project(’:baseLibrary’) } baseLibrary:build.gradle apply plugin: ‘java’
dependencies {
runtime project(’:util’) }
gradle :app:dependencies :app:dependencies
------------------------------------------------------------ Project :app ------------------------------------------------------------
archives - Configuration for archive artifacts. No dependencies
compile - Compile classpath for source set ‘main’. — project :library
— project :baseLibrary
default - Configuration for default artifacts. — project :library
— project :baseLibrary
— project :util
runtime - Runtime classpath for source set ‘main’. — project :library
— project :baseLibrary
— project :util
service — project :library
— project :baseLibrary
— project :util
testCompile - Compile classpath for source set ‘test’. — project :library
— project :baseLibrary
testRuntime - Runtime classpath for source set ‘test’. — project :library
— project :baseLibrary
— project :util
gradle :app:distZip also works - puts into jars(runtime and compile time)