Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » ant custom task: init() isn't called and getProject() returns null
ant custom task: init() isn't called and getProject() returns null [message #64040] Thu, 05 June 2003 12:13 Go to next message
Eclipse UserFriend
Originally posted by: pmorgan.jcoverage.com

I am having some trouble 'porting' some ANT custom tasks that I have
written to run under eclipse. The main problem that I am having is that
init() does not appear to be called on the custom task, and that
getProject() returns null. I am not a regular eclipse user (18+ years of
emacs ;)). So, any help would be appreciated:

My "simple" task:

public class SimpleTask extends Task {
String foo;

public void setFoo(String foo) {
System.out.println("SimpleTask.setFoo("+foo+")");
System.out.println("getProject: "+getProject()); this.foo=foo;
}
}
public void init() throws BuildException {
System.out.println("SimpleTask.init()");
System.out.println("getProject: "+getProject());
}
}
public void execute() throws BuildException {
System.out.println("SimpleTask.execute()");
System.out.println("getProject: "+getProject());
}
}
}
When run under plain-old-ANT via a shell prompt, I get the following
output:

[pmorgan@sport examples]$ ant simple
Searching for build.xml ...
Buildfile: /home/pmorgan/bk/eclipse-plugin/examples/build.xml

simple:
SimpleTask.init()
getProject: org.apache.tools.ant.Project@c931fc SimpleTask.setFoo(bar)
getProject: org.apache.tools.ant.Project@c931fc SimpleTask.execute()
getProject: org.apache.tools.ant.Project@c931fc

As I would expect, before <simple/> can be execute'd, init is called and a
valid project is available from getProject().

However, if I run the same under eclipse (right clicking the build.xml and
"run Ant..."), then I get the following:

Buildfile: /home/pmorgan/bk/eclipse-plugin/workspace/xxx/build.xml

main:
[simple] SimpleTask.setFoo(bar)
[simple] getProject: null
[simple] SimpleTask.execute()
[simple] getProject: null
BUILD SUCCESSFUL

init() hasn't been called, and getProject() is returning null.


My plugin.xml:

<?xml version="1.0" encoding="UTF-8"?> <plugin
name="%pluginName"
id="com.jcoverage"
version="@product.version@"
provider-name="%providerName">

<runtime>
<library name="jcoverage.jar"/>
</runtime>

<requires>
<import plugin="org.eclipse.jdt.core"/> <import
plugin="org.apache.ant"/>
</requires>

<extension point="org.eclipse.ant.core.antTasks">
<antTask name="simple" class="com.jcoverage.ant.SimpleTask"
library="jcoverage.jar"/>
</extension>

<extension point="org.eclipse.ant.core.extraClasspathEntries">
<extraClasspathEntry library="jcoverage-main.jar"/>
<extraClasspathEntry library="lib/bcel/5.1/bcel.jar"/>
<extraClasspathEntry
library="lib/gnu/getopt/1.0.9/java-getopt-1.0.9.jar"/>
<extraClasspathEntry library="lib/log4j/1.2.8/log4j-1.2.8.jar"/>
<extraClasspathEntry library="lib/oro/2.0.7/jakarta-oro-2.0.7.jar"/>
</extension>

</plugin>


So I guess the questions are:

a) Am I doing something really stupid ;)

b) Is this expected behaviour?

c) How should I be doing this?

[Some background: I am porting 2 custom tags for http://jcoverage.com,
<instrument> and <report>, both of which use getProject(). jcoverage is a
GPL'd java code coverage tool, that uses byte code instrumentation].

Thanks,
Peter.
Re: ant custom task: init() isn't called and getProject() returns null [message #64063 is a reply to message #64040] Thu, 05 June 2003 12:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pmorgan.jcoverage.com

On Thu, 05 Jun 2003 17:13:00 +0100, Peter James Morgan wrote:
> <runtime>
> <library name="jcoverage.jar"/>
> </runtime>

Doh! I realized that this should be "jcoverage-main.jar". Sorry. Works OK
now!

Peter.
Re: ant custom task: init() isn't called and getProject() returns null [message #64130 is a reply to message #64040] Thu, 05 June 2003 12:54 Go to previous messageGo to next message
Eclipse UserFriend
> So I guess the questions are:
>
> a) Am I doing something really stupid ;)

No :-)

> b) Is this expected behaviour?

No :-)

> c) How should I be doing this?
You need to ensure that your custom Ant tasks are not included in the
plug-in library.
For more details see either the Eclipse Help under Platform Plug-ing
Developer Guide>Programmers Guide> Platform Ant Support> Contributing tasks
and types
or see
https://bugs.eclipse.org/bugs/show_bug.cgi?id=34466

HTH
Darins
Re: ant custom task: init() isn't called and getProject() returns null [message #64176 is a reply to message #64063] Thu, 05 June 2003 12:58 Go to previous message
Eclipse UserFriend
That will do it too :-)

"Peter James Morgan" <pmorgan@jcoverage.com> wrote in message
news:bbnr6b$ask$1@rogue.oti.com...
> On Thu, 05 Jun 2003 17:13:00 +0100, Peter James Morgan wrote:
> > <runtime>
> > <library name="jcoverage.jar"/>
> > </runtime>
>
> Doh! I realized that this should be "jcoverage-main.jar". Sorry. Works OK
> now!
>
> Peter.
>
Previous Topic:[ANN] oXygen XML Editor available as closely integrated eclipse plugin
Next Topic:Cannot proint under linux
Goto Forum:
  


Current Time: Wed May 28 21:37:34 EDT 2025

Powered by FUDForum. Page generated in 0.03043 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top