Using war copySpec for ant.copy task


(Rudi Adianto) #1

I found out that when doing exploded war construction for development purpose, doing ant.copy is a lot faster than using copy { into ‘dir’; with war }.
The problem with gradle copy is that it isnt really doing the copy incrementally (while the task itself have up-to-date checking); at least that is what I understand from here https://github.com/gradle/gradle/issues/1643 .
On the other hand, Ant’s Copy task only copy ‘newer’ file.

The question: is there an easy way to reuse war copySpec to ant.copy() ?


(uklance) #2

I think you want Sync rather than Copy


(Rudi Adianto) #3

I tried both Copy and Sync.
Both are painfully slow; at least in Windows 10 needing to copy/sync thousand of small files.
Ant’s copy is a lot faster since it has timestamp checking; only newer files are being copied.
As far as I know this method of copying is not yet supported in Gradle.


(uklance) #4

You could likely implement this via eachFile { … } and FileCopyDetails.exclude()


(Rudi Adianto) #5

Sounds like a good idea; I assume this way I can do the timestamp checking myself and manually copy where applicable.
Will try this out.


(uklance) #6

Sort of…

You’d be adding an extra action to a Copy task which would FileCopyDetails.exclude() any files that don’t pass your timestamp check

No manual copy

See the javadoc

Adds an action to be applied to each file as it is about to be copied into its destination. The action can change the destination path of the file, filter the contents of the file, or exclude the file from the result entirely. Actions are executed in the order added, and are inherited from the parent spec.