ant custom task: init() isn't called and getProject() returns null [message #64040] |
Thu, 05 June 2003 12:13  |
Eclipse User |
|
|
|
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.
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03043 seconds