ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 47035] New: Property expansion in macro attributes and elements
Date Wed, 15 Apr 2009 12:20:39 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=47035

           Summary: Property expansion in macro attributes and elements
           Product: Ant
           Version: 1.7.1
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Core
        AssignedTo: notifications@ant.apache.org
        ReportedBy: csaba.juhos@gmail.com


Hi,

I'm using Launch4j to wrap a JAR into a windows executable:

<launch4j>
    <config>
        <jre>
            <opt>-Xms${java.initial.memory}m</opt>
        </jre>
    </config>
</launch4j>

The problem is that the "opt" element doesn't expand properties.
It seems that the developers didn't take care to expand them explicitly.
(http://ant.apache.org/ant_task_guidelines.html)

I wrapped the task into a macro like this:

<macrodef name="create-exe">
    <attribute name="java-initial-memory"/>
    <sequential>
        <launch4j>
            <config>
                <jre>
                    <opt>-Xms@{java.initial.memory}m</opt>
                </jre>
            </config>
        </launch4j>
    </sequential>
</macrodef>

And called it like:

<create-exe java-initial-memory="${java.initial.memory}"/>

in hope that the property will be expanded before being passed to the template.
It wasn't :(



I know that this is the expected behavior. What I'm asking for here is an
option to expand macro arguments before passing them to the template.



After some consideration I came to the conclusion that the best solution would
be to add an optional attribute "expand" to the "element" and "attribute" child
elements of macrodef.

Modified example:

<macrodef name="create-exe">
    <attribute name="java-initial-memory" expand="true"/>
    <attribute name="java-maximum-memory" expand="true"/>
    <element name="vm-options" optional="true" expand="true"/>
    <sequential>
        <launch4j>
            <config>
                <jre>
                    <opt>-Xms@{java.initial.memory}m</opt>
                </jre>
            </config>
        </launch4j>
    </sequential>
</macrodef>

<create-exe java-initial-memory="${java.initial.memory}"
            java-maximum-memory="${java.maximum.memory}">

    <vm-options>
        <opt>${another.vm.option}</opt>
    </vm-options>
</create-exe>

"expand" should be a boolean variable with a default value of "false". This
wouldn't break any existing code.

Another use case I'm seeing is the following:

<macrodef name="create-exe">
    <attribute name="expand-options" default="true"/>
    <attribute name="java-initial-memory" expand="@{expand-options}"/>
    <attribute name="java-maximum-memory" expand="@{expand-options}"/>
    <element name="vm-options" optional="true" expand="@{expand-options}"/>
...

This would make the macro more flexible.



In case this isn't possible to implement, I'm sorry for my ignorance, I'm not
familiar with Ant's internals at all.

Thank you,
Csabi

P.S.: I filed a bug against Launch4j:

   
https://sourceforge.net/tracker/?func=detail&aid=2764888&group_id=95944&atid=613100

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

Mime
View raw message