I am working on a standalone RuleSource plugin within which I would like to generate tasks that issue REST requests using tasks implemented by this REST plugin.
Is this possible?
To apply this REST plugin and make it a dependency of the RuleSource plugin, how do I do it? I don’t see a way to define a Mutate or other type of method to get it done.
Not even sure really where to start - can’t seem to find any documentation on this.
The way I have done this is by implementing Plugin and then using a static nested class with the Rules. I see it done the same way in the Gradle source code in multiple places as well.
public class MyPlugin implements Plugin<Project> {
@Override
public void apply(Project project) {
project.getPluginManager().apply('myOtherPlugin');
}
public static class Rules extends RuleSource {
// rules here
}
}
I believe that buildscript should resolve correctly because Gradle will also resolve the transitive dependencies of the selected artifact (if I understand what you are asking).
…I’d prefer that someone applying my plugin wouldn’t have to know that they need to add a buildscript block for what would appear to them to be an unrelated plugin that they themselves are not directly applying to their build script.
…I get this error when trying to apply MyPlugin to the ultimate build script:
* What went wrong:
A problem occurred evaluating root project 'MyProject'.
> Failed to apply plugin [class 'com.myCompany.gradle.plugins.MyPlugin']
> Plugin with id 'org.tenne.rest' not found.
So, I need to effectively take the repo and classpath config that would normally be found in the buildscript block for applying a plugin, and translate those into runtime dependencies in the build.gradle file for my standalone project, like so: