Help in generating customized War

Experts,

I am new to Gradle.
I have a multi module project with Gradle. The structure can be illustrated as

A
src
----- build.gradle
B
src
— main
—webapp
— myjars
— test.jnlp

------ build.gradle
build.gradle

My goal is to include the generated jar out of module A into ‘myjars’ folder of module ‘B’ during the ‘war’ construction.

Tried the following with no luck as this is getting executed before the jar creation of ‘A’

war {
from(’…/A/build/libs’) {
include '*.jar’
into ‘myJars’
}
}

Any advise?

Currently you are using the relative file path to where the built jar will end up.

from('../A/build/libs')

Instead you can reference jar on project A:

from(project(':A').jar)

Referencing it in this way causes the output of the jar task to be used and also creates a task dependency so that the jar file built in module A will be built before trying to include it in the war.