I'm adding a task to deploy war files to Tomcat .. the only thing that the task needs to do is copy the war file to the TOMCAT location.
There 2 ways that I can think of implementing this .. but being new to gradle, I'm not quite sure what's more conventional/right (or if it even matters).
task myCopy(type: Copy) myCopy.configure { from('source') into('target') include('*.war') }
or
task myCopy{ doLast{ copy { from 'source' into 'target' include '*.war' } } }
Gradle supports two types of task. One such type is the simple task, where you define the task with an action closure. We have seen these in Build Script Basics. For this type of task, the action closure determines the behaviour of the task. This type of task is good for implementing one-off tasks in your build script.
A FileTree represents a hierarchy of files. It extends FileCollection to add hierarchy query and manipulation methods. You typically use a FileTree to represent files to copy or the contents of an archive. You can obtain a FileTree instance using Project.
gradle file is located in each module of the android project. This file includes your package name as applicationID , version name(apk version), version code, minimum and target sdk for a specific application module.
In most cases (including this one), the Copy
task is the better choice. Among other things, it will give you automatic up-to-date checking. The copy
method is meant for situations where (for some reason) you have to bolt on to an existing task and cannot use a separate task for copying.
The code for your Copy
task can be simplified to:
task myCopy(type: Copy) { from('source') into('target') include('*.war') }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With