You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Kim Hansen <ki...@i9.dk> on 2010/03/08 18:00:20 UTC

Strange property bug

Hi,

I am using <propertyfile> together with <property> to have a counter
that will save the number between invocations of ant. This has worked
for a year, but now it has an off by one error. My guess is that this
is a bug in 1.8.0 (I am using the current Debian unstable version).

The problem is that new.test.number is read as 2 when there is a 3 in
the properties file. It is show in the log I have pasted in the bottom
of this message.

Is this a bug?
Is it in the bug tracker?
Can anyone suggest a workaround that also will work with ant 1.7?

Regards,
Kim Hansen

========================

kim@raph:/tmp$ cat build.xml
<?xml version="1.0"?>
<project default="test">
  <target name="test">

    <property file="test.properties"/>
    <echo message="$${test.number} = ${test.number}"/>

    <propertyfile file="test.properties">
      <entry key="test.number" type="int" default="1" operation="+"/>
    </propertyfile>
    <exec executable="cat">
      <arg value="test.properties"/>
    </exec>
    <echo message="$${new.test.number} = ${new.test.number}"/>
    <property file="test.properties" prefix="new"/>
    <echo message="$${new.test.number} = ${new.test.number}"/>

  </target>
</project>
kim@raph:/tmp$ rm test.properties
kim@raph:/tmp$ ant
Buildfile: /tmp/build.xml

test:
     [echo] ${test.number} = ${test.number}
[propertyfile] Creating new property file: /tmp/test.properties
     [exec] #Mon, 08 Mar 2010 17:53:30 +0100
     [exec]
     [exec] test.number=2
     [echo] ${new.test.number} = ${new.test.number}
     [echo] ${new.test.number} = 2

BUILD SUCCESSFUL
Total time: 0 seconds
kim@raph:/tmp$ ant
Buildfile: /tmp/build.xml

test:
     [echo] ${test.number} = 2
[propertyfile] Updating property file: /tmp/test.properties
     [exec] #Mon, 08 Mar 2010 17:53:31 +0100
     [exec]
     [exec] test.number=3
     [echo] ${new.test.number} = ${new.test.number}
     [echo] ${new.test.number} = 2      ** THIS SHOULD BE 3 **

BUILD SUCCESSFUL
Total time: 0 seconds
kim@raph:/tmp$ cat test.properties
#Mon, 08 Mar 2010 17:53:31 +0100

test.number=3
kim@raph:/tmp$


-- 
Kim Hansen
Vadgårdsvej 3, 2.tv
2860 Søborg
Fastnet: 3956 2437  --  Mobil: 3091 2437

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


AW: Strange property bug

Posted by Ja...@rzf.fin-nrw.de.
BTW your 'exec cat' can be replaces by <concat>.

Jan 

>-----Ursprüngliche Nachricht-----
>Von: Antoine Levy Lambert [mailto:antoine@gmx.de] 
>Gesendet: Dienstag, 9. März 2010 02:32
>An: Ant Users List
>Betreff: Re: Strange property bug
>
>Hello Kim,
>
>I remember that a bug has already been filed and fixed in trunk.
>This was Bugzilla 48768.
>
>The commit fixing it was
>
>http://svn.apache.org/viewvc?rev=912610&view=rev
>
>
>Regards,
>
>Antoine
>
>Kim Hansen wrote:
>> Hi,
>>
>> I am using <propertyfile> together with <property> to have a counter
>> that will save the number between invocations of ant. This has worked
>> for a year, but now it has an off by one error. My guess is that this
>> is a bug in 1.8.0 (I am using the current Debian unstable version).
>>
>> The problem is that new.test.number is read as 2 when there is a 3 in
>> the properties file. It is show in the log I have pasted in 
>the bottom
>> of this message.
>>
>> Is this a bug?
>> Is it in the bug tracker?
>> Can anyone suggest a workaround that also will work with ant 1.7?
>>
>> Regards,
>> Kim Hansen
>>
>> ========================
>>
>> kim@raph:/tmp$ cat build.xml
>> <?xml version="1.0"?>
>> <project default="test">
>>   <target name="test">
>>
>>     <property file="test.properties"/>
>>     <echo message="$${test.number} = ${test.number}"/>
>>
>>     <propertyfile file="test.properties">
>>       <entry key="test.number" type="int" default="1" operation="+"/>
>>     </propertyfile>
>>     <exec executable="cat">
>>       <arg value="test.properties"/>
>>     </exec>
>>     <echo message="$${new.test.number} = ${new.test.number}"/>
>>     <property file="test.properties" prefix="new"/>
>>     <echo message="$${new.test.number} = ${new.test.number}"/>
>>
>>   </target>
>> </project>
>> kim@raph:/tmp$ rm test.properties
>> kim@raph:/tmp$ ant
>> Buildfile: /tmp/build.xml
>>
>> test:
>>      [echo] ${test.number} = ${test.number}
>> [propertyfile] Creating new property file: /tmp/test.properties
>>      [exec] #Mon, 08 Mar 2010 17:53:30 +0100
>>      [exec]
>>      [exec] test.number=2
>>      [echo] ${new.test.number} = ${new.test.number}
>>      [echo] ${new.test.number} = 2
>>
>> BUILD SUCCESSFUL
>> Total time: 0 seconds
>> kim@raph:/tmp$ ant
>> Buildfile: /tmp/build.xml
>>
>> test:
>>      [echo] ${test.number} = 2
>> [propertyfile] Updating property file: /tmp/test.properties
>>      [exec] #Mon, 08 Mar 2010 17:53:31 +0100
>>      [exec]
>>      [exec] test.number=3
>>      [echo] ${new.test.number} = ${new.test.number}
>>      [echo] ${new.test.number} = 2      ** THIS SHOULD BE 3 **
>>
>> BUILD SUCCESSFUL
>> Total time: 0 seconds
>> kim@raph:/tmp$ cat test.properties
>> #Mon, 08 Mar 2010 17:53:31 +0100
>>
>> test.number=3
>> kim@raph:/tmp$
>>
>>
>>   
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>

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


