[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[platform-ant-dev] AntRunner classpaths and class loaders
|
I have a question that is related to PDE usage of Ant builds.
We are generating feature and plugin scripts and want to run them using
AntRunner using the following code:
private void runScript(
IFile scriptFile,
ISiteBuildModel buildModel,
IProgressMonitor monitor)
throws CoreException {
AntRunner runner = new AntRunner();
createLogFile(buildModel);
runner.setBuildFileLocation(scriptFile.getLocation().toOSString
());
runner.setArguments(computeBuildArguments(buildModel));
runner.setExecutionTargets(computeTargets());
runner.setMessageOutputLevel(Project.MSG_ERR);
runner.addBuildListener(BUILD_LISTENER_CLASS);
runner.run(monitor);
}
I have two problems: when I execute this code from within PDE UI plug-in,
it complains that it cannot find build listener class (the one passed to
the runner using the fully qualified class name). When I add my PDE UI JAR
to the list of JARs in Ant classpath preference page, it works.
Another problem I had was that this listener class (once class is loaded
and an instance created) seems to be loaded by a different class loader,
since it cannot communicate via static methods. Example: the method above
is in class 'SiteBuildOperation'. The call 'createLogFile' creates a File
object as a static field and exposes it using the static method. When
BuildListener class is loaded and I try to access the log file using the
static method, it returns null, which implies that SiteBuildOperation that
build listener is using is a different class instance (loaded by a
different class loader).
Question: how can I load AntRunner using the same class loader as my
plug-in and how to 'see' classes from my plug-in frmo the build listener
loaded by AntRunner?
Regards,
Dejan Glozic, Ph.D.
Manager, Eclipse Platform Components
D2/MY7/8200/MKM
IBM Canada Ltd.
Tel. 905 413-2745 T/L 969-2745
Fax. 905 413-4854