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.
5 comments:
What is the local war file name that is being uploaded? ROOT.war?
Where is the source file name referenced?
This fails when executed. Can you post something that works?
Jay: The local file is usually built by gradle to build/libs/[projectname]-[version].war
It did not fail for me, within a valid gradle war project. Can you be more specific about the failure you got?
Also, what version of gradle are you using, as stated above this was tested with 1.5. You also would need to put host and username with a password or identity file in the remotes area (starting line 18)
Works great for me!
Thank you.
Post a Comment