16 Jul 20:13
Re: [groovy-user] rootloader scope
From: Jochen Theodorou <blackdrag@...>
Subject: Re: [groovy-user] rootloader scope
Newsgroups: gmane.comp.lang.groovy.user
Date: 2008-07-16 18:13:29 GMT
Subject: Re: [groovy-user] rootloader scope
Newsgroups: gmane.comp.lang.groovy.user
Date: 2008-07-16 18:13:29 GMT
Kallin Nagelberg schrieb:
> I'm trying to write a groovy script that depends on some libraries in
> ../lib.
>
> I do this:
>
> def loader = this.class.classLoader.rootLoader
> def dir = new File('../lib')
> dir.eachFileMatch(~/.*\.jar$/) {
> loader.addURL(it.toURL())
> }
>
> but the class I'm looking for is not found by the script.
>
> However, when I now do an 'evaluate' of another script, that script has
> no problems finding classes from the libraries.
> Is there a way affect the classpath of the current script?
what you can not do is the following:
def loader = this.class.classLoader.rootLoader
loader.addURL("myJar.jar")
def x = Foo.x // Foo is from myJar.jar
this won't work, because at the point where the jar is added, the
compiler did already decide that Foo is no class. The script needs a
recompilation first. So any evaluate that follows will find the class,
simply because the script therein is compiled after rootloader was used.
I am sure we could find a nice solution if you would give an example of
the usage of the class, where it currently leads to a
MissingPropertyException
bye blackdrag
--
--
Jochen "blackdrag" Theodorou
The Groovy Project Tech Lead (http://groovy.codehaus.org)
http://blackdragsview.blogspot.com/
http://www.g2one.com/
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
RSS Feed