I'm working on a Java web project that uses Maven to build its artifacts. At the end of the Maven build we have a few jar and war files that we need to deploy onto our development/testing environment.
Right now we're using a pretty hefty Ant script that performs several tasks (on both开发者_JAVA技巧 Windows/Linux machines)
- Starts/Stops services
- Copies/deletes files
- Builds some stuff and then executes it
- Etc
Ant does the job well - but the script is quickly getting very large, and to be honest, it feels inadequate for the task at hand.
Are there other alternatives? I've heard of gant, but I'm not sure that's the right way to go.
Thanks for helping!
EDIT: after more research, I found out about Gradle - it seems like a very good combination of reusing ant tasks and allowing real scripts to run. It's worth a read.
Yes, take a look at the Cargo plugin for maven:
* Deploying to a running container * Generating a container configuration deployment structure * Merging WAR files * Starting and stopping a container
Hudson - a continuous integration engine - can be used to achieve these tasks as well.
Deployment in general is not easy (and often very specific) and while the Cargo maven plugin may help for the remote deployment of war/ear (if remote deployment for your app server is implemented), I don't think it will cover all your needs. Actually, it's hard to be very precise as the question is vague so I'll just give some pointers. Have a look at solutions like:
- Chef
- SmartFrog
- ControlTier
If it's a large task, you could always write ant tasks in Java or Jython and call them from ant.
This seems to be an open issue in 2017, too. Searching for "java deploy script" points first to this question, and also to Ant and a few other unrelated articles.
The project I'm working on at the time of this writing, has 6-7 JAR files which we place in tomcat's lib/ folder, and 20-30 small WAR files that we place in webapps/. We do have a deployment script that downloads from a Bamboo server and expands an archive that contains everything, but that's not usable during development. And deploying all these manually is a nightmare.
So I started my own Python script that initially would deploy several JARs and WARS to a tomcat instance.
Now it's a cross-platform deployment tool (tested on Windows and Mac), and language and server agnostic, configurable via a JSON file. It can:
Copy and delete libs and apps
Run local and remote (via SSH) commands
Make pauses
Since you can run commands on the remote server, you can do a lot of things via Shell commands (we use them to start/stop tomcat, wait for it to start/stop, delete logs, etc.).
The deployment script is on GitHub.
精彩评论