What does project(':other-project').war return


(Marco Dubacher) #1

I saw code like the following below in which in the from part anothers project s"war"-element is referenced. Finally the files of the war file are copied into my-directory.

I would like to know the inner working of gradle as from expects a set of files and the “war”-element is a task. How does this work?

task zipArtifact(type: Zip) {

into(‘my-directory’) {

from project(’:other-project’).war

} }


(Peter Niederwieser) #2

‘Zip#from’ accepts different kinds of arguments. As documented under ‘Zip’ in the Gradle Build Language Reference, ‘from someTask’ is the same as ‘from someTask.outputs.files’.


(Marco Dubacher) #3

Thanks for your response.

In the documentation of Zip this feature is not mentioned (as far as I could read…).

I wonder where about in the gradle source code the from call is resolved as you mentioned. I checked the Zip-Class, AbstractCopyTask-Class etc. and couldn’t find anything.

Where does the Zip-Task write the zipped files so that it can be accessed later on via …outputs.files?

Thanks for any help (i am just curious… :slight_smile:


(Peter Niederwieser) #4

Go to docs for ‘Zip#from’, then follow the link to ‘Project#files’.


(Marco Dubacher) #5

Do you have any hints regarding my questions concerning the source?


(Peter Niederwieser) #6

I can’t tell offhand.


(Marco Dubacher) #7

… I mean how does it come that the output of a task can be accessed via output.files… I found the class TaskOutputs and annotations like @OutputFile or @OutputDirectory but I couldn’t find any of these in war, jar or zip task or classes they inherit from…


(Peter Niederwieser) #8

Not sure what exactly your question is, but the body of ‘AbstractTask#getOutputs’ indicates that there is some code generation involved to override the method at runtime. To say more I’d have to dig deeper myself.