• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Ant taskdef & classpath

 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Saloon Keeper
Posts: 25481
180
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can't you simply use the nested packageset element?
 
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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



Any help is appreciated, - Dave
 
author
Posts: 3281
8
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Without checking with the Ant docs, I see that you're effectively declaring the classpath twice. Which method do the docs recommend?
 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Martijn,

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.

Thanks, - Dave
 
You know it is dark times when the trees riot. I think this tiny ad is their leader:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic