Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Calculate RCP Product Classpath for Embedded Eclipse Compiler
Calculate RCP Product Classpath for Embedded Eclipse Compiler [message #759007] Fri, 25 November 2011 14:58 Go to next message
Marcel Austenfeld is currently offline Marcel AustenfeldFriend
Messages: 160
Registered: July 2009
Senior Member
Hello,

i would like to calculate the complete classpath of my RCP application for the use
in the classpath option of the Eclipse compiler (for the compilation in my RCP product).

In my application several plugins are embedded and sometimes in the plugins some libraries, too.

At the moment i calculate the paths to each plugin (and embedded libs) and concatenate them as the -classpath option for the compiler. This works fine so far.

If i use a scripting language (like Groovy) inside of an RCP product i don't need to calculate the classpath from the paths of the plugins. It seems that they have already calculated the classpath from whatever function.

So my question is does someone know another way or API function to get the classpath paths from the RCP product?

Thanks in advance for any answer!
Re: Calculate RCP Product Classpath for Embedded Eclipse Compiler [message #759046 is a reply to message #759007] Fri, 25 November 2011 19:49 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

What are you trying to do, exactly? i.e. what usecase are you trying to meet? Are you trying to build your RCP app, or trying to build something from your runtime RCP app?

Build systems like PDE build or maven/tycho are written to be OSGi aware, with their own internal models of the OSGi bundles, sometimes using p2 to manage dependencies and sometimes the OSGi resolver itself.

There's no API to get this information, certainly not in an easy to consume form.

PW



Re: Calculate RCP Product Classpath for Embedded Eclipse Compiler [message #759073 is a reply to message #759046] Fri, 25 November 2011 23:03 Go to previous messageGo to next message
Marcel Austenfeld is currently offline Marcel AustenfeldFriend
Messages: 160
Registered: July 2009
Senior Member
Hello Paul,

in my RCP app i have a custom Java editor embedded and the code from this editor is compiled and loaded dynamically to do calculations with special embedded visualization panels.
I use the Java compiler in my Runtime RCP app to compile the Java code. For the compilation several libraries are required which i calculate at the moment from the paths of the plugins. For example i have one RCP plugin in which i bundle a lot of necessary libraries(*.jars) which i put on the classpath (calculated from the plugins path - see below).

Vector<String> optionList = new Vector<String>();
optionList.addElement("-classpath");
optionList.addElement(my paths);//the path to the necessary libs and classfiles!

JavacTool compiler = com.sun.tools.javac.api.JavacTool.create();
.........
compiler.getTask(out,fileManager,null,optionList, null,Collections.singleton(sf)).call();
.......

Is there a method to get the necessary classpath from a running RCP app without the need to calculate the paths from each plugin (location)?
Re: Calculate RCP Product Classpath for Embedded Eclipse Compiler [message #759355 is a reply to message #759073] Mon, 28 November 2011 13:28 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Oh, yes. You use org.osgi.framework.Bundle.getEntry(String) to get the URL for your jar file, and org.eclipse.core.runtime.FileLocator.toFileURL(URL) to turn that into a file:// URL. FileLocator does the work for you to turn anything in jars into files on the file system.

PW


Re: Calculate RCP Product Classpath for Embedded Eclipse Compiler [message #759396 is a reply to message #759355] Mon, 28 November 2011 14:43 Go to previous message
Marcel Austenfeld is currently offline Marcel AustenfeldFriend
Messages: 160
Registered: July 2009
Senior Member
Hello Paul,


i use the FileLocator already in combination with the information in the Manifest (BUNDLE_CLASSPATH) to get all *.jars listed.

I thought there would be some magical
function to list all *.jars and *.class files from the runtime app.

Yet, thanks for your time and help!
Previous Topic:FileNotFoundException -- Eclipse Plugin
Next Topic:Problems when implementing structure compare view in RCP
Goto Forum:
  


Current Time: Thu Mar 28 12:40:24 GMT 2024

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

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

Back to the top