1

I'm trying to run an ant build in linux and I'm getting odd results. I can't seem to get anything to run without specifying each and every library on the classpath, so I systematically added every jar in the "lib" and "ant/dep/lib" locations to the classpath explicitly.

It runs a bit without any issues (it's a setup batch, so in the first phase of the script, it uses a lot of "input" tasks), then I receive the message that org.apache.tools.ant.taskdefs.optional.PropertyFile was not found. Looking around, I discovered it was located in ant-nodeps.jar and I had added it to the class path, but no change.

Complete failure due to missing libraries I can understand, but why would the build partially function if I was sure I was including every library (including ant-nodeps.jar)?

The script file to launch it is as follows:

#!/QOpenSys/usr/bin/bsh
ANT_HOME=dep/ant
PARAMS="-Dant.home=$ANT_HOME -Dsystem.type=as400 -Dis-as400=y"
LIBS="lib/ant-contrib-1.0b3.jar:lib/ant-launcher.jar:lib/ant.jar:lib/catalina-ant.jar:lib/catalina-deployer.jar:lib/commons-net-2.2.jar:lib/el-api.jar:lib/ganymed.jar:lib/jakarta-oro-2.0.8.jar:lib/jasper-el.jar:lib/jasper.jar:lib/jsp-api.jar:lib/log4j-1.2.16.jar:lib/mail.jar"
ANTLIBS="$ANT_HOME/lib/ant-antlr.jar:$ANT_HOME/lib/ant-jai.jar:$ANT_HOME/lib/ant-starteam.jar:$ANT_HOME/lib/ant-apache-bcel.jar:$ANT_HOME/lib/ant-javamail.jar:$ANT_HOME/lib/ant-stylebook.jar:$ANT_HOME/lib/ant-apache-bsf.jar:$ANT_HOME/lib/ant-jdepend.jar:$ANT_HOME/lib/ant-swing.jar:$ANT_HOME/lib/ant-apache-log4j.jar:$ANT_HOME/lib/ant-jmf.jar:$ANT_HOME/lib/ant-testutil.jar:$ANT_HOME/lib/ant-apache-oro.jar:$ANT_HOME/lib/ant-jsch.jar:$ANT_HOME/lib/ant-trax.jar:$ANT_HOME/lib/ant-apache-regexp.jar:$ANT_HOME/lib/ant-junit.jar:$ANT_HOME/lib/ant-weblogic.jar:$ANT_HOME/lib/ant-apache-resolver.jar:$ANT_HOME/lib/ant-launcher.jar:$ANT_HOME/lib/ant.jar:$ANT_HOME/lib/ant-commons-logging.jar:$ANT_HOME/lib/ant-netrexx.jar:$ANT_HOME/lib/xercesImpl.jar:$ANT_HOME/lib/ant-commons-net.jar:$ANT_HOME/lib/ant-nodeps.jar:$ANT_HOME/lib/xml-apis.jar"

java -classpath $LIBS:$ANTLIBS $PARAMS org.apache.tools.ant.launch.Launcher -buildfile install/install.xml

Any help would be appreciated, even if only suggestions for what to try.

EDIT: In light of oers observation, I realized that there are shell scripts for ant afterall (have pity, I'm no expert in linux), so I'm going to attempt to use it to launch ant rather than try to do the same thing myself. I'll let everyone know of my progress and/or if I was able to fix it doing it that way.

2
  • 2
    why are you writing your own ant script? there is an executable in ant/bin This is basically doing the same (adding averything to the classpath, but using iteration over every jar file present)
    – oers
    Apr 1, 2011 at 8:05
  • It uses .bat files and perl scripts, and as much as I'd like to install perl on this machine, this setup has to always work, meaning I'd have to automate some perl installation prior to running the setup and I'd rather not have to do that just to be able to run ant.
    – Neil
    Apr 1, 2011 at 8:07

2 Answers 2

2

I looked into the shellscript on my machine. There is an additional parameter set:

-Dant.library.dir=\"$ANT_LIB\"  

Perhaps this is needed?

ant_exec_command="exec \"$JAVACMD\" $ANT_OPTS
  -classpath \"$LOCALCLASSPATH\"   
  -Dant.home=\"$ANT_HOME\" 
  -Dant.library.dir=\"$ANT_LIB\" $ant_sys_opts  
  org.apache.tools.ant.launch.Launcher 
    $ANT_ARGS 
    -cp \"$CLASSPATH\" 
    $ant_exec_args"  
4
  • I'm having the same problem, but I can't understand your answer. Could you clarify? Sorry!
    – Ziggy
    Jul 22, 2012 at 18:30
  • 1
    if you have your own build skript for ant or invoke ant just with java ..., you need to add the parameter -Dant.library.dir=PATH_TO_ANT_LIB_DIR to the invoking command, else ants_lib dir is not in the classpath
    – oers
    Jul 22, 2012 at 18:34
  • and basically the solution was to use the shell scripts provided by ant itself to start ant
    – oers
    Jul 22, 2012 at 18:36
  • @ziggy did you get the reply? forgot the @ part
    – oers
    Jul 23, 2012 at 6:26
0

Using the ant scripts to launch the setup seemed to do the trick, specifying parameter -lib as lib and -buildfile as install/install.xml.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.