Applying plugin dependencies from external gradle file


(Jesper Thuun-Petersen) #1

I’m trying to externalize the configuration and dependencies of a set of plugins we use on our project. I’ve created a boilerplate gradle file setting up a buildscript block with repository definition and plugin versions.

buildscript {
 repositories {
  mavenRepo url: "http://nexus.stibo.dk/content/groups/public/"
 }
   dependencies {
  classpath(group: 'com.stibo', name: 'com.stibo.gradle.plugin.stibodefaults', version: '1.3.0')
                // and more plugins..
 }
}
  apply plugin: com.stibo.gradle.plugin.stibodefaults.StiboDefaults
// and more applications...

In each of our modules, I want to apply these common settings by applying the boilerplate gradle file:

apply from:'http://buildstrap.stibo.dk/boilerplate/boilerplate-1.0.0.gradle'

I get an error: No such property: com for class: org.gradle.api.internal.initialization.DefaultScriptHandler

I’ve been searching this forum for hints, and I’ve found a couple of relevant postings:

The common line here is that it can’t be (easily) done.

The newest post on the issue is much more positive, as it suggests that it does indeed work.

Do you have an up to date answer, reflecting the possibilities with the newest version of gradle?

Regards /Jesper


(Peter Niederwieser) #2

I’m not aware of any recent changes. The topic you refer to is about something else.

Usually, the easiest solution is to put the ‘buildscript’ block into the root ‘build.gradle’. From what I remember, this doesn’t cut it for build scripts applied with ‘apply from:’ though, and you’ll have to repeat the ‘buildscript’ block there (if you need the dependencies).

If this isn’t good enough, consider creating a custom Gradle distribution, whose ‘init.gradle’ can bring in build script dependencies automatically.


(Tye Howard) #3

Is your plugin jar set up like the following:

In the plugin jar, in the META-INF/gradle-plugins/StiboDefaults.properties file

implementation-class=com.stibo.gradle.plugin.stibodefaults.StiboDefaults

The cases where I’ve seen this sort of behavior, it’s been because I messed up typing the package name.