Using a custom groovy plugin in a multi-project build


(heidi m) #1

Hi,

I’m using Gradle 1.5 and I’ve created a custom plugin implemented using groovy. I’m trying to use the custom plugin in the same project that contains its source. i.e. the buildSrc folder containing the custom plugin source is in the same project as the gradle script trying to use it.

Initially the gradle script using the custom plugin was a stand-alone project, but I now need to make it one of many projects in a multi-project build. It’s functionality is unchanged, I just want it to be controlled by the parent gradle script.

The gradle script with the custom plugin works fine when its run stand-alone, but I get a NoClassDefFound exception on my.plugin.GreetingPlugin when I include it as part of the multi-project build.

The contents of the script is:

apply plugin: my.plugin.GreetingPlugin
  greeting.message = 'Hi from Gradle'
greeting.myFile = "$buildDir/someBuildFile.txt"

What do I need to add to make my custom plugin visible in a multi-project build?

Thx, Heidi


(Peter Niederwieser) #2

You don’t have to do anything special. Note that there is only one ‘buildSrc’ directory per build, namely ‘$rootDir/buildSrc’.