Ant 仍然是 Java 构建工具的最佳选择吗?

发布于 2024-07-07 20:48:58 字数 1449 浏览 12 评论 0 原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

记忆消瘦 2024-07-14 20:48:58

Maven

它比 ant 好得多,因为对于大多数常见任务,您不必编写复杂的 build.xml ,maven 有很好的默认值,并且都是约定优于配置。

它还有一个大型的中央库存储库,并且很容易将其配置为“使用最新的稳定公共资源”。 然后,Maven 将为您下载最新的稳定版本(不再将 jar 文件签入 VCS),如果发布了新的上游稳定版本,它也会下载它。 当然,如果您需要的话,将其锁定到某个特定版本也同样容易。

它还与 Netbeans 和 Eclipse(m2eclipse 插件)很好地集成,因此 IDE 会遵循您在 pom.xml 文件中声明的任何设置(包括依赖项)。

maven 也有一些缺点:一些插件的文档记录相当少,与两个 IDE 的集成并不是很完美,并且以不同的方式,一些错误消息可能难以理解。

Maven

It is much better than ant because for most common tasks you don't have to write a complicated build.xml, maven has very good defaults and it's all convention over configuration.

It has also a big central repository of libraries and it's very easy to configure it to, like, "use latest stable commons-whatever". Maven will then download the latest stable version for you (no more checking in jars into VCS) and if a new upstream stable version is released, it will download it as well. Of course, it's just as easy to lock it to some specific version should you need that.

It is also well integrated both with Netbeans and Eclipse (m2eclipse plugin) so the IDE honors whatever settings (including dependencies) you declare in the pom.xml file.

There are also some downsides to maven: some plugins are rather poorly documented, integration with both IDEs is not really perfect, and that in different ways, some error messages may be hard to understand.

浅浅 2024-07-14 20:48:58

蚂蚁金服仍然是主要参与者。 根据我的经验,它占主导地位。 另外,通过 Ivy,它可以发挥 Maven 的一些优势。 在我看来,Ant 将成为其他工具的框架:XML 太僵化(请参见下面的链接)。

Maven 2 也是一个主要参与者。 我知道有些人非常喜欢它,并对 Maven 1 的批评感到愤怒(它已经取得了很大的进步)。

Groovy 在构建空间中提供了一些很酷的东西,因为它们是基于 Ant 构建的。 Gant 在 Grails 中使用,但也可以包含在 Gradle 中。 这些也可用于 Java。

冒着给我自己的博客拉皮条的风险, 这是一篇关于 Gant 和 Gradle 的帖子。 这是关于他们的未来的当前辩论的链接。

Ant is still a major player. In my experience, it is dominant. Plus, with Ivy, it handles some of Maven's strengths. IMO, Ant will become a framework for other tools: XML is too rigid (see link below).

Maven 2 is also a major player. I know people who quite like it and bristle at criticisms that were true for Maven 1 (it has come a long way).

Groovy is offering some cool stuff in the build space, because they build on Ant. Gant is used in Grails, but may be subsumed into Gradle. These can be used for Java as well.

At the risk of pimping my own blog, here is a post about Gant and Gradle. Here is a link to the very current debate about their future.

灼疼热情 2024-07-14 20:48:58

在企业领域,蚂蚁金服仍然是老牌玩家。 依赖关系不会快速变化。 与不断转向最新版本的依赖 jar 的开源项目不同,大多数企业都尽量不要太快地更改其依赖项。 由此看来,maven 相比 ant 的优势并不算太多。

