• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Adding an attribute to an ANT task

 
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
 
author
Posts: 5856
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.
 
Rancher
Posts: 43009
76
  • 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
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Peter & Ulf, those nuggets are really helpful..
 
Ranch Hand
Posts: 335
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[quote

Hi
On similar lines this prog is tried
The details are as under viz., buildfile,java prg and the succesful out put
Since you were able to get the attribute added ,please give the sample code to enable me for a try on this
similarly
Tanks
As
CRMK



=Arup Kumar]Thanks Peter & Ulf, those nuggets are really helpful..
 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 335
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Arup Kumar wrote: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




Hi
On similar lines this progm is tried
The details are as under viz., buildfile,java prg and the succesful out put
Since you were able to get the attribute added ,please give the sample code to enable me for a try on this
similarly
Tanks
As
CRMK

   


 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!