I have a running but ugly build with a taskdef with classpath in it:
Before giving it to anybody else I wanted to make it more portable, so I used a property for the location of the class file. For now I have the properties defined at the top of the file. Now the taskdef says
It appears that the taskdef is being evaluated before the properties because Ant-v says
Is that really the problem? Can I force the order?
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Ant file property definitions are done from top to bottom, and the first definition is the one that wins. In the case of taskdefs, the classpath of the task definition is set when the task is defined, then when the task is executed (further down the build.xml) any classpath for the execution of the task which is specified for the task is set. It's occasionally confusing that there are 2 different classpaths at work, but it makes sense when you sort things out.
In any case, for both classpaths, the details become frozen in stone at the time they are defined and do not change thereafter.
I hope that's what you were asking about, and I hope my reply makes sense!
An IDE is no substitute for an Intelligent Developer.
I'm a little bit confused, because in your taskdef you seem to have a property "folder", but the Ant error message talks about a property "saxmanfolder". What am I missing? Can you show us more of your Ant code?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Joined: Jan 29, 2003
D'oh! I'll check those names when I get home. I might have changed that first one to anonymize it a bit but ... I don't think so. I was reluctant to share the whole script because I definitely "paved the cowpath" and automated a bunch of steps that should have been elminiated instead.
The sequence should be good, I think ... the properties are all set at the top of the file, the task definition further down, task execution immediately after that.
BTW: The task generates a list of all packages in the source directory for the benefit of JavaDoc. There must be a standard way to do this, no? Here's from the old all-hard-coded script:
Joined: Jul 11, 2001
Can't you simply use the nested packageset element?
Tim Holloway wrote:Ant file property definitions are done from top to bottom, and the first definition is the one that wins. In the case of taskdefs, the classpath of the task definition is set when the task is defined, then when the task is executed (further down the build.xml) any classpath for the execution of the task which is specified for the task is set. It's occasionally confusing that there are 2 different classpaths at work, but it makes sense when you sort things out.
Hi Tim, I wanted to ask about how to set the classpath when the task is executed. Right now, I'm getting a NoClassDefFoundError when I try and run my custom task but this is mostly because I don't know how to set the classpath when I run the task. I do it like so
I'm not able to find any documentation on those two things online, but as far as I can tell, they do the same thing (I've tried running the task setting the attribute and then another variation setting the child element -- same result).
Can you address Tim's comment about the two classapaths (when task is defined and when task is executed)? It seems that both the things you were asking me about are related to defining the task but not executing the task.