This is how you could do it.
In your ‘init.gradle’:
class OurPlugins {
def buildscript
OurPlugins(buildscript) {
this.buildscript = buildscript
buildscript.repositories {
mavenCentral()
}
}
void jsPlugin(String version) {
buildscript.dependencies {
classpath "com.eriwen:gradle-js-plugin:$version"
}
}
}
allprojects {
extensions.create('ourPlugins', OurPlugins, buildscript)
}
Then in your ‘build.gradle’ (assuming you want to apply the plugin to all children):
buildscript {
allprojects {
ourPlugins.jsPlugin "1.0"
}
}
allprojects {
apply plugin: "js"
}
The application has to be outside of the ‘buildscript’ block right now, and outside of the init script because of GRADLE-2407. When that is fixed, you could make it a little more concise.