ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: Setting multiple properties in one condition
Date Fri, 13 Dec 2002 15:45:47 GMT
Notwithstanding the addition I'd like to see to your proposal Conor, this
one particular addition would take care nicely of my using case below:

    <!-- Set various properties according to the build mode -->
    <switch value="${buildmode}" caseinsensitive="true">
      <case value="debug">
        <property name="debug"         value="true" />
        <property name="configuration" value="Win32 Debug" />
        <property name="baseconfig"    value="shared.debug" />
      </case>
      <case value="release">
        <property name="debug"         value="false" />
        <property name="configuration" value="Win32 Release" />
        <property name="baseconfig"    value="shared" />
      </case>
      <default>
        <fail message="Invalid buildmode: ${buildmode}" />
      </default>
    </switch>

And I think it would also take care nicely of that common use-case:

  <!-- Set platform-specific properties -->
  <target name="set_platform_properties"
          depends="set_platform,
                   set_properties_windows,
                   set_properties_linux"/>

  <target name="set_platform">
    <condition property="os.is.windows">
      <os family="windows"/>
    </condition>
    <condition property="os.is.linux">
      <os name="Linux"/>
    </condition>
  </target>

  <target name="set_properties_windows" if="os.is.windows">
    <property name="platform" value="win32"/>
    <property name="can.jni" value="true"/>
    <available property="have.gcc"
               file="g++.exe"
               filepath="${env.Path}"
               type="file"/>
  </target>

  <target name="set_properties_linux" if="os.is.linux">
    <property name="platform" value="linux"/>
    <property name="can.jni" value="true"/>
    <available property="have.gcc"
               file="g++"
               filepath="${env.PATH}"
               type="file"/>
  </target>

So YES, very much worth committing AS-IS IMHO!!!

But of course, I'd also like to see the additions I wrote about earlier ;-)

Thanks, --DD

-----Original Message-----
From: Conor MacNeill [mailto:conor@cortexebusiness.com.au] 
Sent: Friday, December 13, 2002 8:57 AM
To: Ant Developers List
Subject: Setting multiple properties in one condition

I've done a quick change to allow condition to set multiple poperties. This 
is an example of how it can be used

   <target name="platform_props">
     <condition>
       <os family="unix"/>
       <propertyset>
         <property name="target" value="bash"/>
         <property name="extension" value="sh"/>
         <property name="shell" value="bash"/>
       </propertyset>
     </condition>
     <condition>
       <and>
         <os family="windows"/>
         <not>
           <os family="win9x"/>
         </not>
       </and>
       <propertyset>
         <property name="target" value="win2k"/>
         <property name="extension" value="bat"/>
         <property name="shell" value="cmd.exe"/>
       </propertyset>
     </condition>
   </target>

Worth committing? Thoughts?

Conor


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

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


Mime
View raw message