----- Original Message -----
From: "Jeff Brown" <[EMAIL PROTECTED]>

>
> I have added an optional attribute to the <java> task called
> "systemassertions".  This is a boolean attribute to enable or disable
system
> assertions.  System assertions are a little simpler than "other"
assertions
> in that system assertions are either on or off.
>
> Non system assertions have finer grained control.  I can enable or disable
> assertions by package or class name.  I have addressed this with nested
> <disableassertions> and <enableassertions>.  Each of these can be used
with
> no attributes or with exactly one of either "package" or "class"
attributes.
> Here is a sample target...
>
>   <target name="test" depends="compile">
>     <java classname="Test"
>              classpath="classes"
>              systemassertions="on"
>              fork="yes">
>    <enableassertions package="com.packagetwo"/>
>    <enableassertions class="com.packageone.a.Test"/>
>    <disableassertions class="com.packagetwo.b.Test"/>
>     </java>
>   </target>
>
> The disabling and enabling of assertions have a cumulative effect.  The
> command line generated by the target above is...
>
>
c:\jdk1.4\jre\..\bin\java.exe -ea:com.packagetwo... -ea:com.packageone.a.Tes
> t -da:com.packagetwo.b.Test -esa -classpath D:\devel\assertTest\classes
Test
>
> This implementation involves three, one line methods added to Java.java (1
> for the systemassertions attribute, and one each for the enableassertions
> and disableassertions nested elements), and a new class that I have called
> AssertionArgument.  This class is a small wrapper around
> Commandline.Argument with two public methods (1 each for the optional
> package and class attributes).
>

I see and if you enable assertions for a package, it covers packages beneath
it -right?

Before adding it to the Java task I can see some issues

1. what happens when run on Java < 1.4? I would like the code to warn and
continue, whereas right now it will pass the args to java which will fail.

2. does forking need to be turned on for the option to work?

> Attached to this email are three files.
>
> java-assert.diff = the diffs to org.apache.tools.ant.taskdefs.Java
> AssertionArgument.java = new class mentioned above
> assertTest.zip = a simple test set for exercising the implementation
>
> There is a target in the test set called "test".  Take a look at that to
> play with the features.

I will try this on a 1.4 box when I get a chance (not till next week), to
see what
happens when asserts get raised, as of course we want to turn these into
build exceptions.

>
> btw... I looked around and I couldn't find anything very specific about
how
> to submit code for discussion.  I hope this is appropriate.  If not,
please
> offer up any comments.  The combined size of the attached files doesn't
seem
> to be much to me.  I hope I haven't bounced outside of protocol and
> generated any hostility!  :-)

This is roughly the way to do it. There are some guidelines -
http://jakarta.apache.org/ant/ant_task_guidelines.html
which provide a bit more detail. Submitting patches with [PATCH] in the
title and the patch in diff -u format is preferred.


-Steve

Reply via email to