3

Hi most of the time i will build the Java Application using IDE option Build/Clean then Export JAR/WAR/EAR file to desktop after that will deploy in server using server admin url/console. But in some organizations will build application using ant/maven script in linux/windows. is there any difference buid using IDE and external script.

sdasdadas
  • 23,917
  • 20
  • 63
  • 148
rev
  • 77
  • 1
  • 8

2 Answers2

2

An external script like ANT can automate things for you. This may seem irrelevant when all you do is build a .JAR, but when you start to do more things it can be very helpful.

An automated build could do this for you:

  • Run your unit tests and create a report that you can view.
  • Compile your project ("Build")
  • Move the .JAR to a different directory.
  • Upload via FTP to your server.

This means that everything you currently do could be done by double-clicking an Ant script. Eclipse even has support for Ant so you can edit and run the script within your IDE.


Just an edit about the philosophy of automation. Let's say your current process takes about 15 minutes to build a .JAR and upload it to your server:

  • Once, 15 minutes.
  • Twice, 30 minutes.
  • Four times, 60 minutes.

You get the point. But wait, you say, writing an ANT script... that's more difficult - it might take 8 hours to learn about ANT and write a script that works.

And that is absolutely correct but the thing that makes automation grand is that now it takes 0 minutes to do your step. So, the process looks like:

  • Write ANT script: 480 minutes (8 hours)
  • Run ANT script: 0 minutes

So how do you know if you need automation? Simply think about how many times you will need to perform your manual process. If you'll only ever run it once then the comparison will be 15 minutes vs 480 minutes and you shouldn't write a script. But if you think you'll perform the process 40 times, then the comparison is 600 minutes vs 480 minutes and you would be better off writing a script.

(The above also excludes other positives about automation. For example, it's very easy to make mistakes [error in creating .JAR] when you do it manually - but the computer never makes mistakes once it's set-up correctly.)

sdasdadas
  • 23,917
  • 20
  • 63
  • 148
  • One can also note that when using ANT or Maven, you would generally setup your IDE so the configuration files are used to setup the IDE project. So in essence - there is no difference. Even in your IDE ANT and Maven would be used up to a certain point. – Gimby Mar 20 '13 at 17:26
  • Hi thanks for Detailed Explanation. But My question is straight forward. we develop application in Eclipse IDE then Compile/Build the Application using Build/Clean option in IDE. But most of them will call External script to compile/Build . what is difference compile a Application using IDE And external script? – rev Mar 20 '13 at 17:27
  • There is no difference. Eclipse uses a different compiler, see: http://stackoverflow.com/questions/3061654/what-is-the-difference-between-javac-and-the-eclipse-compiler but the end result should be the same no matter how you build your application. – sdasdadas Mar 20 '13 at 17:36
2

If you simply need to archive the entire project in your IDE as a WAR or EAR , then it does not really make difference if you build it through IDE or thorough ANT.

However there are certain scenarios where it requires more than just archival. For example you might want to create an EAR but do not want to include certain jars in it. Or you might want to remove all property files before creating the EAR. ANT gives you that flexibility. You can define your own build.xml and run it through ANT. It will create the EAR as defined in the build.xml.

Also it takes less time since its a automated process. So if you need to create WAR's or EAR's at a high frequency, You should probably use the scripts. They are going to save you a lot of time.

So basically automation and customization are the two main advantages of using ANTscripts

CoderP
  • 1,361
  • 1
  • 13
  • 19