Question about adding war archive to ear archive

(pavankumar.ovs) #1

Hi Nikolay/Rene,

I have a question in creating ear file. I have a requirement to add the war file under ear file and few other folder/files along with it.
I verified few articles, posting and Gradle guide which says to add the below command under dependencies

deploy project(path: ‘:war’, configuration: ‘archives’)

But when I try this then I am getting an exception. Could you please guide me on how to add war file under ear.

Pavan Note: This topic was created from a reply on the Ear build with specific appDirName path topic.

(René Groeschke) #2

What exception do you get?

(pavankumar.ovs) #3

Hi Rene,

Thanks for your response. Below is the exception which I am getting

C:\workspace-cord\ERIM>gradle build

FAILURE: Build failed with an exception.

  • Where: Build file ‘C:\workspace-cord\ERIM\build.gradle’ line: 8

  • What went wrong: A problem occurred evaluating root project ‘ERIM’. > Project with path ‘:war’ could not be found in root project ‘ERIM’.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


Total time: 7.186 secs

Thanks Pavan

(René Groeschke) #4

Hi Pavan

in the snippet

deploy project(path: ':war', configuration: 'archives')

‘:war’ is referencing your war project. It seems that your war project has a different name. you must replace ‘:war’ with the correct project path.

(pavankumar.ovs) #5

Hi Rene,

Thanks for the reply. Sorry that I was out of station so responding late. Here is the code snippet which I am using. Please advice.

apply plugin: ‘java’ apply plugin: ‘war’ apply plugin: ‘eclipse’ apply plugin: ‘ear’

dependencies {

compile fileTree(dir: ‘WebRoot/WEB-INF/lib’, includes:[’*.jar’])

deploy project(path: “:erim”, configuration: “archives”)


war {


include ‘*.xml’

into (‘WEB-INF/’)


into (‘WEB-INF/jsp’){

from ‘WebRoot/WEB-INF/jsp’


into (‘WEB-INF/tags’){

from ‘WebRoot/WEB-INF/tags’


into (‘javaScript’){

from ‘WebRoot/javaScript’


into (‘images’){

from ‘WebRoot/images’


into (‘css’){

from ‘WebRoot/css’



include ‘.

into (’’)


exclude(“WEB-INF/lib/classes12.jar”) }

sourceSets {


java {

srcDir ‘src’


} }

ear {

deploymentDescriptor {

webModule(project(":erim").war.archiveName, “customContextPath”)

} }


Thanks Pavan