Grokbase Groups Ant user April 2016
FAQ
Hello,

in my ant script, I define a task "MyTask" via "macrodef". The task has a mandatory attribute "nodeName" (not the camelCase name).

Then I call the task from a javascript snippet:

var myTask = project.createTask('myTask');
myTask.setDynamicAttribute("nodeName", "blah");
myTask.perform();


This does not work because I use the camleCase name in the call to setDynamicAttribute. Later, when the task is performed, I get an error that the attribute "nodename" (lowercase!) is not set.

In the source of MacroInstance I see that attribute names are converted to lower case when they are retrieved. But why are they not converted when they are set?

When I use this (note the lowercase name)

     myTask.setDynamicAttribute("nodename", "blah");

everything works. But here I''m forced to use an attribute name I didn't specify (I specified "nodeName").

Why is it made this way?

I see one reason for converting everything to lower case -- to avoid errors due to a wrong capitalizing. But then the conversion should be done everywhere, i.e. when getting and when setting the attributes.

Regards
AL

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

Search Discussions

  • Stefan Bodewig at Apr 16, 2016 at 5:00 pm

    On 2016-04-12, Al Le wrote:

    in my ant script, I define a task "MyTask" via "macrodef". The task
    has a mandatory attribute "nodeName" (not the camelCase name).
    Then I call the task from a javascript snippet:
    var myTask = project.createTask('myTask');
    myTask.setDynamicAttribute("nodeName", "blah");
    myTask.perform();
    This does not work because I use the camleCase name in the call to
    setDynamicAttribute. Later, when the task is performed, I get an error
    that the attribute "nodename" (lowercase!) is not set.
    In the source of MacroInstance I see that attribute names are
    converted to lower case when they are retrieved. But why are they not
    converted when they are set?
    My guess is that you are the first person who's trying what you do and
    you've simply hit a bug.

    Any attribute set on a MacroInstance via an ant build file gets
    lowercased in IntrospectionHelper - we've probably just overlooked the
    case of anybody using the API directly.

    Please open a bug ticket.
    I see one reason for converting everything to lower case
    That's how Ant build files have always worked, task attributes are not
    case-sensitive. And IntrospectionHelper is the central piece of mapping
    attributes to method names or dynamic attributes (and a few other
    things) - which takes care of using lowercase attribute names.

    If you want to work around this, you may want to use IntrospectionHelper
    via its API as well.

    IntrospectionHelper.getHelper(MacroInstance.class).setAttribute(...)

    Stefan

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Al Le at Apr 16, 2016 at 10:43 pm

    My guess is that you are the first person who's trying what you do and
    you've simply hit a bug.

    [...]

    Please open a bug ticket.
    Created the bug report 59339.

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Stefan Bodewig at Apr 17, 2016 at 4:49 am

    On 2016-04-17, Al Le wrote:


    Please open a bug ticket.
    Created the bug report 59339.
    Thanks, should be fixed in git, will be fixed in 1.9.8 and 1.10.0.

    Stefan

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Al Le at Apr 17, 2016 at 1:27 pm
    Thanks, should be fixed in git, will be fixed in 1.9.8 and 1.10.0.
    That's not fair! I've needed so long to identify the problem and create a bug report, and you fix it so quickly! :-)

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriesant
postedApr 12, '16 at 3:45p
activeApr 17, '16 at 1:27p
posts5
users2
websiteant.apache.org

2 users in discussion

Al Le: 3 posts Stefan Bodewig: 2 posts

People

Translate

site design / logo © 2018 Grokbase