You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2008/12/23 23:56:03 UTC

DO NOT REPLY [Bug 46440] New: loadfile not overwriting property

https://issues.apache.org/bugzilla/show_bug.cgi?id=46440

           Summary: loadfile not overwriting property
           Product: Ant
           Version: 1.7.0
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core tasks
        AssignedTo: notifications@ant.apache.org
        ReportedBy: chad.retz@gmail.com


In the following build script, only the initial file (Test1.js) is loaded into
file.contents and nothing else is after that. The @{srcfile} does change
everytime:

<project name="js-merger" default="merge" basedir=".">    
    <!-- simple file appender -->
    <macrodef name="fileappend">
        <attribute name="srcfile" />
        <attribute name="destfile" />
        <sequential>
            <tstamp>
                <format property="current.time" pattern="MM/dd/yyyy hh:mm aa"
/>
            </tstamp>
            <echo file="@{destfile}" append="true"><![CDATA[
/**
 * Imported by js-merger from @{srcfile} at ${current.time}
 * --------------------------------------------------------
 */  
]]></echo>
            <loadfile property="file.contents" srcFile="@{srcfile}" />
            <echo message="${file.contents}" file="@{destfile}" append="true"
/>
        </sequential>
    </macrodef>
    <target name="merge">
        <property name="dest.file" value="Combined.js" />
        <!-- clean -->
        <delete file="${dest.file}" />
        <!-- write -->
        <fileappend srcfile="Test1.js" destfile="${dest.file}" />
        <fileappend srcfile="Test2.js" destfile="${dest.file}" />
        <fileappend srcfile="Test3.js" destfile="${dest.file}" />
        <fileappend srcfile="Test4.js" destfile="${dest.file}" />
        <fileappend srcfile="Test5.js" destfile="${dest.file}" />
    </target>
</project>

ant -version
Apache Ant version 1.7.0 compiled on December 13 2006

I haven't bothered to look at the source yet, but I will. Of course, I can work
around like by changing my macrodef to:

    <macrodef name="fileappend">
        <attribute name="srcfile" />
        <attribute name="destfile" />
        <sequential>
            <tstamp>
                <format property="current.time" pattern="MM/dd/yyyy hh:mm aa"
/>
            </tstamp>
            <echo file="@{destfile}" append="true"><![CDATA[
/**
 * Imported by js-merger from @{srcfile} at ${current.time}
 * --------------------------------------------------------
 */  
]]></echo>
            <loadfile property="file.contents.@{srcfile}" srcFile="@{srcfile}"
/>
            <echo message="${file.contents.@{srcfile}}" file="@{destfile}"
append="true" />
        </sequential>
    </macrodef>

It'd be worth mentioning in the manual if this is intentional behavior.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 46440] loadfile not overwriting property

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46440





--- Comment #2 from Matt Benson <gu...@yahoo.com>  2009-01-06 08:20:27 PST ---
Note that you may get some love from the scoped properties in Ant's trunk.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 46440] loadfile not overwriting property

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46440


Stefan Bodewig <bo...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX




--- Comment #1 from Stefan Bodewig <bo...@apache.org>  2009-01-06 01:36:35 PST ---
properties are more or less immutable, almost no Ant task changes the value of
an existing property and loadfile is no exception.  This is documented in the
manual page of the property task.

I've added a sentence to the manual in svn revision 731895 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=731895 ) - for "experienced"
Ant users, loadfile's behavior is expected.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.