Runtime ClassLoader Instead of Build ClassLoader

View: New views
4 Messages — Rating Filter:   Alert me  

Runtime ClassLoader Instead of Build ClassLoader

by Robert Fischer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'd like to call a Java class, but use the runtime classloader instead of the build classloader for
resolving and executing the class.  Is there an easy way to do this?

The wider background: I'm executing org.jruby.Main#main to execute JRuby scripts.  I'd like those
scripts to use the runtime classloader so I don't have to keep building up the
buildscript.dependencies closure.

--
~~ Robert Fischer, Smokejumper IT Consulting.
Enfranchised Mind Blog http://EnfranchisedMind.com/blog

Grails Expert Retainer Services
http://smokejumperit.com/grails-retainer/

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Runtime ClassLoader Instead of Build ClassLoader

by Adam Murdoch-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



Robert Fischer wrote:
> I'd like to call a Java class, but use the runtime classloader instead
> of the build classloader for resolving and executing the class.  Is
> there an easy way to do this?

Depends what do you mean by the 'runtime classloader'. What stuff do you
need to be visible (or not visible)?

--
Adam Murdoch
Gradle Developer
http://www.gradle.org


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Runtime ClassLoader Instead of Build ClassLoader

by Robert Fischer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'd like to provide the dependencies specified in the "dependencies" closure, not by the stuff in
buildscript.dependencies.

~~ Robert Fischer, Smokejumper IT Consulting.
Enfranchised Mind Blog http://EnfranchisedMind.com/blog

Grails Expert Retainer Services
http://smokejumperit.com/grails-retainer/


Adam Murdoch wrote:

>
>
> Robert Fischer wrote:
>> I'd like to call a Java class, but use the runtime classloader instead
>> of the build classloader for resolving and executing the class.  Is
>> there an easy way to do this?
>
> Depends what do you mean by the 'runtime classloader'. What stuff do you
> need to be visible (or not visible)?
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Runtime ClassLoader Instead of Build ClassLoader

by Adam Murdoch-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



Robert Fischer wrote:
> I'd like to provide the dependencies specified in the "dependencies"
> closure, not by the stuff in buildscript.dependencies.
>

There's no built-in method for doing this. It's quite easy to script it
up, however:

ClassLoader loader = new URLClassLoader(configurations.runtime.collect {
it.toURI().toURL() } as URL[])

It might be a good thing to be able to do something like:

cl = configurations.runtime.getAsClassLoader()
cl = configurations.runtime as ClassLoader

or possibly just

cl = new URLClassLoader(configurations.runtime as URL[])

> ~~ Robert Fischer, Smokejumper IT Consulting.
> Enfranchised Mind Blog http://EnfranchisedMind.com/blog
>
> Grails Expert Retainer Services
> http://smokejumperit.com/grails-retainer/
>
>
> Adam Murdoch wrote:
>>
>>
>> Robert Fischer wrote:
>>> I'd like to call a Java class, but use the runtime classloader
>>> instead of the build classloader for resolving and executing the
>>> class.  Is there an easy way to do this?
>>
>> Depends what do you mean by the 'runtime classloader'. What stuff do
>> you need to be visible (or not visible)?
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

--
Adam Murdoch
Gradle Developer
http://www.gradle.org


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email