Variable declaration in build.gradle file like Eg: repositories,dependencies


(kiranduggirala) #1

Hi! I have written a plugin to compile my rmic classes in grrovy.

I want to define my rmicClasses variable something like repositories or dependencies in my build.gradle file. can anybody help me on that.

i want to define something like this in my build.gradle build.gradle: rmic {

abc.dd.class1

abc.dd.class2

}

Please help me

Regards, kiran


(Andrew Oberstar) #2

One thing you could try is the new extension mechanism. If you aren’t passing in too many classes it might be easier to use a method syntax, rather than a closure syntax.

extensions.rmic = new RmicExtension()
  rmic.classes 'abc.dd.class1', 'abc.dd.class2'
  class RmicExtension {
 List classes = []
   void classes(String... classes) {
  this.classes.addAll(classes)
 }
}