Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compare to the IDE for Java,do we still need Ant?

Tags:

eclipse

ant

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.

like image 763
Vacker Avatar asked Oct 25 '11 04:10

Vacker


People also ask

Can I code Java without IDE?

The Java Code to be Built and Executed java does have a main function to allow demonstration of running the class without an IDE.

Are ants outdated?

Ant and Maven are fairly obsolete at this point in the Java world having been superseded by Gradle, and so aren't really worthy of much discussion.

Does Eclipse use Maven or Ant?

In fact Eclipse itself uses Ant extensively to build plugins. If you were to learn one of the two, learn Maven, it's the one pretty much everyone uses these days (replacing Ant). Show activity on this post. Maven is generally used to build the plugins or jars for a particular application.

Is Maven like Ant?

While Ant gives flexibility and requires everything to be written from scratch, Maven relies on conventions and provides predefined commands (goals). Simply put, Maven allows us to focus on what our build should do, and gives us the framework to do it.


4 Answers

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.

like image 71
manojlds Avatar answered Sep 29 '22 00:09

manojlds


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.

like image 23
David W. Avatar answered Sep 29 '22 01:09

David W.


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.

like image 36
Dante WWWW Avatar answered Sep 29 '22 02:09

Dante WWWW


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.

like image 22
Amanuel Nega Avatar answered Sep 29 '22 02:09

Amanuel Nega