File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes Adding an attribute to an ANT task Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Adding an attribute to an ANT task" Watch "Adding an attribute to an ANT task" New topic
Author

Adding an attribute to an ANT task

Arup Kumar
Greenhorn

Joined: Jun 19, 2008
Posts: 5
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

Joined: May 14, 2008
Posts: 5823
    
    7

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.


JBoss In Action
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41587
    
  54
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 ]

Ping & DNS - my free Android networking tools app
Arup Kumar
Greenhorn

Joined: Jun 19, 2008
Posts: 5
Thanks Peter & Ulf, those nuggets are really helpful..
 
Consider Paul's rocket mass heater.
 
subject: Adding an attribute to an ANT task