Unable to add war file to uberJar using gradle

gradle-3297
gradle-2698

(Doraiswamy) #1

I am trying to create uberJar which comprises jars, war. When the uberJar is created, I don’t see war file from Module3. I see Module3.jar added to /lib. Is there a way to get Module3.war file to lib?

RootProject
|
|
|------------ Module1 (Builds jar file)
|
|------------ Module2 (Builds jar file)
|
|
|------------ Module3 (War file - WEB-INF/lib contains jar file from Module 1 & 2, Jsps, META-INF, etc)
|
|
|------------ Module4 (UberJar - Jar of Jars, War)

Module4 - build.gradle is given below:

dependencies {
  compile(project(':Module1')) {
    transitive = false
  }
  compile (project(':Module2')) {
    transitive = false
  }

  compile (project(':Module3')) {  // which is war
    transitive = false
  }

}

task copyDeps(type: Copy) {
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
    from(configurations.compile)
    into buildDir.path + '/lib'
}

task uberJar(type: Jar, dependsOn: [copyDeps]) { 
  into('lib') {
    from {
      configurations.runtime.collect {
        it.isDirectory() ? it : it.getAbsoluteFile()
      }
    }
  }
  into('META-INF') {
    from("./META-INF") {
      include '**/*'
    }
  }
}

When uberJar is created, I get Module3.jar and not Module3.war file.

How can I include Module3.war instead of Module3.jar in the uberJar?

Thanks a lot.