In my-webapp/build.gradle
First create new configuration, that will be used for dependency resolution.
configurations {
testWar
}
Then assign output of the war task to the testWar configuration.
artifacts {
testWar war
}
In integration-test/build.gradle
Create configuration and set dependency on the sibling project configuration
configurations {
testWar
}
dependencies {
testWar project(path: ":my-webapp", configuration: "testWar")
}
Let depend the task where you need the war file on the testWar configuration and use the configuration files as you need.
task prepareWebapp(type: Copy) {
dependsOn configurations.testWar
configurations.testWar.files.each { artifact ->
from artifact {
into "${buildDir}/tomcat/webapps"
}
}
}