ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: Problem using org.apache.tools.ant.taskdefs.Java
Date Wed, 30 Jun 2004 08:14:49 GMT
I'll post this again, in case it's useful. --DD

    /**
     * Configures a helper task to be used within another task.
     *
     * @param  parent the parent (custom) task using the helper task.
     * @param  helper the helper task to configure for use.
     * @return the configured helper task for call chaining.
     */
    public static Task configureTask(Task parent, Task helper) {
        // Make helper share attributes of the parent
        helper.setProject(parent.getProject());
        helper.setTaskName(parent.getTaskName());
        helper.setOwningTarget(parent.getOwningTarget());

        // Initialize (and return) the helper
        helper.init();
        return helper;
    }

-----Original Message-----
From: Stefan Bodewig
To: user@ant.apache.org
Sent: 6/30/2004 1:06 AM
Subject: Re: Problem using org.apache.tools.ant.taskdefs.Java

On Wed, 30 Jun 2004, Robert Mark Bram <relaxedrob@optusnet.com.au>
wrote:

>        // Run common.guitools.Test as a Java task
>        Java testTask = new Java();

Ant usually does more than that, in particular it invokes setProject
with a valid project reference - and without actually checking the
code I'd bet the NPE you see is Ant trying to use that project
reference.

         Java testTask = (Java) getProject().createTask("java");

would be the better approach.

Stefan

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


Mime
View raw message