The Goal: build the war and upload it into Tomcat's "webapps" directory. Should be simple. Thankfuly it is, using int128's Gradle SSH Plugin, a wrapper around JSch.
- After the gradle war task has executed the path the new war is war.archivePath.absolutePath (usually in "build/libs").
- If your deploying to Amazon EC2, (and who isn't?) you'll need to disable StrictHostKeyChecking.
- Don't upload the war with a .war extension. Tomcat will attempt to start it before it's done copying, fail, and you will have to restart tomcat or screw around in the admin console.
- Once it's finished uploading, and the old war is removed, then you can rename to .war.
Feel free to post your favorite Tomcat deploy edge cases in the comments!
Example tested with Tomcat 7 and Gradle 1.5.