ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <ste...@apache.org>
Subject Re: Abusing the BuildListener
Date Fri, 14 Jul 2006 11:48:02 GMT
Henri Yandell wrote:
> On 7/13/06, Steve Loughran <stevel@apache.org> wrote:
> 
>> Henri Yandell wrote:
>> > I suspect this isn't what was intended for the build listener, but
>> > I've been using it to override the build.xml for <junit> tasks. In
>> > startTask I ensure that haltonerror and haltonfailure are set to
>> > false. Next up I want to ensure there is always a <formatter
>> > type="xml"/>, but adding a new task in seems a lot more painful than
>> > simply modifying the existing objects.
>> >
>> > Here's a chunk of my code:
>> >
>> > UnknownElement proxy = new UnknownElement("formatter");
>> > proxy.setNamespace("");
>> > proxy.setQName("formatter");
>> > proxy.setTaskName("formatter");
>> > 
>> proxy.setTaskType("org.apache.tools.ant.taskdefs.optional.junit.FormatterElement");

>>
>> >
>> > proxy.setProject(task.getProject());
>> > proxy.setOwningTarget(task.getOwningTarget());
>> > RuntimeConfigurable fc = new RuntimeConfigurable( proxy, "formatter");
>> > fc.setAttribute("type", "xml");
>> > rc.addChild(fc);   // rc is the RuntimeConfig for the junit task
>> >
>> > When I build with a listener that contains this, I get:
>> >
>> > Class org.apache.tools.ant.UnknownElement doesn't support the "type"
>> > attribute.
>>
>> have you not thought of using <presetdef> to define a new junit with the
>> right defaults?
> 
> 
> Didn't know it existed :)
> 
> Reading the presetdef manual page, it sounds like it's not what I want
> because it only sets defaults and not mandated values. I don't want to
> allow the build.xml to change the settings.
> 
> My ant script calls other ant scripts, so would be worried that the
> presetdef wouldn't survive down into the <ant> call. Of course I'm
> assuming that I can get the listener into the <ant> call in some way
> :)

Well, if you are being really ruthless, you could subclass junit, and 
have a distro with a modified properties file defining the junit typedef 
and pointing at your subclass. The subclass gets to enforce its own rules...


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message