How do I get war task archive output (subproject.war)?

I am wondering how to get the war archive output. I have a project that one subproject builds a war file, and another subproject builds a distribution. The following code works (in a copy task):

into('folder') {
 from project(':myproject-jar').jar
}

But, when I am referencing a war project, the follwing does not work:

into('folder') {
 from project(':myproject-war').war
}

Any ideas on what I am missing here?

Thanks.

Problem solved. I figured out that I need to depend on the ‘myproject-war’ before. But it’s something weird here since I do not need to depend on ‘myproject-jar’ when I am doing the first approach.

Anyway, I am happy :slight_smile: Added the following code ontop of my distribution build:

dependsOn ':myproject-war'

Sounds like an evaluation order problem where the ‘war’ task hasn’t been defined yet when the ‘copy’ task gets evaluated.

‘Project.dependsOn’ may be a bit of overkill here. One alternative is ‘Project.evaluationDependsOn’. Another alternative is to defer the evaluation of ‘from’ with a closure:

into(‘folder’) {

from { project(’:myproject-war’).war }

}

Thanks. The defered evaluation trick was smooth :slight_smile: