Resolve 'sourcecontrol' location URIs in non-Jazz Eclipse plugins
Hi,
I'm trying to sort out a problem for a client who uses our Eclipse plugins alongside Jazz/RTC.
As part of our project builder we create a java.net.URLClassLoader configured with an entry for each of the classpath roots visible to the project containing the resource being built. These URLs might refer to a folder i.e. for a referenced source folder or a file e.g. a jar.
When the project under build references another project we convert the source folders of the referenced project to URLs by combining the project location with the relative path of the source folder:
IJavaProject javaProject = ...
IClasspathEntry entry = ...
IFile file = javaProject.getProject().getFile(entry.getPath(). removeFirstSegments(1));
URL url = new URL(file.getLocationURI().toURL().toString()+"/");
For standard Eclipse projects this works fine but when the referenced project is under the control of Jazz/RTC the resulting URL has the 'sourcecontrol' protocol. URLClassLoader doesn't like this as it is not a supported protocol by default.
Our ultimate aim is to consume resources under classpath entries as InputStreams. Can anyone help with a way to resolve such resources when they are in Jazz/RTC projects? We are thinking along the lines of either a Jazz-specific URIHandler to process the sourcecontrol URIs, a conversion strategy into a file system path (I expect this is probably not possible in general) or some other API we can use as an alternative to the URLClassloader approach.
Regards,
Matthew Smith
Developer
Model Two Zero
One answer
It sounds like you want the local path of the resource. This was an issue in Eclipse CDT and BIRT and you can follow the solution in those bugs for the correct way to get the local path from a URL.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=378882
https://bugs.eclipse.org/bugs/show_bug.cgi?id=403480
https://bugs.eclipse.org/bugs/show_bug.cgi?id=378882
https://bugs.eclipse.org/bugs/show_bug.cgi?id=403480