I'm looking at porting a maven build to gradle. One feature of maven is pom inheritance whereby I can declare a variety of common behaviour in a pom, publish that to a repository and then use that via the <parent>
element in a concrete project.
My Q is simply whether there is an equivalent behaviour in gradle?
I've previously done this in ant+ivy by importing a common build.xml which relied on either having already checked out the location of the common build.xml from source control or using something like svn:externals. I can repeat this approach without any real difficulty but this seems to be one thing maven does quite nicely so it would be nice to see something similar in gradle.
My current solution is option 3; package the common scripts into a jar as resources and then unjar during the buildscript section like so
buildscript {
repositories {
// enterprise repo here
}
dependencies {
classpath 'com.foo.bar:common-build:0.1.0-SNAPSHOT'
}
dependencies {
ant.unjar src: configurations.classpath.singleFile, dest: 'build/gradle'
}
}
apply from: 'build/gradle/common.gradle'
This seems to do what I want.