ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: ANT 1.7 features suggestion
Date Wed, 05 May 2004 15:01:08 GMT
> From: Jose Alberto Fernandez [mailto:jalberto@cellectivity.com]
> 
> -100 :-\
> 
> IMHO, if/unless in targets are one of the worst features we have in the
> ANT language.

I'm completely at the other end of the spectrum! I think if/unless, and
extension of these that I coded up in my custom tasks/types, make the build
a lot easier to read, and are absolutely essential to Java development with
a lot of native code underneath like here.

It all comes down again to some pundits who do not like features like
if/unless on all tasks and want to save the rest of the Ant community from
themselves by preventing them to use this idiom, which I prefer 100 times
better than <if/> (to use the same hyperbole you used Jose Alberto ;-)

To prove my point (or show the world how bad my builds are, I don't know), I
quickly compiled a bunch of snippets from my build scripts that show
extensive use of if/unless or more precisely ifTrue/unlessTrue/os/osFamily,
which are just extended conditions of the same sort (I could never quite
accept the if/unless way of testing just property existence rather than
value!).

I know very well of <ac:if>, <ac:switch>, etc... and even used them for a
time, but using inline attribute conditions is tons better IMHO.

So to make a long story short, since I doubt we'll get to any sort of
consensus on this issue, I would propose that Ant implements a hook at the
task or better yet execution engine (that turns UE into instantiated types)
so that some build writers like me can provide custom implementation of that
hook to add conditional aspects throughout Ant (basically custom OAP).

Since Ant 1.6+ is now fully dynamic, one can envision that the Ant runtime
would examine all UE's attributes and interrogate a hook, if any, passing
the UE's attributes to it, to find out if this particular UE, be it a task,
a type, or a nested elements of either, is to be passed to it's parent (if a
nested element) or instantiated (if a task/type). If the hook says no, then
it's as if that XML tag never existed in the build file!

If this was possible, Ant would remain as-is to you, but I could implement
that hook to make globally available what I currently have to sprinkle
everywhere in my own code, and in wrappers of Ant tasks when I need it for
Ant tasks. You use <ac:if> if that suits you, and I (and quite a few others
since if/unless on everything has been requested and even submitted by a few
people already) can use inline condition attributes.

I'm not trying to attack anyone here, although I'm sure my post is
controversial at best, but this if/unless issue has been lingering long
enough it seems to me, and if the Ant committers persists in refusing it,
please at least provide me a framework so I can myself get a rope to hang
myself with.

I am also an experienced Ant user working on big builds Jose Alberto, and
yet we still cannot be farther apart on this issue. I guess diversity is
what makes life interesting ;-) But let's break the current dead-lock and
move on. --DD


    <bm:echoproperty name="jar.classpath" ifTrue="${verbose}" />

    <echo ifTrue="${verbose}"
          xmlns="antlib:com.lgc.buildmagic">
      <path refid="modulepath" />
      <path refid="classpath" />
      <path refid="systempath" />
      <text>Building ${ant.project.name}</text>
    </echo>

  <buildpath id="buildpath"
             xmlns="antlib:com.lgc.buildmagic">
    <element location="Plugin" ifTrue="${plugin}" />
    <element location="Core" />
  </buildpath>

   <macrodef name="compile">
      <attribute name="jaxb" default="false" />
      <attribute name="register" default="false" />

      <sequential>
        <!-- Compile the XML schemas into Java code, if any -->
        <mkdir dir="build/generated/@{name}" />
        <bm:jaxb destDir="build/generated/@{name}" ifTrue="@{jaxb}"
                 readOnly="true" strictValidation="true"
                 xjcjar="tools/jwsdp-1.1/jaxb-1.0/lib/jaxb-xjc.jar">
          ...
        </bm:jaxb>

        <!-- Register services of that library, if any -->
        <register dir="build/classes/@{name}"
                  excludes="**.test.*Test"
                  ifTrue="@{register}">
          ...
        </register>
      </sequential>
    </macrodef>

    <ds:serversinfo id="blah">
      <ds:upload>
        <ds:primaryserver host="somehost.lgc.com">
          <ds:basedir location="\\%host%\dsbuilds" osFamily="windows" />
          <ds:basedir location="/net/%host%/blah/dsbuilds/${os}"
                      osFamily="unix" unlessTrue="${denver}" />
          <ds:basedir location="/network/%host%/blah/dsbuilds/${os}"
                      osFamily="unix" ifTrue="${denver}" />
        </ds:primaryserver>
      </ds:upload>

      <ds:download>
        <ds:server host="${defaultServerHost}">
          <ds:baseurl url="http://%host%/dsbuilds" osFamily="windows" />
          <ds:baseurl url="http://%host%/dsbuilds/${os}" osFamily="unix" />
        </ds:server>
      </ds:download>
    </ds:serversinfo>

    <module ... xmlns="antlib:com.lgc.decisionspace">
      ...
      <systempath>
        <element location="${bin.dir}" />
        <elementgroup ifTrue="${msdev}">
          <element location="plugin1/bin/${msdev.config}" />
          <element location="plugin2/bin/${msdev.config}" />
          <element location="plugin3/bin/${msdev.config}" />
          <element location="plugin4/bin/${msdev.config}" />
        </elementgroup>
      </systempath>
    </module>

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


Mime
View raw message