I am writing ant scripts and using Ant flaka jar to do some work.
But flaka doesn't work as other external Ant lib.
For example, if I need to include ant-contrib:
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="../../lib/ant-contrib.jar"/>
</classpath>
</taskdef>
Most importantly, I can specify where the jar is located.
But for flaka, I don't see such thing. In the official website, they just tell user to download flaka jar to Ant installation folder.
How can I specify where is the flaka jar when I want to use it?
I just installed flaka in under 1 minute. Simply put the .jar into your ..ant/lib dir as they indicate in the installation instructions.
Run this :
As they also say in the site. If the output is different than this :
Check your java version. It must be >= 1.5. Your ant should be >= 1.7 and last but not least check your permissions.
First of all some general recommendation. Any external lib has to be in sight for ant, means on path.
The most primitive approach is to put your ant addons in $ANT_HOME/lib, but that 'pollutes' your ant installation.
Put your external libs in it's own location, f.e. /ant_xtralibs and use the -lib parameter via Ant_ARGS.
The Flaka manual section 2 has some notes about that, more details in the Ant manual.
Your example dealing with antcontrib uses the traditional approach via taskdef resource..
The modern - recommended - way is to use a XML namespace declaration, as the Flaka Manual mentions
right before section 2 :
"Thus all build file snippets shown assume that the build file contains the following XML namespace declaration"
It's also possible to use Flaka via taskdef the traditional way:
output
note the lines starting with "Trying to override.." That's because of Flaka extends some ant tasks
but if you put Flaka in it's own namespace :
output
no more "Trying to override..." means no more collision with ant's own tasks, as Flaka resides in it's own namespace
So to make it short :
1) use ANT_ARGS to bring your extralibs (Flaka .. etc.) in the game
2) use the modern way of Namespace declaration
EDIT after comment asking for namespace combined with classpath EDIT
yes that works, see Ant manual for details about antlib, especially the section
"Load antlib from inside of the buildfile", for Flaka you would use something like :
but i believe you still didn't get the advantages of using $ANT_ARGS
simply use some script to start your ant scripts, f.e. :
for Windows
set JAVA_HOME=C:\java\jdk\1.6.0_26
set ANT_HOME=C:\ant
set ANT_ARGS=-lib C:\ant_xtralibs;C:\ant_testlibs
set PATH=%PATH%;%JAVA_HOME%\bin;%ANT_HOME%\bin;C:\cvsnt
:: default
call ant -f %1
:: debug
::call ant -debug -f %1
... etc.
for Linux/Unix - don't forget the quotationmarks on the ANT_ARGS line !
...
ANT_ARGS="-lib /usr/local/ant_xtralibs:/usr/local/ant_testlibs"
export ANT_ARGS
...
You don't need to use taskdef with classpath anymore !!
Using the -lib option to load additional libraries has another benefit.
There are some libs which must be loaded before Ant (f.e. BSF, js, xml)
starts parsing the buildfile.
ANT_ARGS is a special environment variable. Its content is automatically added to the invocation of Ant.
-- Other possibilities --
1)
put those 'set ANT_ARGS ...' stuff into =
Linux/Unix
$ANT_HOME/bin/ant
Windows
%ANT_HOME%/bin/ant.bat
disadvantage = changes the ant core installation, remember
your changes before you copy your ant installation to
another machine and strange things happen !
2)
put your extralibs in ${user.home}/.ant/lib
advantage = every user may use his own set of libraries
consult the Ant manual for details :
http://ant.apache.org/manual/running.html#commandline
http://ant.apache.org/manual/running.html#libs