与Java的IDE相比,我们还需要Ant吗?

发布于 2024-12-11 21:00:32 字数 196 浏览 0 评论 0原文

不久前我已经深入研究了Ant并使用它做了一些简单的练习(编译,单元测试,打包)。现在我平时的工作都是在Eclipse下进行java开发,平时的工作都可以通过Eclipse的功能来简单完成:in-time编译、点击按钮部署、各种向导..

所以我想知道在Eclipse下我们是否需要Ant。 如果是的话,我们应该在哪些方面将 Ant 与 Eclipse 结合使用。

Not long before I had digged into Ant and use it doing simple practice(compile,unit test,package).Now my usual work is under Eclipse for java development,the usual work can all be simply done through Eclipse' function:in-time compiling、click button to deploy、various wizard..

So I am wondering under Eclipse do we have a need for Ant.
And if it is, at which aspect should we use Ant along with Eclipse.

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

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

发布评论

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

评论(4

慢慢从新开始 2024-12-18 21:00:32

构建应用程序不仅仅是在 IDE 中构建它们。您需要设置一个可运行的自动化构建和部署方法,例如持续集成和部署。构建的包必须部署到各种环境并最终投入生产。您无法从自己的盒子中构建它们。您无法在 IDE 之外构建它。您需要单独的构建系统。这就是像 ANT 这样的构建工具的用武之地。

另请注意,IDE 进行构建、部署的功能是有限的,这不是它们的强项。但是,可以使用 ANT 及其构建脚本和 从 Eclipse 中运行它们。这样,您就拥有了用于本地(开发人员)构建和主构建过程的一组脚本。由于 ANT 基于 JAVA,您还可以通过编写自定义任务等来满足您的构建工具的需求。

此外,当您在构建系统中使用像 ANT 这样的标准工具时,您可以迁移到不同的 IDE,例如 Intellij IDEA 和仍然使用您知道的构建系统。

Building applications is not about just building them in your IDE. You need to setup an automated build and deploy method that can be run for, say, continuous integration and deployment. The built package has to be deloyed to various environments and finally production. You cannot build them out of your own box. You cannot build it out of your IDE. You need separate build system. That is where build tools like ANT come in.

Also note that the capabilities of IDEs for doing build, deploy is limited and that is not their strength. It is, however, possible to make use of ANT and its build scripts and run them out of eclipse. This way, you have a single set of scripts for both your local ( developer ) build and the main build process. With ANT being JAVA based, you can also suit your build tool to your needs by writing custom tasks etc.

Also, when you make use of something as standard as ANT for your build system, you can move to a different IDE like Intellij IDEA and still make use of the build system that you know.

惜醉颜 2024-12-18 21:00:32

如果可以通过 IDE 构建,还需要 Ant 吗?当然不是!你自己可以看到这一点。

您是否仍然应该使用标准工具进行独立于 IDE 的构建?当然!

请注意,我没有说“蚂蚁”。有许多用于构建 Java 程序的构建工具,例如 Maven 或 Gradle。但是,您需要一个独立于 IDE 的构建系统是有原因的:

  • 您有一个持续集成服务器:您确实有一个。正确的?如果你没有得到一个。每次将更改提交到版本控制系统时,持续集成服务器都会自动构建您的项目(并运行每个测试)。它会发现错误。它还提供官方构建。不再有它在我的机器上工作了!借口。如果持续集成服务器无法构建它并成功运行测试,那么该软件就不好。
  • 您的其他人需要在不同环境的不同计算机上处​​理您的项目:IDE 的问题在于它特定于您的系统。其他人检查了您的项目,他们可能使用不同的 IDE。他们的设置可能略有不同。像 Ant 这样的独立构建脚本语言可以保证他们可以按预期重建您的项目。

如果您与其他人共享一个项目,您需要一种独立的标准方法来构建该项目并准确了解该构建工作需要什么。 IDE 可以隐藏该信息。

Do you need Ant if you can build through the IDE? Of course not! You can see that yourself.

Should you still have a IDE independent build with standard tools? Of course!

Note I didn't say Ant. There are a number of build tools such as Maven or Gradle that are made to build Java programs. However, there are reasons why you want an IDE independent build system:

  • You have a Continuous Integration Server: You do have one. Right? If you don't get one. A Continuous Integration Server automatically builds your project (and runs every test) each time a change is committed to the version control system. It catches mistakes. It also provides an OFFICIAL BUILD. No more It worked on my machine! excuses. If the Continuous Integration Server can't build it and successfully run the tests, the software isn't good.
  • You have others who need to work with your project on a different computer in a different environment: The problem with IDEs is that its specific to your system. Someone else checks out your project, and they may be using a different IDE. They maybe have a slightly different setup. An independent build scripting language like Ant guarantees that they can rebuild your project as intended.

If you share a project with someone else, you need an independent standard method way of being able to build that project and to know exactly what is required for that build to work. IDEs can hide that information.

你げ笑在眉眼 2024-12-18 21:00:32

我是一名每天使用 Ant 的基准测试人员。我们的环境有7台测试机和1台控制台机。对于每次测试运行,ant 脚本都会更新工作副本,重新启动数据库,使用适当的属性构建产品和 Grinder 并将它们部署到机器上,然后启动它们和监控软件。使用 1000-line-buildfile,我只需在控制台计算机的终端中输入类似“ant ABCD E”的行即可。我认为在 Eclipse 或 NetBeans 或其他任何 IDE 中执行此操作不是一个好主意。

另外,在我公司的产品中,ant被广泛使用。我们使用ant构建样本数据进行基准测试;我们使用ant来更新Tomcat,Tomcat将与我们的产品捆绑在一起;我们还使用 ant 构建和运行 selenium 测试。

更重要的是,当你想要发布源代码时,包括IDE项目文件并不是一个好主意,因为IDE有很多。如果用户只想从您的最新代码获得新的构建(如果您不提供夜间构建)怎么办?提供一组 ant(或其他构建工具)构建文件是一个好主意。这样,您就可以管理构建的类路径。

I am a benchmark tester using Ant everyday. Our environment has 7 test machines and 1 console machine. For each test run, the ant script updates the working copy, restarts the database, build the product and the Grinder with proper properties and deploy them to the machines, and starts them and the monitoring softwares. With the 1000-line-buildfile, I can just type in an "ant A B C D E"-like line in the terminal on the console machine. I don't think it's a good idea to do this in a IDE like eclipse or NetBeans or anything else.

Also, in my company's product, ant is widely used. We use ant to build sample data for the benchmark test; we use ant to update Tomcat which is going to be bundled with our product; we also use ant to build and run selenium tests.

What's more, when you want to release the source code, including the IDE project files is not a good idea because there are a lot of IDEs. And what if the user just want to get a fresh build from your latest code (if you don't provide nightly build)? Providing a set of ant (or other build tool) buildfiles is a good idea. With this, you can manage your classpath for the build.

