Search code examples
gradleeargradle-plugin

How can I create an instance of a EarPluginConvention for my Gradle Plugin?


I am trying to create an instance of the Ear Plugin Convention , but the documentation is vague. I am currently constructing the object as

EarPluginConvention epc = new EarPluginConvention(task.getServices().get(FileResolver.class),task.getProject().getObjects()); 

, but all the properties on this object are null. Is there an other way to get an instance of a FileResolver?

https://docs.gradle.org/current/javadoc/org/gradle/plugins/ear/EarPluginConvention.html


Solution

  • If you create a new instance of this class it will always be empty anyway, so what's the sense?

    I guess you are more after something like

    project.getConvention().getPlugin(EarPluginConvention.class).getAppDirName()
    

    which gets the one that the ear plugin created, configured and added to the project and that maybe was reconfigured by the build script