ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 47003] Add to ant lib classpath from within project file
Date Thu, 09 Apr 2009 16:56:31 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=47003





--- Comment #2 from Martin von Gagern <Martin.vGagern@gmx.net>  2009-04-09 09:56:29
PST ---
Created an attachment (id=23476)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=23476)
Imrpove <classloader> task, always provide core loader

(In reply to comment #1)
> I think you are looking for the (undocumented) classloader task.

Almost, but not quite. <classloader> is a good first step, because it allows
modification of an existing class loader, in theory even the core class loader.

It fails to achieve this, though, because it identified the core task loader
using a reference name not used anywhere else. ComponentHelper.initTasks()
comes before <classloader> is executed, and already fixes the association
between standard tasks and the core class loader in use at that moment.
Furthermore, when started from the command line, ant by default has null as its
core class loader.

The attached patch addresses those issues. Firstly it changes Main.runBuild to
always provide an AntClassLoader as the core loader, so there will always be a
loader to which additional path elements can be added.

Secondly it changes the behaviour of the classloader task when name is omitted
or specified as "ant.coreLoader". In that case, the loader is not looked up by
reference, but instead the core loader of the project is used. This avoids
having to register a reference to this loader anywhere else.

I've tested using this simple build file:

<project default="demo">
  <target name="demo" description="Demonstrate bug 47003">
    <echo message="$${ant-junit.jar}='${ant-junit.jar}'"/>
    <classloader classpath="${ant-junit.jar}"/>
    <junit/>
  </target>
</project>

I had only ant.jar inside ant.library.dir, but had ant-junit.jar point at that
optional task. Before my patch, the build failed because of a missing
JUnitTask. With the patch applied, it failed due to missing junit.jar, emitting
an error message specific to a correctly loaded <junit> task.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Mime
View raw message