z祗昰~ 2024-12-18 21:00:32

这里最简短的答案是灵活性。 IDE 可能带有预定义的功能,甚至允许您使用向导选择一些选项。这就像用 Dreamweaver 或此类工具生成 html 一样。它永远不会像纯粹的东西那样灵活。例如,NetBeans 在底层使用 Ant。

引用自:Netbeans:构建工具

默认的 NetBeans IDE 项目系统直接构建在
Ant 构建系统。所有项目命令,例如“Build
Project”和“Run File in Debugger”,在项目的Ant中调用目标
脚本。因此,您可以在 IDE 之外构建并运行您的项目
与在 IDE 中构建和运行完全相同。

即使您为此目的使用了工具之后,您很可能仍然需要温习。所以,我想说的是,IDE 为您所做的只是您使用纯 ant 或 maven(如果您使用它)可以做的事情的一个子集。对于编译和运行等简单任务,IDE 做得非常好!但是,如果您的用例像在 CI IDE 上部署一样复杂,则不会对您有帮助。您需要构建工具的整体灵活性。

The shortest answer here wold be flexibility. The IDEs may came with pre-defined functionalities and may even allow you to choose some options using wizards. It is like generating html with Dreamweaver or such tools. It will never be as flexible as the pure thing. For example NetBeans uses Ant underneath.

Quoted from: Netbeans: Build Tools

The default NetBeans IDE project system is built directly on top of
the Ant build system. All of the project commands, such as "Build
Project" and "Run File in Debugger", call targets in the project's Ant
script. You can therefore build and run your project outside the IDE
exactly as it is built and run inside the IDE.

Even after you use tools for that purpose you are most likely still to brush up. So, what I am saying is, what the IDEs do for you is only a subset of what you can do with the pure ant or maven( if you use it). For simple tasks such as compile and run, IDEs do pretty much a good job! But if you have a use case as complex as deploying on CI IDEs won't help you. You need the whole flexibility of your build tools.

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