Recently I started running into this weird ant error that was causing a lot of our builds fail.
[root]#ant
Unknown argument: -cp
ant [options] [target [target2 [target3] …]]
Options:
-help, -h print this message
-projecthelp, -p print project help information
-version print the version information and exit
-diagnostics print information that might be helpful to
diagnose or report problems.
-quiet, -q be extra quiet
-verbose, -v be extra verbose
-debug, -d print debugging information
-emacs, -e produce logging information without adornments
-lib <path> specifies a path to search for jars and classes
-logfile <file> use given file for log
-l <file> ”
-logger <classname> the class which is to perform logging
-listener <classname> add an instance of class as a project listener
-noinput do not allow interactive input
-buildfile <file> use given buildfile
-file <file> ”
-f <file> ”
-D<property>=<value> use value for given property
-keep-going, -k execute all targets that do not depend
on failed target(s)
-propertyfile <name> load all properties from file with -D
properties taking precedence
-inputhandler <class> the class which will handle input requests
-find <file> (s)earch for buildfile towards the root of
-s <file> the filesystem and use it
-nice number A niceness value for the main thread:
1 (lowest) to 10 (highest); 5 is the default
I did a google search on “ant Unknown argument: -cp” and ended up with a pretty decent number of hits. But unfortunately none of them seem to offer a simple and elegant solution to my problem. The solution ranged from deleting a file from /etc directory to changing the ant script itself, which were definately not acceptable due to the fact that these builds were working perfectly before. After some digging around I found why this occured in my environment. Apparently Ant does not like if the ANT_HOME is different from the location of ANT’s bin in the PATH variable. For example, I had my ANT_HOME as
echo $ANT_HOME
/opt/ant170
And the PATH is set to point to a different version of ANT as,
echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/sbin:/bin:/usr/sbin:/usr/bin:
/opt/1.6.2a/bin:/opt/java/1.5/bin
Setting my PATH to the right ANT’s bin directory fixed the problem..
I did the same mistake was was trying to find out the other version of the ant.
It may quite possible that you wont be able to find out exact place of ant.
For Ubuntu
1> Go to System–>Administration–>Synaptic Package Manager
3> Search for ant.
4> Mark it for removal
5> And apply the changes
This will remove the ant which was installed by mistake.
Now you can set up the proper path of the ant.
Try it out.
Kishor,
Thanks and I am sure the information you posted will be helpful.