Return-Path: X-Original-To: apmail-ant-user-archive@www.apache.org Delivered-To: apmail-ant-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EAFE219747 for ; Tue, 26 Apr 2016 06:53:32 +0000 (UTC) Received: (qmail 42255 invoked by uid 500); 26 Apr 2016 06:53:32 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 42109 invoked by uid 500); 26 Apr 2016 06:53:32 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 42098 invoked by uid 99); 26 Apr 2016 06:53:31 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Apr 2016 06:53:31 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 2B30D18028C for ; Tue, 26 Apr 2016 06:53:31 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.702 X-Spam-Level: X-Spam-Status: No, score=-0.702 tagged_above=-999 required=6.31 tests=[RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001] autolearn=disabled Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id nlREJ5muutRl for ; Tue, 26 Apr 2016 06:53:29 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with ESMTPS id 752455FB1A for ; Tue, 26 Apr 2016 06:53:28 +0000 (UTC) Received: from [91.235.236.103] by 3capp-gmx-bs16.server.lan (via HTTP); Tue, 26 Apr 2016 08:53:20 +0200 MIME-Version: 1.0 Message-ID: From: "Al Le" To: user@ant.apache.org Subject: How to create a task associated a target Content-Type: text/plain; charset=UTF-8 Date: Tue, 26 Apr 2016 08:53:20 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K0:LWCcv5fR1ewY4eEGXHWwAKtn12eke3frPCaKEN5zHn3 bFEmihxuEqSZWh77SDSJt8kEFOFvf3mLuI+FW3ChHC+xWxW9yu D42P5todVItxPLOlrpgwSSAnWJNc+h6FcH3D+EgkUsxuH3LxVd DlAS5cC2tdAlzMozRAy82wrXo66jUZ5WHdZpotNFdGn4JZPHqK v4Y4odRjBRPH+Wr7rx2g3Qe13bICv6yW215GClbODnBaOQsMz4 C+6Rpbx6eMySazeHmd/MF4TUiWFS0Zw1erRITktTKFL4qx9MC5 PQ253M= X-UI-Out-Filterresults: notjunk:1;V01:K0:hDFyS/GWHHY=:6EN+0FVrqZOBIQUECyhfz5 GhvUIka8HFa1WtaFUeF8csgVF8Vg03wflcwYg+JJ0XeYOlX8pmEsRne19Qgn1hQBrORisKAHI anDIYReh2QmHBavCaM4rT4MUqK6bXhKS9A6UtVzQhIOfd/dGvhI4NFrRVH9IIOp5AqckMUZBA OFRCq/nmmk1MQ7+KB1aRiSMWzSNTKzb2gSbz0KkYAnQGv2v+i2SrRP4QYAjLXI1hNlYBSA5GQ gIsJY2hJyBiiGYrbiiEzJ/JXaPmxbVpfvkaoDQ5kT0qTBdgfyCYxN57NgBwE0h4cv8mbG0/J1 0fN+jhkajglF6u7CdyOzi1BdK7qtFB/1ccbu7s8sEKPyZEoT9pNDG+JTP3MqCWtk5NDs5OtOX GjxYkezrQTpG451BW0DYfbnYHe7ozlZUMugiktdTSoolUz3jef4xv0jEz4Ie5Z+Exzp8TPPey TxWegEQlZA== Hello, in my ant script, I do the following: 1. there is a target "calledTarget" 2. there is a task "macroTask", defined via "macrodef". This task contains in its body a call to "calledTarget" (via "antcall"). 3. there is a target "mainTarget" which contains a task "script" (javascript). In this script, I create an instance of macroTask and then execute it. Here's the picture as an outline: When I run the script, I get a NullPointerException. I found out that it occurs in Ant.java, at the line "if (getOwningTarget().getName().equals("")) {" (line number about 380, depending on the ant version). OK, it's clear that the owning target is not set for the task because the task is created via the project (and not via a target). Now I have some questions: 1. Is it possible to create a task so that it "automatically" gets associated with a task? 2. Is it possible to find out the name of the current target (or even get the current target as an object) in a script? So that I don't have to write "mainTarget" in the call to "setOwningTarget" in the script above, but rather can do something like getCurrentTarget(). The code above is just an outline. In the real script, I have a rather complicated logics in the javascript, and from the script I set some project properties and call the macro which passes the properties to the called target (to call the target is my real goal; the macroTask is just passing it through). Thank you AL --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org