EJB client gradle plugin

plugins

(Maksim Kostromin) #1

Hi folks,

I created plugin to to help me build client thin jar containing only needed interfaces in addition to regular (full) jar

class EjbClientExtension {
  String[] filters = [
      "**/api/*.*",
      "**/api/**/*.*",
  ]
}

class EjbClientPlugin implements Plugin<Project> {
  void apply(final Project project) {
    final EjbClientExtension extension = project.extensions.create("ejbClient", EjbClientExtension)
    project.afterEvaluate {
      project.apply(plugin: "java")
      final Task createEjbClientJarTask = project.task("createEjbClientJar", type: Jar) { task ->
        task.classifier = "client"
        task.from project.sourceSets.main.output

        extension.filters.each {
          task.include it
        }
      }
      project.jar.dependsOn(createEjbClientJarTask)
    }
  }
}

apply plugin: EjbClientPlugin

it works fine, but unfortunately it’s not configurable as I expected. What I want is to have possibility to override package need to be included using ejbClient extension, like so:

apply plugin: EjbClientPlugin

ejbClient.filters = [
    "**/remote/**/*.*",
    "**/local/**/*.*",
]

but as result I still have -client.jar with /api/ filter, not from ejbClient extension
How can I fix that?
Thanks in advice


Regards,
Maksim