aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes help in Ant makefiles Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "help in Ant makefiles" Watch "help in Ant makefiles" New topic
Author

help in Ant makefiles

Abhi Chat
Ranch Hand

Joined: Oct 10, 2004
Posts: 57
could u guys help me in gettin accustomed in Ant ....i prefer to do the compiling part of the scjd through Ant..

thanx
abhi


SCJP 1.4<br />Preparing for <br />SCJD and SCWCD
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11277
    
  59

Hi Abhi,

Perhaps you could provide us with an example of some task you are currently doing manually, then we might be able to offer an example of how to do it with ant.

Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
peter wooster
Ranch Hand

Joined: Jun 13, 2004
Posts: 1033
Originally posted by Abhi Chat:
could u guys help me in gettin accustomed in Ant ....i prefer to do the compiling part of the scjd through Ant..

thanx
abhi


Here's the build.xml that I use to compile, jar and javadoc my project. Its pretty simple, no fancy dependencies or anything like that.
Andy Zhu
Ranch Hand

Joined: May 26, 2004
Posts: 145
Not a fan of Ant. Found gnu make is quite easy and works for me. Actually it will have me write a short script.


--------<br />Andy Zhu<br />scjp 1.4<br />scjd 1.4<br />SAS Certified Programmer 9.0
Inuka Vincit
Ranch Hand

Joined: Aug 10, 2004
Posts: 175
Although I am working on an ANT build file...
JBuilder the free version, can handle all the building part if you dont want to or dont have time of learning ANT. Whats more the editor is briliantly good since it detects and underlines syntax errors saves me a bunch of time.


MCP (C# application dev 70-316) 860<br />SCJP 1.4 100% SCJD (URLyBird) 378<br />MAD 100% nuts
jiju ka
Ranch Hand

Joined: Oct 12, 2004
Posts: 306
I am using WSAD for the URLyBird.You may donload the freeware ide eclipse from eclipse.org which is what WSAD is using.

Other choices are NetBeans which Sun prefers but not IBM.
vydhehi paruchuri
Greenhorn

Joined: Aug 27, 2003
Posts: 22
Which version og JBuilder is free?
peter wooster
Ranch Hand

Joined: Jun 13, 2004
Posts: 1033
Originally posted by vydhehi paruchuri:
Which version og JBuilder is free?


The Foundation Edition, but don't use JBuilder for the SCJD, it will do too much to help build your GUI.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11277
    
  59

Originally posted by Andy Zhu:
Not a fan of Ant. Found gnu make is quite easy and works for me. Actually it will have me write a short script.


I am a convert to Ant.

I used to use make extensively to the point where I was asked to provide training to other companies and to help out other development teams with it. And I know from experience the difficulties you can get when dealing with the different variants (is the platform I am writing for using GNU make or POSIX or ???). But when writing C programs that were being compiled under many different Unix variants, it was great.

Ant's large number of built in tasks, but the add on tasks makes life so much easier than using make. And then the ant script can usually be run directly from the command line and/or many of the popular IDEs.

Regards, Andrew
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11277
    
  59

Hi Abhi,

Did Peter's ant file help you? Or are you thinking about posting a command line you would like converted into an ant script so you can see how it is done?

Regards, Andrew
peter wooster
Ranch Hand

Joined: Jun 13, 2004
Posts: 1033
Originally posted by Andrew Monkhouse:
I am a convert to Ant.

I used to use make extensively ...


Same here, I've used so many different make utilities, I can't keep them straight, there's make, gmake, nmake, not to mention polytron pmake and make like utilities in other systems.

Ant is great for building java, it has all sorts of built in tasks that do much of what you need, and none of the Unix strange syntax (only known by shell programming gurus). Some people, myself included, aren't certain the XML syntax is the best, but it sure beats shell.
Inuka Vincit
Ranch Hand

Joined: Aug 10, 2004
Posts: 175
Originally posted by peter wooster:


The Foundation Edition, but don't use JBuilder for the SCJD, it will do too much to help build your GUI.
]

Agreed. But you dont have to use the built in GUI Builder
But its the editor that got me. I tried eclipse and JEdit... but cant beat the built in sytax highlighting and checking. Its nice to have 0 syntax every time you do a complie .

I am also a convert from Make... I changed over for practicle reasons could get the winblows make port to work properly.
Abhi Chat
Ranch Hand

Joined: Oct 10, 2004
Posts: 57
Hi Andrew,

Thanx guys for all your help....Andrew it would be nice if you could help me
with an ANT script of the project 2 version of Mehrams Habibis book...it would be really a good startin point for me...

Thanx

Abhi
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11277
    
  59

Hi Abhi,

This is a very simple ant build file, which is designed to just compile the source files in the project. I have not gone into the RMIC or JAR commands in this first build file, as I want to keep the first part simple. A little further down this post you will see the more advanced version of the ant script.



Save this as "build.xml" in your base directory (the one containing the "sampleproject" directory). Then you can use this to compile the source code just by typing "ant" at the command line. This is a little easier than retyping the entire set of compilation commands each time a single file changes!

Make sure you understand what is happening in that build file before going on. If there is something you don't understand, then the following won't help.

Here is a slightly longer version of that XML file, which includes targets to run the RMIC compiler, and to make the executable jar file:




If you run the command "ant -projecthelp" in the directory containing the above build.xml file, you will get the following output:



If you look through the build.xml file above, you will see that the compile and dist targets are the only two targets that I created a description for. That is why they are the only two targets that appear when you ask for project help. However there is nothing to stop you running one of the other targets directly. You could, for example, run ant rmic and it will run the rmic target.

I have tried to make this readable, without writing an entire book on the subject.

Please ask questions if you are unsure of anything.

Regards, Andrew
Abhi Chat
Ranch Hand

Joined: Oct 10, 2004
Posts: 57
Thanx Andrew...this would surely get me started .....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help in Ant makefiles
 
Similar Threads
Junit with ant
What does this mean in ANT
java.lang.IllegalStateException: Exception Description: Cannot use an EntityTransaction while using
WA #1.....word association
ANT SCRIPT with Eclipse 3.0