JavaCore.newVariableEntry() with relative path [message #530099] |
Wed, 28 April 2010 09:01  |
Eclipse User |
|
|
|
Hi JDT Community,
I develops a project named CALICO as Eclipse plugins where I reuse
JavaProject, and I would like to use classpath's variable to references
libraries contained in my plugins without use absolute path.
To do that I create a variable which references the eclipse install
directory :
String CALICO_LOCATION_VARIABLE = "CALICO_LOCATION";
Location calicoInstallLocation = Platform.getInstallLocation();
URL calicoInstallURL = calicoInstallLocation.getURL();
IPath calicoInstallPath = new Path(calicoInstallURL.getFile());
IProgressMonitor monitor = new NullProgressMonitor();
JavaCore.setClasspathVariable(CALICO_LOCATION_VARIABLE,
calicoInstallPath, monitor);
After I reuse this variable in a ClasspathEntry referencing a library
contained in one of my plugins, first a get the library path relative to
the install location :
String instrumentationBundleId =
"fr.inria.adam.calico.models.instrumentation"
Bundle instrumentationBundle = Platform.getBundle(instrumentationBundleId);
String instrumentationBundlelocation = instrumentationBundle.getLocation();
// here I delete some useless prefix
if (instrumentationBundlelocation.startsWith(initial)) {
instrumentationBundlelocation =
instrumentationBundlelocation.replaceAll(initial + base, "");
} else {
instrumentationBundlelocation =
instrumentationBundlelocation.replaceAll(base, "");
}
//Here I create a path using my variable with my relative library's path
IPath path = new Path(CALICO_LOCATION_VARIABLE +"/"+
instrumentationBundlelocation+libraryPath);
IClasspathEntry classpathEntry = = JavaCore.newVariableEntry(path,
null, null);
....
// and update my project's classpath :
javaProject.setRawClasspath(...)
But my build path is incorrect, an example, my
Platform.getInstallLocation() references the
/home/esteban/Bureau/EclipseHeliosM6/ path
my Platform.getBundle(instrumentationBundleId).getLocation() references
initial@reference :file:../../CALICO/fr.inria.adam.calico/plugins/fr.inria.ada m.calico.models.instrumentation/
after string processing I get a correct install location relative path
to my library:
.../../CALICO/fr.inria.adam.calico/plugins/fr.inria.adam.cal ico.models.instrumentation/libs/fr.inria.adam.calico.models. runtime.common_0.1.0.jar
With my previously created variable I create a variable entry :
CALICO_LOCATION/../../CALICO/fr.inria.adam.calico/plugins/fr .inria.adam.calico.models.instrumentation/libs/fr.inria.adam .calico.models.runtime.common_0.1.0.jar
but the org.eclipse.core.runtime.Path.canonicalize() method remove my
CALICO_LOCATION variable then my IClassPathEntry becomes incorrect :
.../CALICO/fr.inria.adam.calico/plugins/fr.inria.adam.calico .models.instrumentation/libs/fr.inria.adam.calico.models.run time.common_0.1.0.jar
In the JDT doc :
http://help.eclipse.org/galileo/topic/org.eclipse.jdt.doc.is v/guide/jdt_api_classpath.htm,
we can see an example but only with a filename. Can variable entry can
be use with relative path?
Thanks in advance.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03716 seconds