I have a simple plugin class in groovy in ROOT/buildSrc/src/main/groovy/org/example/Foo.groovy and a build file located at ROOT/sub1/test.gradle, which contains the following:
apply plugin: org.example.Foo
Now if I do a
$ ./gradlew -b test.gradle
in folder sub1, I get this error:
> Could not find property 'org' on project 'sub1'.
If I add an import statement at the top of test.gradle
I get a ClassNotFoundException. I also tried assigning a short name to my plugin (ROOT/buildSrc/src/main/ressources/META-INF/gradle-plugins/foo.properties) and using this in my
apply plugin: statement, but no success either.
What am I missing here? Is it possible at all to provide plugin code in a multi-project build? The same project has custom tasks located in_ ROOT/buildSrc_ and my sub project build files eat them without complaining…
EDIT: I verified file ROOT/buildSrc/build/libs/buildSrc.jar; it contains my plugin class files and my META-INF/gradle-plugins/ folder.
EDIT: Ok I have some progress here - if I do a
apply from: 'test.gradle' in file sub1/build.gradle it seems that my plugin is consumed. However, I would like to avoid having to tightly couple test.gradle to build.gradle. How can I achieve this?