Copy libs from ear file into my project

In my project, I’m creating a WAR file which is deployed to an OAM server. Oracle has an EAR file, which contains JAR files that I need to copy into my project. I’m placed the EAR file in our artifact repository. So, I want to do is get the EAR and uncompress it in a directory and copy the JAR files into the WAR file.

After researching online, I have made several attempts to copy the ear and uncompress it, but I cannot get it to copy and uncompress the file. This is what I have tried. Any help would be appreciated.

configurations {
earFiles
}
dependencies {
earFiles ‘oracle.security.oam.branding:oam-server:11.1.2.3.0@ear’
}
ext.unpackedEarFiles = fileTree("$buildDir/tmp/earFiles") {
builtBy 'unpackEarFiles’
println “FileTree…”
}
task unpackEarFiles(type: Copy) {
println "Copying…"
from configurations.earFiles.files.collect {
println "Extracting…"
println it
zipTree(it)
}
into unpackedEarFiles.dir
}

This is what I’m seeing in output.

FileTree…
Copying…
Extracting…
C:\Projects.gradle\caches\modules-2\files-2.1\oracle.security.oam.branding\oam-server\11.1.2.3.0\9587c08ec81f78bcb4ad8f2789c7c0df5e0adc1f\oam-server-11.1.2.3.0.ear

I figured it out. I had to add a dependsOn inside my war section. From there, I had to work with copying the JAR files from the tmp location into the war.