ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: Property element of ant task needs an "if"
Date Fri, 12 Jul 2002 15:29:44 GMT
Actually, I've asked for a <propertyset> datatype before, in relation to a
set of (runtime) properties I needed in more than one place (<java> and
<junit>). People said 'just use an entity include', which I do right now,
but it's not a good options.

A <propertyset> would be a collection of named properties (it don't care
about the properties values, it's only role is to reference a bunch of
properties). Here's how I would see it:

<project ...>

  <!-- Declares properties directly belonging to a propertyset.
       The properties are available as if they had been declared
       at the top level. -->
  <propertyset id="ps1">
    <property name="p1" value="x" />
    <property name="p2" value="y" />
  </propertyset>

  <property name="p3" value="z" />

  <!-- Can nest property sets.
       Alternate way to had a property to a property set. -->
  <propertyset id="ps2">
    <propertyset refid="ps1" />
    <propertyref name="p3" value="y" />
  </propertyset>

  <!-- This ones actually debatable... Might be better to only
       be able to inject all the properties of a properties file
       inside a propertyset by declaring it inside a <propertyset>
       element? Or <propertyfile> be used instead??? -->
  <property file="somefile.properties"
            propertysetrefs="ps1, ps2" />

  <!-- Various uses of this set of properties -->
  <target ...>
    <java ...>
      <propertyset refid="ps2" />
    </java>
  </target>

  <target ...>
    <junit ...>
      <propertyset refid="ps2" />
    </java>
  </target>

  <target ...>
    <ant ... inheritAll="false">
      <property name="p1" value="XXX" />
      <propertyset refid="ps2" />
    </java>
  </target>

</project>

Properties are oblivious to whether they belong to 0, 1, many propertysets.
Propertysets can overlap.
Explicitly declared <property>s in <ant> would override the one referenced
in the property set (in the child Project), but not in <junit>/<java>,
respecting normal property override rules.

This would solve the <ant inheritAll="false"> issue discussed here, and
would make my build file really clean!

Can someone please tell me why this shouldn't be in ANT???? --DD

-----Original Message-----
From: Diane Holt [mailto:holtdl@yahoo.com] 
Sent: Thursday, July 11, 2002 8:48 PM
To: Ant Users List
Subject: Re: Property element of ant task needs an "if"

--- Scott Ellsworth <scott@alodar.com> wrote:
> As an alternative, if we had a nested "inheritproperty" element that 
> forwarded just the property named, I could accomplish this end.

But that wouldn't really be the same as your proposed if/unless addition,
would it? If it's just passing the named property, then it's not allowing
for it to take on a new value, as it did in your if/unless example, where
you explicitly set the value to "orange". Also, you should keep in mind,
when dealing with this stuff, that there's the whole
anything-defined-on-the-command-line thing...

If you are going to try and do an <inheritproperty> element, you may want
to consider adding a <propertyset> datatype, so you wouldn't have to list
all the same properties to pass every time.

In the meantime, you can always just fall back on the <if> task:
  <target name="juice">
    <if>
      <isset property="juice"/>
      <then>
        <ant antfile="blend.xml" target="blendit" inheritall="false">
          <property name="juice" value="orange"/>
        </ant>
      </then>
      <else>
        <ant antfile="blend.xml" target="blendit" inheritall="false"/>
      </else>
    </if>
  </target>

A bit long-winded, but it does get you there.

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com

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

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


Mime
View raw message