I am writing a custom plugin for Gradle. I want to be able to:
serviceDependencies { service name: 'service1', version: '1.0' service name: 'service2', version: '1.1' }
In my plugin implementation (in Java), I have:
public void apply(final Project project) { project.getExtensions().create("serviceDependencies", Services.class); project.getExtensions().create("service", Service.class); }
And Service.java:
public class Service { private String name; private String version; public Service(final String name, final String version) { this.name = name; this.version = version; } public String getName() { return this.name; } public void setName(final String name) { this.name = name; } public String getVersion() { return this.version; } public void setVersion(final String version) { this.version = version; } }
When I try to use this plugin, I get:
java.lang.IllegalArgumentException: Could not find any public constructor for class com.xxx.xxx.Service_Decorated which accepts parameters [].
This happens when I remove serviceDependencies / Services.java from the picture.
If I remove the service constructor or delete the arguments.
org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method service() for arguments [{name=service1, version=1.0}] on root project ...
Obviously, my pojo is styled, but not quite with the right constructor. How can I make the constructor work as I want in my build.gradle script?
The second and independent question is what does Service.java look like?