ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Inger <ma...@sedonacorp.com>
Subject Re: [PATCH] Allow "if" and "unless" attributes on the Sequential and Parallel tasks
Date Fri, 24 Aug 2001 18:42:38 GMT
Stefan Bodewig wrote:

>Matthew,
>
>this belongs into the category of scripting like tasks - <if>,
><foreach> and so on - and has been declined by the committers as core
>tasks several times before, the last time in the discussion of
>features for Ant2.
>
>If you don't get any comments, that doesn't necessarily mean that
>everybody agrees with you, but may very well be a "we've been through
>that far too often".
>
>If I was to do something like what you want to accomplish with your
>task, I'd write an <if> task that extends ConditionBase and has two
>Sequential child elements <then> and <else> - and would chose the
>Sequential to execute based on the nested condition.  This would be
>trivial to write and give you much more power than the if/unless
>attributes ...  if I was.
>
>Cheers
>
>        Stefan
>
I'm not saying it has to be a catch all, but i don't see what the issue 
is with allowing
the simple if and unless attributes on the two above tasks.  Not 
allowing them forces
you to have to pollute your code with gads of extra targets that could 
be simplified
by simply allowing these attributes.

Being that they already exist on the "<target>" tag, I don't see how 
it's any different
to allow them the sequential and parallel tags.  Saying it doesn't 
belong in the core,
to me is not valid, since, as i mentioned above, it's already there for 
"target".

Say for instance have a target x, which does something very specific, 
say, extracting an
arbitrary archive, based on on file extension (.tar.gz, .tgz, .jar, 
.zip, etc....).  Now say you
want to optionally extract a set of archives based on whether or not the 
user has specified
certain flags in the property file, such as "install.tomcat".  You'd 
have to create an extra
target for each of these packages you wanted to install

consider the target:

    <target name="extract_archive">
        .....
    </target>

without the if/unless in sequential:

    <target name="maybe_extract_tomcat" if="install.tomcat.extract">
      <antcall target="extract_archive">
         <param name="archive.path" value="${install.tomcat.path}" />
      </antcall>
    </target>

    <target name="my_target">
      <antcall target="maybe_extract_tomcat" />
    </target>


to me, at the top level, there's no indication that this will only
happen if the install.tomcat.extract attribute is defined.  Not to mention,
you have 10 other archives you might want to extract, then you have 10
more targets to define.  If you allow the "if" and "unless", you could do
this:

    <target name="my_target">

       <sequential if="install.tomcat.extract">
          <antcall target="extract_archive">
             <param name="archive.path" value="${install.tomcat.path}" />
          </antcall>
      </sequential>

    </target>

to me, the second form is much clearer as to what is going on, and is 
not any
more of a scripting idea than it is inside of a target attribute.

any thoughts? comments.

-- 
Matt Inger (matt.inger@sedonacorp.com)
Sedona Corporation
455 S. Gulph Road, Suite 300
King of Prussia, PA 19406
(484) 679-2213
"Self-respect - the secure feeling that no one,
 as yet, is suspicious." -H.L. Mencken 




Mime
View raw message