Include war in ear

(Techno_Guy) #1


I have two gradle projects

— The gradle build script in ProjectA creates war and ear file, say ProjA.ear and ProjA.war respectively. the ear file just contains the war.
snippet of build.gradle

apply plugin: ‘war’

  • dependencies {*
  •                  compile project(':AnotheProject')*
  •                 }*
  • war {*
  •      archiveName = 'ProjA.war'*
  •    }*


apply plugin: ‘ear’

  • dependencies {*

  • earlib project (’:AnotheProj’)*

  • }*

  • ear {*

  • includeEmptyDirs = false*

  • from war.archivePath*

  • archiveName = ‘ProjA.ear’*

  • deploymentDescriptor {*

  • applicationName = ‘ProjA’*

  • initializeInOrder = true*

  • displayName = ‘ProjA’*

  • webModule(‘ProjA.war’,‘ProjAWeb’) *

  • }*

  • } *
    ear.dependsOn war

— The gradle script should create a ear, say* ProjB.ear* which should contain the war file from ProjectA, ProjA.war

I am using ear plugin in Project B, in dependencies I add the below line

  • deploy project(path:’:ProjectA’, configuration:‘archives’)*
    When I run gradle on project B the * ProjB.ear* created with * ProjA.ear*, but I want ProjA.war to be included in ProjB.ear.

Could anyone has any idea on this??

I am new to gradle and will appreciate your help…


I think this approach is broken or still incubating so I suggest you workaround.

Define everything as normal and make ear {} to depend on ...war:build. Rock solid. For EAR use either deploy if you war want to place artifact in root or earlib if you want to be placed under /lib.

(Techno_Guy) #3

hi kris, thanks for your reply. but i did use deploy (from ProjectB) to place the war (ProjA.war) in root of PojB.ear but the deploy command placed the ear (ProjA.ear) file instead the war

(SureshPandiyan) #4


I am new to gradle build, I want to add war file to inside ear, could you please help me on that?
below my build script:

apply plugin: 'war’
apply plugin: 'ear’
title = "wam-lnAccess"
team = WAM
jarName = "lnAccess.war"
srcDir = "src/lnaccess"
libDir = "src/WamCommon/lib"
javaDir = “src/lnaccess/src”

from ‘src/lnaccess/WebContent’ // adds a file-set to the root of the archive
from(‘src/lnaccess/src’) {
include "/*.properties"
include "
into “WEB-INF/classes”