One of the big changes for 1.6 will be the ComponentHelper, and the creation of tasks and types just before their use. In ant1.5 some of the tasks were created before use, but an attempt to create the task was made when the task was read. If a task definition
was available, then the task would be created at parse time. If not - it'll be created before use.
In addition, all core and optional tasks were instantiated ( Class.forName ) at startup. That resulted in 2-3 seconds wasted in creation of tasks we'll never use. Most of the time was actually spent processing stack traces for the optional tasks with missing dependencies.
There are few benefits of doing Class.forName() just before executing:
* we only create the tasks that we need. 2-3 seconds out of each build may look very little.
* with help from the classloader task, we can push jars into the loader ( like junit.jar) and then optional tasks would work even if their deps are not in ant/lib
The ComponentHelper provides 2 hook mechanisms: you can replace the default helper by setting ant.componentHelper reference ( preferably before calling ant), and you can chain a custom helper. This can be done from withing a normal ant task.
The hooks allow arbitrary "antlibs" to be hooked into ant.
What's missing:
* pass the namespace to the task, so antlibs can use it
* implement a default antlib using the namespace as a java package.
So far I've seen no major backward compatibility problems - gump seems happy
and all projects I use build without problems ( well, many times they don't - but not because of ant ).
Technical stuff
Saturday, January 11, 2003
Ant: delayed task creation
Friday, January 10, 2003
import in ant
Now that the basic <import> has been added, there are few "small" details to settle down - before people start using it.
My opinion is that import should work well for existing build files - that would mean basedir must be relative to the build file ( by default ). It is obviously possible to customize the basedir for the imported.
In any case - if we want different imported files to use different basedirs, we need to keep track of the imported file location in each element. So regardless of the final decision, that's something to work on.
Jose Alberto seems to believe that only files specifically written for import would work - or that the default should support this use case.
In parallel, Alexey Solofnenko posted info about a preprocessor that supports a similar behavior. It's very intersting, but I don't think it'll help us too much - import is going to be a core task.
Properties are as usual a special case. It is possible to rename properties and support a prefix to avoid naming conflicts. This could be done with some special code in PropertyHelper or in the Property task itself - by looking at the current import environment.
The common use case of multiple build files working togheter doesn't seem to benefit from that - you want properties to be consistent, without big surprises. The imutability of properties is already a surprise for many people.