Ant 任务与 Shell 脚本 [英] Ant task vs Shell script

查看:35
本文介绍了Ant 任务与 Shell 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的办公室看到很多地方使用 ant tasks 将文件从一个地方移动到另一个地方,并对这些文件执行一些任务.然而,所有这些都可以用 shell 脚本.

I see a lot of places in my office where ant tasks are used to move files from one place to another and also do some tasks on these files.However all this can be done with shell scripts.

我的问题是,

在什么情况下 antshell 脚本 更受欢迎?

In what cases is ant preferred over shell scripts ?

使用 ant 而不是 shell 脚本 来完成相同的任务有什么好处.

What are the benefits of using ant over a shell scripts for doing same set of tasks.

ant 的一个优势是它适用于所有平台,除此之外还有任何与 性能 相关的优势吗?

One advantage ant has is that it works on all platforms,other than that are there any performance related advantages ?

推荐答案

关于为什么 ANT 应该比 shell 脚本更受欢迎的问题有两个:

Your question as to why ANT should be preferred to shell scripts is two-fold:

  1. ANT 是一种已被广泛采用的工具,很可能已经安装在开发人员的工作站上.比起一个在它的主要前身 make 中,ANT 更加标准化并且跨平台.
  2. ANT 是开发人员熟悉的工具.用于构建他们的代码,因此他们通常会扩展 ANT 脚本以将他们的应用程序部署为好.事实上,许多供应商为此提供了 ANT 任务.

真的没有性能优势.Java 命令行使用速度很慢.

There are no performance benefits, really. Java is slow for command-line usage.

但是..... 我建议不要打性能"牌.让我们假设您的应用程序不支持 windows(考虑到 Java 应用程序应该支持所有平台,这很奇怪......):我已经看到 shell 脚本驱动的部署陷入混乱,试图协调不同的 unix 操作系统命令的各种工作方式.tar"、awk"等命令可能略有不同,这会导致脚本中出现额外的平台支持逻辑.

But..... I would advise against playing the "performance" card. Let's pretend that your application does not support windows (Which is odd considering a Java application should support all plaforms...): I have seen shell script driven deployments decend into chaos attempting to reconcile the various ways different unix operating system commands work. Commands like "tar", "awk", etc can be subtly different which leads to additional platform support logic in your script.

总而言之,我不会使用它们.我选择使用 groovy 进行通用脚本编写的混合方法.它是一种基于 Java 的脚本语言,并嵌入了 ANT 的全部功能.作为一种基于 Java 的脚本语言意味着它可以在所有平台上运行.为了公平起见,还应注意还有其他语言选项.Ruby 当然值得一提,因为它产生了一组非常值得评估的配置管理技术.(参见 Chef木偶)

In conclusion I would use neither. I choose a hybrid approach of using groovy for general scripting. It is a java based scripting language and embeds the full power of ANT. Being a java based scripting language means it will work on all platforms. In the interest of fairness it should also be noted that there are other language options. Ruby is certainly worthy of mention since it has spawned a set of configuration management technologies that are well worth evaluation. (See Chef and Puppet)

这篇关于Ant 任务与 Shell 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