Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-ant-dev] AntRunner classpaths and class loaders

I the mean time, Rodrigo pointed me at the location in Help where this is
clearly described, so this is a mild case of RTFM :-).

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



                                                                                                                                        
                      "Darin Swanson"                                                                                                   
                      <darins@xxxxxxxxx>             To:       <platform-ant-dev@xxxxxxxxxxx>                                           
                      Sent by:                       cc:                                                                                
                      platform-ant-dev-admin@        Subject:  Re: [platform-ant-dev] AntRunner classpaths and class loaders            
                      eclipse.org                                                                                                       
                                                                                                                                        
                                                                                                                                        
                      12/07/2002 04:10 PM                                                                                               
                      Please respond to                                                                                                 
                      platform-ant-dev                                                                                                  
                                                                                                                                        
                                                                                                                                        



We have a similar scenario in the Ant test suite.

What we do is have the "test" build listener reach back and set information
into the AntTestChecker.

I would set the PDE UI plugin to contribute an extra classpath entry using
this Ant core extension point (see the doc).
Then your plugin class loader is set as a parent classloader of the
AntClassLoader.  Then all classes loaded by your plugin class loader can be
"seen" and will not be loaded by the AntClassLoader. Then you could have
the
build listener set the static field on a class that you know is loaded by
your plugin class loader. You must make sure that the "reaching back" of
the
build listener is not the reason the class is loaded as this will load the
class in the AntClassLoader. Then your plugin class loader will load the
class again and you will have the same problem.

I hope this is as clear as mud,
Darins

----- Original Message -----
From: "Darin Swanson" <Darin_Swanson@xxxxxxx>
To: <darins@xxxxxxxxx>
Sent: Saturday, December 07, 2002 1:41 PM
Subject: Re: [platform-ant-dev] AntRunner classpaths and class loaders


>
>                       dejan@xxxxxxxxxx
>                       Sent by:                        To:
platform-ant-dev@xxxxxxxxxxx
>                       platform-ant-dev-admin@         cc:
>                       eclipse.org                     Subject: Re:
[platform-ant-dev]
>                                                       AntRunner
classpaths
and class
>                                                       loaders
>                       12/07/2002 02:32 PM
>                       Please respond to
>                       platform-ant-dev
>
>
>
>
>
>
>
>
> I managed to fix problem number 1 using the following custom classpath:
>
>       private URL[] computeCustomClasspath() {
>             // Add this plug-in's space
>             AntCorePreferences preferences = AntCorePlugin.getPlugin
> ().getPreferences();
>             URL [] defaultAntURLs = preferences.getDefaultAntURLs();
>             URL installURL = PDEPlugin.getDefault().getDescriptor
> ().getInstallURL();
>             try {
>                   int length = defaultAntURLs.length;
>                   URL [] customURLs = new URL[length+2];
>                   System.arraycopy(defaultAntURLs, 0, customURLs, 0,
> length);
>                   customURLs[length] = new URL(installURL, "bin/");
>                   customURLs[length+1] = new URL(installURL,
"pdeui.jar");
>                   return customURLs;
>             }
>             catch (IOException e) {
>                   PDEPlugin.logException(e);
>                   return null;
>             }
>       }
>
> The code above seems to work in both the self-hosting scenarios (when bin
> is used) and in a regular build (when jar will be used). However, I still
> cannot fix the problem #2. I checked AntPluginLoader implementation and
it
> seems fairly logical why it happens: this new loader instance does not
> 'see' the class instance loaded by the calling plug-in loader - static
> access to classes cannot work in this arrangement.
>
> In general, is there a solution for reaching back into running plug-ins
> from classes created by Ant classloader? The only thing my build listener
> can now do is output the events into the file in the fixed location,
which
> is not very useful.
>
> 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
>
>
>
>
>                       Dejan
>                       Glozic/Toronto/IBM@IBMC        To:
>                       platform-ant-dev@xxxxxxxxxxx
>                       A                              cc:
>                       Sent by:                       Subject:
>                       [platform-ant-dev] AntRunner classpaths and class
>                       loaders
>                       platform-ant-dev-admin@
>                       eclipse.org
>
>
>                       12/06/2002 09:16 PM
>                       Please respond to
>                       platform-ant-dev
>
>
>
>
>
> 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
>
> _______________________________________________
> platform-ant-dev mailing list
> platform-ant-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/platform-ant-dev
>
>
>
> _______________________________________________
> platform-ant-dev mailing list
> platform-ant-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/platform-ant-dev
>
>

_______________________________________________
platform-ant-dev mailing list
platform-ant-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-ant-dev





Back to the top