You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Pascal Quesseveur <qu...@abaksystemes.fr> on 2006/12/04 16:19:19 UTC

Some problems extending ExecTask

Hello,

I wanted to be able to use conditional args with an exec-like task
(like the way compilerarg works in cc task). So I have done the
following things:

  - extend Commandline.Argument to Commandline.Xargument: that new
    class introduces 2 new attributes to manage if and unset
    conditions.
  - extend Commandline to XCommandLine to manage a vector of XArgument
  - extend ExecTask to set the new Commandline in the constructor

,----
|   cmdl = new XCommandLine();
`----

That works fine, but as the variable arguments in Commandline.java is
private I have to declare my own arguments variable in the extended
class XCommandline and rewrite all the methods that access that
variable. It would be more simple if the variable arguments was
protected. Is there any reason to restrict arguments visibility?

More annoying. If I want to use the new argument type in an Apply task
I have to manage correctly the Commandline.Marker. The
Commandline.Marker.getPosition() needs to access items in the
arguments vector. As I cannot override the private arguments variable
I have to rewrite the Commandline.Marker.getPosition() method to use
the new variable set in the extended class XCommandline. But it is not
possible: class Commandline.Marker is public but the constructor is
only package visible. The constructor should be protected to be able
to set a new Marker class subclassing Commandline.Marker. 

Once again there wouldn't any problems if arguments was protected.

What can I do to achieve my goal as I don't want to rewrite entirely
the Commandline and ExecuteOn tasks?

TIA.


-- 
Pascal Quesseveur, quesseveur@abaksystemes.fr


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


Re: Some problems extending ExecTask

Posted by Dominique Devienne <dd...@gmail.com>.
On 12/4/06, Pascal Quesseveur <qu...@abaksystemes.fr> wrote:
> I wanted to be able to use conditional args with an exec-like task
> (like the way compilerarg works in cc task).
> ...
> What can I do to achieve my goal as I don't want to rewrite entirely
> the Commandline and ExecuteOn tasks?

How about submitting a patch to Commandline with tests and docs,
instead of doing it on your side? Conditional arguments is useful in
general. You may have to wait for 1.7.1 to use it though.

Otherwise, provide an actual patch in cvs diff -u format to a new
enhancement request on bugzilla, to open up Commandline's internals.

--DD

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