

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
6 messages in org.apache.ant.devCoreLoader not used for antlib & type...| From | Sent On | Attachments |
|---|---|---|
| Gilles Scokart | Nov 19, 2008 1:08 pm | |
| Stefan Bodewig | Nov 19, 2008 9:29 pm | |
| Gilles Scokart | Nov 20, 2008 1:06 am | |
| Gilles Scokart | Nov 26, 2008 7:15 am | |
| Stefan Bodewig | Nov 26, 2008 7:21 am | |
| Gilles Scokart | Nov 26, 2008 8:06 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | CoreLoader not used for antlib & typedef [Re: Launching unit test of antunit] | Actions |
|---|---|---|
| From: | Gilles Scokart (gsco...@gmail.com) | |
| Date: | Nov 19, 2008 1:08:18 pm | |
| List: | org.apache.ant.dev | |
It took me quiet a lot of time to find the way to build antunit, so I wanted to understand the root cause of the problem (and lost a few hours more ;-) )
The problem actually comes from the fact the the antunit unit test creates projects and execute build using BuildFileTest. However, the created project are not aware of the classpath used by the unit test. I was thus thinking to provide this classpath using the project.setCoreLoader. But that didn't worked. Indeed, the coreLoader is not used when declaring antlib.
The antunit unit tests use 2 aproach to define type : the antlib uri, and a typedef.
Making use of the coreLoader when using the antlib seems to have minor impact, but for the typedef declaration, I feel I should update Project.createClassLoader, which might have a wide impact.
Here is the patch I end up :
Index: src/tests/junit/org/apache/tools/ant/BuildFileTest.java =================================================================== --- src/tests/junit/org/apache/tools/ant/BuildFileTest.java (revision 687833) +++ src/tests/junit/org/apache/tools/ant/BuildFileTest.java (working copy) @@ -282,6 +282,7 @@ logBuffer = new StringBuffer(); fullLogBuffer = new StringBuffer(); project = new Project(); + project.setCoreLoader(this.getClass().getClassLoader()); project.init(); File antFile = new File(System.getProperty("root"), filename); project.setUserProperty("ant.file" , antFile.getAbsolutePath()); Index: src/main/org/apache/tools/ant/ComponentHelper.java =================================================================== --- src/main/org/apache/tools/ant/ComponentHelper.java (revision 687833) +++ src/main/org/apache/tools/ant/ComponentHelper.java (working copy) @@ -831,6 +831,9 @@ definer.setProject(project); definer.init(); definer.setURI(uri); + //anlib declared by their namespace only should be searched in the coreLoader + //when specified + definer.setAntlibClassLoader(project.getCoreLoader()); //there to stop error messages being "null" definer.setTaskName(uri); //if this is left out, bad things happen. like all build files break Index: src/main/org/apache/tools/ant/Project.java =================================================================== --- src/main/org/apache/tools/ant/Project.java (revision 687833) +++ src/main/org/apache/tools/ant/Project.java (working copy) @@ -335,8 +335,11 @@ * @return an appropriate classloader. */ public AntClassLoader createClassLoader(Path path) { - return new AntClassLoader( - getClass().getClassLoader(), this, path); + ClassLoader cl = getCoreLoader(); + if (cl==null) { + cl = getClass().getClassLoader(); + } + return new AntClassLoader(cl, this, path); }
With that, antunit unit test could be executed with : ant test I still have to run the test suite in ant itself (and seeing the time I took to run the test in antunit I have some fears;-) In parallel I wanted to ask feedback for such sensible change for which I can't really mesure all the impact.
2008/11/17 Stefan Bodewig <bode...@apache.org>:
On 2008-11-15, Gilles Scokart <gsco...@gmail.com> wrote:
The only workaround.I found is :
ant -lib build/classes\;build/test-classes test
I use two -libs, but otherwise I do exactly the same.
Stefan
-- Gilles Scokart







