• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding an attribute to an ANT task

 
Arup Kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to add a new attribute lets say category into the Junit task, which has other attributes like fork,haltonerror etc., I want to add this attribute and provide implementation to it, any idea which all source codes I should dig, I am using junit4.0, junit-ext-0.2.4.
1.)Is there a code or configuration in ANT which has list of all attributes of a task.
2.)For providing implementation to the new attribute in the junit task, do I need to modify the JunitTask, JunitRunner and classes of ant-junit.
Any good idea will be highly appreciated.

Thanks
Arup
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Each attribute of an ant task is stored in a field of the class that implements that ant task. So what you would want to do is find the class that implements the junit ant task, extend it, and add a field for your attribute. Then what you do with that attribute value is up to you.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's the source to a test task I wrote a while ago. It has a single attribute "arg1" for which a setter method needs to be provided. It also shows how to retrieve a property from the build file, and various calls to the project environment. You'd use it with <MyTask arg1="foobar"/>.

[ July 01, 2008: Message edited by: Ulf Dittmer ]
 
Arup Kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Peter & Ulf, those nuggets are really helpful..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic