The moose likes Ant, Maven and Other Build Tools and the fly likes setting up ANT Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Reply Bookmark "setting up ANT" Watch "setting up ANT" New topic
Author

setting up ANT

Praveen Kumar
Greenhorn

Joined: May 17, 2004
Posts: 15
Hello All,

When I try to run ant through the command "ant" and its various versions like "ant -version", "ant -help", I get the following error message ...

Invalid implementation version between Ant core and Ant optional tasks.
core : 1.6.0
optional: 1.6.1

After googling out I found that I have to download Optional Jar files for certain tasks. My first impression after I visited the appropriate manual page that describes the optional jars is that I am not using any of those tasks mentioned. Here is my build file

<?xml version="1.0"?>
<!-- Build.xml sample xml file -->
<project name ="Learning Ant" basedir="." default ="compile">
<property name = "src.dir" value ="src"/>
<!-- Temporary build directories -->
<property name="build.dir" value="build"/>
<property name="build.classes" value="${build.dir}/classes"/>
<property name="build.lib" value="${build.dir}/lib"/>
<!-- Target to create the build directories prior -->
<!-- compile target. -->
<target name="prepare">
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.classes}"/>
<mkdir dir="${build.lib}"/>
</target>

<target name="clean" description="Remove alltemp files.">
<delete dir="${build.dir}"/>
</target>
<target name="compile" depends="prepare" description="Compiles all source code.">
<javac srcdir="${src.dir}" destdir="${build.classes}"/>
</target>
<target name="jar" depends="compile" description="Generates target.jar ">
<!-- Exclude unit tests from the final JAR file -->
<jar jarfile="${build.lib}/target.jar" basedir="${build.classes}" />
</target>
<target name="all" depends="clean,jar" description="Cleans, compiles, builds JAR "/>
</project>
</align>

What amazes me more is that for commands like "ant -version" which is not trying to execute any tasks, ant gives the same error message.

Please help this newbie get started

Thanks,

Praveen.


Gosh ! Darn it.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Make sure the jar's you have in %ANT_HOME%\lib are only those for the core Ant installation. All of them should start "ant". Make sure you don't have optional.jar kicking around in there too. Also check your %ANT_HOME% doesn't point to a different version of ant than you expect it to.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Alpha Ma,

Welcome to JavaRanch!

We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.

Thanks Pardner! Hope to see you 'round the Ranch!n


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Praveen Kumar
Greenhorn

Joined: May 17, 2004
Posts: 15
Hello Paul,

Thanks for the reply. Per your suggestion I took out all the jars that were not starting with ant. There were actually two such and both are XML related jars. The problem still persists. Any other suggestion?

Thank You,

Rave.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

I suspect you've taken out xercesImpl.jar and xml-apis.jar? They actually are distributed with Ant (sorry, my earlier comment was a little too all inclusive) so won't be the problem. Your error suggest there is an optional jar from Ant 1.6.1 somewhere in your classpath when you try to run Ant. Check your classpath and check the jars in the %ANT_HOME%\lib directoy. If you can't find it, I'd delete your ant directory and unpack Ant again.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 23621

"Rave",
Thank you for changing you name. Unfortunately, your display name is still invalid. Note that it must be two words: a first name and a last name.
[ May 18, 2004: Message edited by: Jeanne Boyarsky ]

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Certs: SCEA Part 1, Part 2 & 3 & Core Spring 3, OCAJP
 
 
subject: setting up ANT
 
Threads others viewed
Why can't run?
Apache Ant add property file and policy file
ANT Always Compiling.
How to excute the build.xml for the ant script
Problem when including unit test cases in build
IntelliJ Java IDE