Re: Strange property bug

Posted by Antoine Levy Lambert <an...@gmx.de>.
Hello Kim,

I remember that a bug has already been filed and fixed in trunk.
This was Bugzilla 48768.

The commit fixing it was

http://svn.apache.org/viewvc?rev=912610&view=rev


Regards,

Antoine

Kim Hansen wrote:
> Hi,
>
> I am using <propertyfile> together with <property> to have a counter
> that will save the number between invocations of ant. This has worked
> for a year, but now it has an off by one error. My guess is that this
> is a bug in 1.8.0 (I am using the current Debian unstable version).
>
> The problem is that new.test.number is read as 2 when there is a 3 in
> the properties file. It is show in the log I have pasted in the bottom
> of this message.
>
> Is this a bug?
> Is it in the bug tracker?
> Can anyone suggest a workaround that also will work with ant 1.7?
>
> Regards,
> Kim Hansen
>
> ========================
>
> kim@raph:/tmp$ cat build.xml
> <?xml version="1.0"?>
> <project default="test">
>   <target name="test">
>
>     <property file="test.properties"/>
>     <echo message="$${test.number} = ${test.number}"/>
>
>     <propertyfile file="test.properties">
>       <entry key="test.number" type="int" default="1" operation="+"/>
>     </propertyfile>
>     <exec executable="cat">
>       <arg value="test.properties"/>
>     </exec>
>     <echo message="$${new.test.number} = ${new.test.number}"/>
>     <property file="test.properties" prefix="new"/>
>     <echo message="$${new.test.number} = ${new.test.number}"/>
>
>   </target>
> </project>
> kim@raph:/tmp$ rm test.properties
> kim@raph:/tmp$ ant
> Buildfile: /tmp/build.xml
>
> test:
>      [echo] ${test.number} = ${test.number}
> [propertyfile] Creating new property file: /tmp/test.properties
>      [exec] #Mon, 08 Mar 2010 17:53:30 +0100
>      [exec]
>      [exec] test.number=2
>      [echo] ${new.test.number} = ${new.test.number}
>      [echo] ${new.test.number} = 2
>
> BUILD SUCCESSFUL
> Total time: 0 seconds
> kim@raph:/tmp$ ant
> Buildfile: /tmp/build.xml
>
> test:
>      [echo] ${test.number} = 2
> [propertyfile] Updating property file: /tmp/test.properties
>      [exec] #Mon, 08 Mar 2010 17:53:31 +0100
>      [exec]
>      [exec] test.number=3
>      [echo] ${new.test.number} = ${new.test.number}
>      [echo] ${new.test.number} = 2      ** THIS SHOULD BE 3 **
>
> BUILD SUCCESSFUL
> Total time: 0 seconds
> kim@raph:/tmp$ cat test.properties
> #Mon, 08 Mar 2010 17:53:31 +0100
>
> test.number=3
> kim@raph:/tmp$
>
>
>   


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