Can the ear plugin create multiple ears with different earlib results?


#1

I have a project that needs to build two different EARs. Since the plugin only handles one ‘earlib’ configuration, how can I adjust the earlib for each EAR task? I have a set of common libs for both ears, and then for one of the EARs I need to add an additional set of dependencies.

I tried the following:

task myEar (type: Ear) {
   from {
      configurations.earlibExtra
      into 'lib/'
   }
 }

The problem is that I get circular dependency errors. Other methods work, but the dependencies go into the EAR root and not ‘/lib’. Can this be solved without splitting the project?


(Peter Niederwieser) #2

Above syntax is incorrect. Try:

task myEar(type: Ear) {
    from(configurations.earlibExtra) {
              into 'lib'
    }
 }

Or, leveraging the ‘Ear’ task’s ‘lib’ method:

task myEar(type: Ear) {
    lib {
        from configurations.earlibExtra
    }
}

PS: I prefer into-from over from-into, because it better reflects the target structure. Semantics stay the same.

task myEar(type: Ear) {
    into('lib') {
              from configurations.earlibExtra
    }
 }

#3

OK, those all worked. I think I was not testing the correct task before, because I’m pretty sure I tried at least one of those combinations. Thank you!