ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 53723] New: [Patch] Local task: local by prefix, all local, New: global task
Date Wed, 15 Aug 2012 07:32:50 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=53723

          Priority: P2
            Bug ID: 53723
          Assignee: notifications@ant.apache.org
           Summary: [Patch] Local task: local by prefix, all local, New:
                    global task
          Severity: enhancement
    Classification: Unclassified
                OS: Linux
          Reporter: rks-ant@gmx.de
          Hardware: PC
            Status: NEW
           Version: unspecified
         Component: Core tasks
           Product: Ant

Created attachment 29236
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=29236&action=edit
Patch with improved local taskm the new global task and antunit test

Recently I had the need to better control local properties within
a macrodef.

1) All properties with a given prefix should be local.
   Needed for:
     <xmlproperty file="@{src}"  prefix="prefix" />

2) All properties in the current scope should be local.

3) Create a way to exclude a certain property from the
   extensive local restriction defined by the previous points.


Examples:

    <sequential>
        <!-- all properties with the prefix "local." are local -->
        <local prefix="local" />
    </sequential>

    <sequential>
        <!-- all properties in this sequential are local -->
        <local/>
    </sequential>

    <sequential>
        <!-- all properties in this sequential are local ... -->
        <local/>
        <!-- ... except the property gFoo -->
        <global name="gFoo" />
    </sequential>


Updated task "local": 

1) New attribut "prefix": All properties with the given prefix are handled as
   local properties. 
   - If the prefix is empty a BuildException is thrown.
   - If the prefix does not end with a "." one is appended.

2) Without any attribute, all properties are local.

Usage:

     <!-- foo is a local property - like today -->
     <local name="foo" />

     <!-- All properties with the prefix "local." are local -->
     <local prefix="local" />

     <!-- all properties are local -->
     <local/>


New task "global":

Well, if I can restrict scope like that, it might be that I need a way to
declare all but a special property as local. So I introduced the task global.
The global task is only useful with a accompanied local task.  Otherwise it
has no effect.

Attributes:

   name: The name of the global property
   prefix: All properties with the given prefix are handled as
       global properties. 
       - If the prefix is empty a BuildException is thrown.
       - If the prefix does not end with a "." one is appended.

Usage:
     <!-- all properties are local, except "global.foo" -->
     <local/>
     <global name="global.foo" />

     <!-- all properties are local, except those prefixed with "global." -->
     <local/>
     <global prefix="global" />


Note: "global" does not really mean global. In the following example
"foo" is global for the inner sequential but is marked local in the
outer sequential. So it is not visible outside the outer sequential.
>From this point of view the name "global" is not 100% correct.

    <target ...

        <sequential>
            <local name="foo" />
            <sequential>
                <!-- all but foo are local -->
                <local all="true"/>
                <global name="foo" />
                <property name="foo" value="isset" />
            </sequential>
            <!-- property foo is set -->
        </sequential>
        <!-- property foo is NOT set -->

    </target>


Some strange usage:

The global task always overrules a local task. Independant of the order.
Should this be changed? How?

    <target name="strange">
        <sequential>
            <!-- Property 'strange' is local -->
            <local name="strange" />
            <property name="strange" value="bar" />
            <echo message="inner local strange: ${strange}" />

            <!-- Now property 'strange' is global -->
            <global name="strange" />
            <echo message="1. inner global strange: ${strange}" />
            <property name="strange" value="bar2" />
            <echo message="2. inner global strange: ${strange}" />

            <!-- declaring it local again has no effect -->
            <local name="strange" />
            <echo message="3. inner global strange: ${strange}" />
        </sequential>
        <echo message="global strange: ${strange}" />
    </target>

Output:

    strange:
    inner local strange: bar
    1. inner global strange: ${strange}
    2. inner global strange: bar2
    3. inner global strange: bar2
    global strange: bar2



The attached patch contains:
- Updated local task, LocalProperties and LocalPropertyStack
- New task global
- Updated antunit tests (src/tests/antunit/taskdefs/local-test.xml)


I would further refine this if needed and also update documentation if this is
considered for inclusion in ant.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Mime
View raw message