再说一次,如果你想要一些 Maven 的功能,ant 人有 ivy (http://ant.apache.org /ivy/) 用于依赖项功能。

如果您想继续使用 ant,请获取《ANT IN ACTION》第二版,以便您可以使用 ant 发挥最佳生产力。

祝你好运,

in the enterprise, ant is still the entrenches player. dependencies don't change fast. unlike open source projects that keep moving to fairly newest version of dependent jars, MOST enterprises try NOT to change their dependencies too fast. Given that, maven's advantages are NOT too much compared to ant.

Then again, if you want some of maven's features, ant folks have ivy (http://ant.apache.org/ivy/) for the dependencies feature.

IF you want to continue using ant, get hold of "ANT IN ACTION", 2nd edition so that you can use ant to the best productivity.

Good luck,

九八野马 2024-07-14 20:48:58

有些人喜欢 Ivy,它是 Ant 的依赖管理工具,所以我想人们来自蚂蚁背景会喜欢的。

其他类似 Builder。 这是 JRuby 的事情,所以如果您可以在同一个项目中同时使用 Ruby 和 Java,那么我想这会很有趣。

就我个人而言,我只使用 Maven。 可以轻松创建默认的 pom.xml 文件并使用所有构建命令。 当项目增长时,您已经拥有用于运行插件和添加依赖项的基础设施。

Some people like Ivy, which is a dependency managing thingy for Ant so I suppose that people coming from an Ant background will like it.

Others like Buildr. It's a JRuby thing, so if you can juggle Ruby and Java in the same projects, then I suppose it'll be interesting.

Personally, I just use Maven. It's easy to whip up a default pom.xml file and have all the build commands at your disposal. And when the project grows, you already have the infrastructure in place for running plugins and adding dependencies.

夜深人未静 2024-07-14 20:48:58

您还拥有 Gant。 Gant 是 Groovy + Ant,您可以用普通的 groovy 编写任务,也可以调用任何 ant 任务。 如果您是 Java 商店,想要重用您拥有的 ant 技能,但不喜欢 XML,我推荐 Gant,它非常容易设置,您可以将其嵌入到 ant 中(也可以从 ant 调用 gant)。

You also have Gant. Gant is Groovy + Ant, you can write your tasks in plain groovy and you can also call any ant task. If you are a Java shop and want to reuse the ant skills you have but dislike XML, I recommend Gant, it is ver easy to setup and you can embed it in ant (and also call gant from ant).

我ぃ本無心為│何有愛 2024-07-14 20:48:58

我非常喜欢 SCons,它是一个构建工具,其配置文件都只是 Python 脚本。 这将吸引任何了解 Python 或类似脚本语言的人。 SCons 旨在与 Java 以及 C/C++ 和其他语言很好地配合使用,我过去对它非常满意。

由于 SCons 文件是用 Python 编写的,因此如果您发现自己需要执行任何特殊操作,则可以编写任意 Python 代码。 但是,如果您完全不熟悉 Python,那么与尝试扩展 Ant 或类似的东西来完成您想要的事情相比,学习曲线可能会更高。

I really like SCons, which is a build tool whose configuration files are all just Python scripts. This will appeal to anyone who knows Python or similar scripting languages. SCons is designed to work well with Java as well as C/C++ and other languages, and I've been very satisfied with it in the past.

Because SCons files are written in Python, you can write arbitrary Python code if you find yourself needing to do anything special. However, if you're completely unfamiliar with Python, then there will possibly be a higher learning curve than trying to extend Ant or something similar to do what you want.

病毒体 2024-07-14 20:48:58

Maven2 似乎是后起之秀。

然而,对于我们的项目,我们将在可行的情况下迁移回 ant。

Maven2 需要相当多的知识才能完全按照您想要的方式获得它,并且 Maven2 版本似乎以不同的方式处理类路径。

检查可能被吸引的依赖项的依赖项中包含的所有许可证是一件痛苦的事情。并且

可能启动时间较慢,因为您需要自己找出依赖项,但至少它很容易阅读。 这里没有什么神奇的:)

如果您确实使用 Maven,请考虑像 Nexus 这样的内部存储库。 这样,即使某些图书馆决定退出网络,您的软件也不会死掉*。

*我们被maven1烧伤了; ibiblio maven1 存储库重定向,maven1 不支持重定向:(

Maven2 seems to be the up and coming thing.

For our projects however we are migrating back to ant wherever feasible.

Maven2 requires quite a bit of knowledge to get it exactly the way you want, and Maven2 versions seem to handle classpaths differently.

And it is a pain to check all licenses included in the dependencies of the dependencies which may get drawn in.

And may have a slower start-up time, as you need to figure out the dependencies yourself, but at least it's easily readable. No magic going on here :)

If you do use maven, give a thought to an internal repository like Nexus. That way your software is not dead if some libraries decide to go away from the net*.

*We got burned with maven1; the ibiblio maven1 repository redirects and maven1 does not support redirects :(

趁年轻赶紧闹 2024-07-14 20:48:58

我建议您在考虑合适的工具时首先考虑您的需求。 每个项目都是不同的,您使用的工具应该反映问题空间而不是时尚。

话虽这么说,我认为对于一般用途来说,ant 可能仍然是构建 java 应用程序的最佳通用工具。 它通常与其他工具一起有效地用于依赖管理,但我们再次回避一个没有问题的解决方案。

好消息是,如果您的流程良好,那么切换构建工具是一个相当轻松的过程 - 教训 - 从一个适合当前问题的良好流程开始。

I would urge you to start with your requirements when considering the right tool. Each project is different, the tool you use should reflect the problem space not the fashion.

That being said, I think for general use ant is still probably the best general tool for building java applications. It is often used effectively with other tools for dependency management but there we go again skirting off into a solution without a problem.

The very good news, is that if your process are good switching build tools is a fairly painless process - lesson - start with a good process scaled to the problem at hand.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文