Hi,
Using Gradle 4.7.
I have some build code that can benefit from being a plugin. I created a plugin project and try to use it with the other subprojects.
Can anyone share an example project were this setup works?
Seemed that all old examples don’t work.
Thanks,
Gadi.
staffanf
(Staffan Forsell)
May 17, 2018, 7:02am
2
Place it in buildSrc, then it will be available to the rest of the build.
https://guides.gradle.org/writing-gradle-plugins/ along with https://docs.gradle.org/4.7/userguide/java_gradle_plugin.html covers the basic of getting started.
In the gradle-all.zip you can find samples/multiProjectBuildSrc
which has a simple working example too.
thanks @staffanf
I cannot make this to work:
When I apply the plugin it tell me it is not found.
'plugin with id xxx not found
I tried with full name or just plugin name.
I have a properties file with the plugin class
my plugin is java (not groovey)
my projects organised in multi level nested folder structure
any java plugin example?
Thanks
staffanf
(Staffan Forsell)
May 17, 2018, 8:47am
4
Create a minimal viable example of what does not work and post it here or on github.
Then we can help you get it started.
staffanf
(Staffan Forsell)
May 17, 2018, 11:30am
6
Here’s a patch for a fixed version:
https://pastebin.com/guTtmEU4
The main problem was that I don’t think you can have subprojects in buildSrc
thanks @staffanf , can you submit a pull request?
Can you seperate plugins with different properties files in the same buildSrc directory?
Thanks.
staffanf
(Staffan Forsell)
May 17, 2018, 2:20pm
8
Yes, just use more blocks in the dsl like:
gradlePlugin {
plugins {
integrationPlugin {
id = 'com.rds.example.gradle.integration-plugin'
implementationClass = 'com.rds.example.gradle.IntegrationPlugin'
}
pluginB {
id = 'another.id'
implementationClass = 'some.other.PluginClass'
}
}
}
1 Like
jjustinic
(James Justinic)
May 17, 2018, 2:20pm
9
There’s also nothing wrong with buildSrc
being a multi-project build. However, the root project must have a runtime
dependency on the subprojects you want to include (see Organizing Build Logic - Build Sources ).
There’s no problem including all subprojects in one go, if that’s what you want:
buildSrc/build.gradle
dependencies {
runtime subprojects
}
https://docs.gradle.org/current/userguide/organizing_build_logic.html#sec:build_sources
1 Like
awesome! thanks @jjustinic
thanks @staffanf , cool, this is what I thought.