I have one non-web based application. I have the Ant file to create the jar file. I have another web application that uses this jar.

My client would like them to be in single codebase and one Ant file so that we can identify whether to build the jar or war file so all the source codes for the non-web based as well as the web-based will be in one project.

Is that possible? I think so but I just need some opinions from all of you. Sorry, not really sure about Ant here. Let me google it as well

LVL 16
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Probably all you need is to pass a parameter to ant to tell it what to build

ant -Dproject=web

or indeed just have separate targets

ant web


ant non-web

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
suprapto45Author Commented:

Thanks, I think that the separate targets are the best way to go. Basically, can I use my existing Ant xml file so...I might end up like build.xml, buildWeb.xml and buildNonWeb.xml

I think that it should be doable, am I right?

suprapto45Author Commented:
Sometimes this Ant *thing* and classpath are making me nuts
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

You don't need separate build files, just separate targets, which will probably be fairly similar, in the same build file
suprapto45Author Commented:

I will have a try tonight. Anyway, you can be online now, you must be close. Where are you located actually?

The UK - currently Somerset - sometimes London
suprapto45Author Commented:

So far so good. I have created two target in Ant...buildJar and buildWar. One more question. When I tried to run it using Ant, it seems that I need to specify the default in the <project> tag to allow it run otherwise, it won't run. Any idea on that? So I need to specify either
<project name="Test" default="buildJar" basedir=".">
<project name="Test" default="buildWar" basedir=".">

Yes you can specify a default and then run


or else you need to specify the target:

ant buildJar


and buildWar
suprapto45Author Commented:
Sorry for the delay...but can I set the default to buildWar but run it using ant buildJar? I tried but it fails. It works only if you set the default to buildJar

Could be something wrong here. Let me double check

>>but can I set the default to buildWar but run it using ant buildJar?

suprapto45Author Commented:
Thanks. Yeah just specifying the target solves the problem.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.