ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Fetzer <elstonk...@yahoo.com>
Subject Re: Reset BuildNumber
Date Fri, 01 May 2009 16:24:18 GMT
Yeah, the macrodef was overkill, huh.  How about:

  <target name="main">
    <if>
      <equals arg1="${major.increment}" arg2="true"/>
      <then>
        <buildnumber file="major.number"/>
        <propertycopy name="major.number" from="build.number"/>
        <property file="minor.number"/>
        <replace file="${minor.number}" token="build.number=${build.number}" value="build.number=0"/>
        <property file="minor.number"/>
      </then>
      <else>
        <property file="major.number"/>
        <propertycopy name="major.number" from="build.number"/>
        <buildnumber file="minor.number"/>
      </else>
    </if>
    <property name="full.buildnumber" value="${major.number}.${minor.number}"/>
  </target>



________________________________
From: Eric Fetzer <elstonkers@yahoo.com>
To: Ant Users List <user@ant.apache.org>
Sent: Friday, May 1, 2009 10:17:24 AM
Subject: Re: Reset BuildNumber

So, here's how I'd do it.  Is there a better way?

  <target name="main">
    <if>
      <equals arg1="${major.increment}" arg2="true"/>
      <then>
        <buildnumber file="major.number"/>
        <propertycopy name="major.number" from="build.number"/>
        <property file="minor.number"/>
        <setPropertyInFile
            var.filename="${minor.number}"
            var.varname="${build.number}"
            var.oldvalue="${build.number}"
            var.newvalue="0"
        />
      </then>
      <else>
        <property file="major.number"/>
        <propertycopy name="major.number" from="build.number"/>
        <buildnumber file="minor.number"/>
      </else>
    </if>
    <property name="full.buildnumber" value="${major.number}.${minor.number}"/>
  </target>

  <macrodef name="setPropertyInFile">
    <attribute name="var.filename"/>
    <attribute name="var.varname"/>
    <attribute name="var.oldvalue"/>
    <attribute name="var.newvalue"/>
    <sequential>
      <replace file="@{var.filename}" token="@{var.varname}=@{var.oldvalue}" value="@{var.varname}=@{var.newvalue}"/>
    </sequential>
  </macrodef>




________________________________
From: Eric Fetzer <elstonkers@yahoo.com>
To: Ant Users <user@ant.apache.org>
Sent: Friday, May 1, 2009 9:31:50 AM
Subject: Reset BuildNumber

What is the prescribed method of setting properties in a property file?  Specifically, I'm
speaking of a file that keeps track of one of the build numbers.  Here's a simple example
with what I'd like to do in it:

  <target name="main">
    <if>
      <equals arg1="${major.increment}" arg2="true"/>
      <then>
        <buildnumber file="major.number"/>
        <propertycopy name="major.number" from="build.number"/>
        <!--This would be great, but is my imagination, how would it really work?-->
        <buildnumber file="minor.number" reset="true"/>
        <propertycopy name="minor.number" from="build.number"/>
      </then>
      <else>
        <property file="major.number"/>
        <propertycopy name="major.number" from="build.number"/>
        <buildnumber file="minor.number"/>
        <propertycopy name="minor.number" from="build.number"/>
      </else>
    </if>
    <property name="full.buildnumber" value="${major.number}.${minor.number}"/>
  </target>

Thanks,
Eric


      
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message