Here is the build.gradle file
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'ear'
def binDir = file("bin")
def libDir = "WebContent/WEB-INF/lib"
def testReportDir = file('testReport')
def outputDir = file("output")
def envParam = "local"
sourceSets {
project.webAppDirName = 'WebContent'
main {
java { srcDirs = ['src/main/java'] }
resources { srcDirs = ['src/main/resources'] }
output.classesDir = binDir
}
test {
java { srcDirs = ['src/test/java', 'src/main/java'] }
resources { srcDirs = ['src/test/resources'] }
output.classesDir = binDir
compileClasspath = sourceSets.main.compileClasspath
runtimeClasspath = output + compileClasspath
}
}
dependencies {
compile fileTree(dir: libDir, include: ['*.jar'])
testCompile 'junit:junit:4.12'
}
task cleanDirs(type: Delete) {
//clean tasks
}
war {
dependsOn cleanDirs
destinationDir(binDir)
}
ear {
dependsOn war
appDirName '../XYZApplicationEAR/META-INF'
destinationDir(outputDir)
deploymentDescriptor {
displayName = "XYZApplicationEAR"
webModule("XYZApplication.war", "xyzapp")
}
}
Everything is fine but the issue is, inside the generated war file… under WEB-INF/classes, the compiled classes are missing. The only present items are the properties files from the resources(src/main/resources) package.
Anyone can help us on this? thanks
Project Format below
XYZApplication
>>src
>>WebContent
>>>>META-INF
>>>>WEB-INF
gradle.build (placed under XYZApplication)
gradle.properties (placed under XYZApplication)
XYZApplicationEAR
(the parent ear project that contains web nodule XYZApplication)
XYZApplication is the web module. XYZApplication is the ear module
This is version Gradle 3.1