From 9c369c29d95d7c6720bb0f7d01b2be04a1e73047 Mon Sep 17 00:00:00 2001 From: Peter Reilly Date: Wed, 18 Feb 2004 16:01:14 +0000 Subject: [PATCH] Make note in FAQ about taskcontainer differences between ant 1.6 and ant 1.6 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276108 13f79535-47bb-0310-9956-ffa450edef68 --- docs/faq.html | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ xdocs/faq.xml | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) diff --git a/docs/faq.html b/docs/faq.html index 89a95f917..370fd7c61 100644 --- a/docs/faq.html +++ b/docs/faq.html @@ -335,6 +335,12 @@
  • <zip> is broken in Ant 1.5.2. +
  • +
  • + + Why do my custom task containers see Unknown Elements in Ant 1.6 + - they worked in Ant 1.5? +
  • @@ -1538,6 +1544,55 @@ mv /tmp/foo $ANT_HOME/bin/antRun 17871 and Bug 18403. All of them are supposed to be fixed with Ant 1.5.3 (and only 18403 should exist in 1.5.3beta1).

    +

    + + + Why do my custom task containers see Unknown Elements in Ant 1.6 + - they worked in Ant 1.5? + +

    +

    + The objects added in TaskContainer.addTask(Task task) + have changed from Tasks to UnknownElements. +

    +

    + There was a number of valid reasons for this change. But the backward + compatibility problems were not noticied until after Ant 1.6.0 was + released. +

    +

    + Your container class will need to be modified to check if the Task + is an UnknownElement and call perform on it to + convert it to a Task and to execute it. + (see apache.tools.ant.taskdefs.Sequential) +

    +

    + If you want to do more processing on the task, + you need to use the techniques in apache.tools.ant.taskdefs.Antlib#execute() + This does make use of one 1.6 method call (UE#getRealObject()), + you need to use UE#getTask() instread - this will + return null for non tasks (types like fileset id=x). +

    +

    + So.. interate over the tasks, if they are UEs, convert them to + tasks, using UE#maybeConfigure and UE#getTask() +

    +
    +        for (Iterator i = tasks.iterator(); i.hasNext();) {
    +           Task t = (Task) i.next();
    +           if (t instanceof UnknownElement) {
    +              ((UnknownElement) t).maybeConfigure();
    +              t = ((UnknownElement) t).getTask();
    +              if (t == null) {
    +                  continue;
    +              }
    +           }
    +           // .... original Custom code
    +        }
    +        
    +

    + This approach should work for ant1.5 and ant1.6. +

    diff --git a/xdocs/faq.xml b/xdocs/faq.xml index db168a070..b4825cbac 100644 --- a/xdocs/faq.xml +++ b/xdocs/faq.xml @@ -1359,6 +1359,56 @@ mv /tmp/foo $ANT_HOME/bin/antRun + + + Why do my custom task containers see Unknown Elements in Ant 1.6 + - they worked in Ant 1.5? + + +

    + The objects added in TaskContainer.addTask(Task task) + have changed from Tasks to UnknownElements. +

    +

    + There was a number of valid reasons for this change. But the backward + compatibility problems were not noticied until after Ant 1.6.0 was + released. +

    +

    + Your container class will need to be modified to check if the Task + is an UnknownElement and call perform on it to + convert it to a Task and to execute it. + (see apache.tools.ant.taskdefs.Sequential) +

    +

    + If you want to do more processing on the task, + you need to use the techniques in apache.tools.ant.taskdefs.Antlib#execute() + This does make use of one 1.6 method call (UE#getRealObject()), + you need to use UE#getTask() instread - this will + return null for non tasks (types like fileset id=x). +

    +

    + So.. interate over the tasks, if they are UEs, convert them to + tasks, using UE#maybeConfigure and UE#getTask() +

    + +

    + This approach should work for ant1.5 and ant1.6. +

    +
    +