简体   繁体   English

您将在Java中使用什么部署脚本?

[英]What would you use for deployment scripts in Java?

I'm working on a Java web project that uses Maven to build its artifacts. 我正在研究一个使用Maven构建其工件的Java Web项目。 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. 在Maven构建结束时,我们需要将一些jar和war文件部署到我们的开发/测试环境中。

Right now we're using a pretty hefty Ant script that performs several tasks (on both Windows/Linux machines) 现在我们正在使用一个非常庞大的Ant脚本来执行多个任务(在Windows / Linux机器上)

  • 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. Ant可以很好地完成工作 - 但是脚本很快变得非常大,而且说实话,它对于手头的任务感觉不够。

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. 编辑:经过更多的研究,我发现了Gradle - 它似乎是重用ant任务和允许真正的脚本运行的非常好的组合。 It's worth a read. 值得一读。

Yes, take a look at the Cargo plugin for maven: 是的,看看maven的Cargo插件:

 * 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. Hudson - 一个持续集成引擎 - 也可用于实现这些任务。

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. 一般来说部署并不容易(通常非常具体),而Cargo maven插件可能有助于远程部署war / ear(如果实现了app服务器的远程部署),我认为它不会覆盖你的所有需要。 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: 看看像这样的解决方案:

如果这是一项大任务,你总是可以用Java或Jython编写ant任务并从ant调用它们。

This seems to be an open issue in 2017, too. 这似乎也是2017年的一个悬而未决的问题。 Searching for "java deploy script" points first to this question, and also to Ant and a few other unrelated articles. 搜索“java deploy script”首先指向这个问题,也指向Ant和其他一些不相关的文章。

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/. 我在撰写本文时正在研究的项目有6-7个JAR文件,我们放在tomcat的lib /文件夹中,还有20-30个小的WAR文件放在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. 我们有一个部署脚本,可以从Bamboo服务器下载并扩展包含所有内容的存档,但在开发期间不可用。 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. 所以我创建了自己的Python脚本,最初会将几个JAR和WARS部署到tomcat实例。

Now it's a cross-platform deployment tool (tested on Windows and Mac), and language and server agnostic, configurable via a JSON file. 现在它是一个跨平台的部署工具(在Windows和Mac上测试),语言和服务器无关,可通过JSON文件进行配置。 It can: 它可以:

  • Copy and delete libs and apps 复制和删除库和应用程序

  • Run local and remote (via SSH) commands 运行本地和远程(通过SSH)命令

  • 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.). 由于您可以在远程服务器上运行命令,因此可以通过Shell命令执行很多操作(我们使用它们来启动/停止tomcat,等待它启动/停止,删除日志等)。

The deployment script is on GitHub . 部署脚本位于GitHub上

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 构建一个大型Java应用程序,您将使用什么堆栈? - building a high scale java app, what stack would you use? 您将使用哪些Java框架与Google App Engine合作? - What Java framework would you use with Google App Engine? appfuse vs roo - 你会用什么? - appfuse vs roo - what would you use 你会在App Engine中使用什么“未来”? - What would you use a “Future” for in App Engine? 直接Java / Groovy与ETL工具(Talend / etc) - 您将使用哪些库? - Straight Java/Groovy versus ETL tool (Talend/etc) - what libraries would you use? 最佳的数据结构是什么? java的 - What would be the best data structure to use? java 为什么你会在java中使用BitSet而不是布尔数组(在Java中)? - Why would you use a BitSet in java as opposed to an array of booleans (in Java)? 您会选择在Java应用程序中运行HTML / Javascript - What would you choose to run HTML/Javascript inside Java application 你在MySQL / Hibernate中映射BigDecimal的类型是什么类型的? - What type would you map BigDecimal in Java/Hibernate in MySQL? Web服务通知-您会推荐哪种Java实现? - Webservice Notification - what java implementation would you recommend?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM