On Nov 20, 2007 1:36 AM, Hunter Peress <[EMAIL PROTECTED]> wrote: > *First the build file: > * > <?xml version="1.0" encoding="UTF-8" ?> > <project default="go" basedir="."> > <path id="abc"> > <pathelement location="resources/bsf-2.4.0.jar"/> > <pathelement location="resources/commons-logging.jar > "/> > <pathelement location="resources/groovy-all-1.0.jar > "/> > </path> > <target name="go"> > <script language="groovy" classpathref="abc"> > println "HELLO" > </script> > </target> > </project> > > -------------------------------------------------------------------------------- > * > Next we run it and watch it error:* > $ ant > Buildfile: build.xml > > go: > > BUILD FAILED > c:\Documents and Settings\hperess\build.xml:10: > java.lang.NoClassDefFoundError: org/apache/bsf/BSFException > > Total time: 0 seconds > > -------------------------------------------------------------------------------- > *Finally, we run it but including the jars at call time. > > [EMAIL PROTECTED] ~ > $ ant -lib resources/ > Buildfile: build.xml > > go: > [script] HELLO > > BUILD SUCCESSFUL > Total time: 0 seconds > > -------------------------------------------------------------------------------- > *Version info:* > [EMAIL PROTECTED] ~ > $ ant -version > Apache Ant version 1.7.0 compiled on December 13 2006 > > java version 1.6 > -------------------------------------------------------------------------------- > * > QUESTION: > * > How can I run it so that I don't have to explicitely call ant with -lib??
This is due to classloader delegation issues - see the manual entry for the script task. This particular use case should work in ant 1.7.1. With ant 1.7.0 and java6 one can the javax.script interface. download the groovy-engine from https://scripting.dev.java.net/ <path id="groovy.path"> <fileset dir="${user.home}/apps/groovy-1.0/embeddable" includes="*.jar"/> <fileset dir="${user.home}/apps/jsr223-engines/groovy/build" includes="*.jar"/> </path> <script language="groovy" classpathref="groovy.path" manager="javax"> System.out.println("Hello world") </script> Please note that using a classpathref like this causes a new classloader to be created for each <script> usage. Peter > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]