Search code examples
gradleear

How to add APP-INF/classes to my EAR with Gradle


I am building an ear with Gradle. So far my configuration is very simple:

apply plugin: 'ear'

ear {
  libDirName 'APP-INF/lib'
}

dependencies {
    deploy project(path: ':MyProjectWeb', configuration: 'archives')

    earlib project(':ModuleA')
    earlib project(':ModuleB')
}

I also have :ModuleC, whose classes I'd like to place into APP-INF/classes, rather than copying ModuleC.jar into APP-INF/lib.

How can I do this with Gradle?


Solution

  • It will be similar to:

    ear {
      libDirName 'APP-INF/lib'
    
      from(project(':modc').sourceSets.main.output) {
          into('APP-INF/classes')
      }
    }
    

    Sample demo can be found here.