After re-packaging the OTRE for Bug 320191 -
[pde] Exporting an OT plug-in requires to have org.eclipse.objectteams.runtime in the ws:
* Simplify by removing intermediate variable OTRUNTIME_LIBDIR
* Fix regressions in, e.g., OTBuilderTests: when OTRE is served from the projects bin folder,
a linked folder was inconsistently created
(missing in the ws-elementTree - to be checked with JDT/Core team).
diff --git a/plugins/org.eclipse.objectteams.otdt/plugin.xml b/plugins/org.eclipse.objectteams.otdt/plugin.xml
index b88a55f..84bc547 100644
--- a/plugins/org.eclipse.objectteams.otdt/plugin.xml
+++ b/plugins/org.eclipse.objectteams.otdt/plugin.xml
@@ -41,9 +41,6 @@
<classpathVariableInitializer
variable="OTDT_INSTALLDIR"
class="org.eclipse.objectteams.otdt.core.ext.OTVariableInitializer"/>
- <classpathVariableInitializer
- variable="OTRUNTIME_LIBDIR"
- class="org.eclipse.objectteams.otdt.core.ext.OTVariableInitializer"/>
</extension>
<extension
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTDTPlugin.java b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTDTPlugin.java
index a632782..e6f130c 100644
--- a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTDTPlugin.java
+++ b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTDTPlugin.java
@@ -42,7 +42,6 @@
public static final String PLUGIN_ID = JavaCore.OTDT_PLUGIN_ID;
public static final String OTDT_INSTALLDIR = "OTDT_INSTALLDIR"; //$NON-NLS-1$
- public static final String OTRE_CONTAINER_PATH = "OTRUNTIME_LIBDIR" ; //$NON-NLS-1$ // FIXME(SH): rename variable if successful
// === IDs for configurable options for the compiler : ===
public static final String OT_COMPILER_BASE_CALL =
@@ -120,7 +119,7 @@
try {
OTREContainer.findBCEL(context);
} catch (RuntimeException re) {
- this.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, "Cannot initialize BCEL location", re));
+ this.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, "Cannot initialize BCEL location", re)); //$NON-NLS-1$
}
}
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainer.java b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainer.java
index 52bdd8d..15535a4 100644
--- a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainer.java
+++ b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainer.java
@@ -46,31 +46,42 @@
*/
public class OTREContainer implements IClasspathContainer
{
- public static final String OTRE_CONTAINER_NAME = "OTRE"; //$NON-NLS-1$
- public static final String OTRE_JAR_FILENAME = "otre.jar"; //$NON-NLS-1$
- public static final String OTRE_MIN_JAR_FILENAME = "otre_min.jar"; //$NON-NLS-1$
- public static final String OTRE_AGENT_JAR_FILENAME = "otre_agent.jar"; //$NON-NLS-1$
+ /** Name of this classpath container, which hosts the full OTRE. */
+ public static final String OTRE_CONTAINER_NAME = "OTRE"; //$NON-NLS-1$
- public static final IPath OTRE_CONTAINER_PATH = new Path(OTRE_CONTAINER_NAME);
// these are served from the current plugin:
- public static final IPath OTRE_MIN_JAR_PATH = OTDTPlugin.getResolvedVariablePath(OTDTPlugin.OTDT_INSTALLDIR, "lib/"+OTRE_MIN_JAR_FILENAME); //$NON-NLS-1$
- public static final IPath OTRE_AGENT_JAR_PATH = OTDTPlugin.getResolvedVariablePath(OTDTPlugin.OTDT_INSTALLDIR, "lib/"+OTRE_AGENT_JAR_FILENAME); //$NON-NLS-1$
+ public static final IPath OTRE_MIN_JAR_PATH;
+ public static final IPath OTRE_AGENT_JAR_PATH;
+
public static IPath BCEL_PATH; // will be initialized in {@link findBCEL(BundleContext)}
+
+ // details of this container: name and hosting plugin:
+ private static final IPath OTRE_CONTAINER_PATH = new Path(OTRE_CONTAINER_NAME);
+ private static final String OT_RUNTIME_PLUGIN = "org.eclipse.objectteams.runtime"; //$NON-NLS-1$
+
+ // file names for the above OTRE_X_JAR_PATH constants:
+ private static final String OTRE_MIN_JAR_FILENAME = "otre_min.jar"; //$NON-NLS-1$
+ private static final String OTRE_AGENT_JAR_FILENAME = "otre_agent.jar"; //$NON-NLS-1$
+
// data for initializing the above BCEL_PATH:
private static final String BCEL_BUNDLE_NAME = "org.apache.bcel"; //$NON-NLS-1$
private static final String BCEL_VERSION_RANGE = "[5.2.0,5.3.0)"; //$NON-NLS-1$
+
+ static {
+ OTRE_MIN_JAR_PATH = OTDTPlugin.getResolvedVariablePath(OTDTPlugin.OTDT_INSTALLDIR, "lib/"+OTRE_MIN_JAR_FILENAME); //$NON-NLS-1$
+ OTRE_AGENT_JAR_PATH = OTDTPlugin.getResolvedVariablePath(OTDTPlugin.OTDT_INSTALLDIR, "lib/"+OTRE_AGENT_JAR_FILENAME); //$NON-NLS-1$
+ }
+
private IClasspathEntry[] _cpEntries;
public IClasspathEntry[] getClasspathEntries()
{
if (_cpEntries == null)
{
- _cpEntries = new IClasspathEntry[1];
- IPath fullPath = new Path(OTDTPlugin.OTRE_CONTAINER_PATH);
- IClasspathEntry varOTREEntry = JavaCore.newVariableEntry(fullPath, fullPath, fullPath, true);
- _cpEntries[0] = JavaCore.getResolvedClasspathEntry(varOTREEntry);
+ IPath fullPath = new Path(OTVariableInitializer.getInstallatedPath(OTDTPlugin.getDefault(), OT_RUNTIME_PLUGIN, "bin")); //$NON-NLS-1$
+ _cpEntries = new IClasspathEntry[] {JavaCore.newLibraryEntry(fullPath, fullPath, new Path("/"))}; //$NON-NLS-1$
}
return _cpEntries;
@@ -83,7 +94,7 @@
public int getKind()
{
- return IClasspathContainer.K_APPLICATION;
+ return IClasspathContainer.K_DEFAULT_SYSTEM;
}
public IPath getPath()
@@ -169,12 +180,16 @@
static void findBCEL(BundleContext context) throws IOException {
ServiceReference ref= context.getServiceReference(PackageAdmin.class.getName());
if (ref == null)
- throw new IllegalStateException("Cannot connect to PackageAdmin");
+ throw new IllegalStateException("Cannot connect to PackageAdmin"); //$NON-NLS-1$
PackageAdmin packageAdmin = (PackageAdmin)context.getService(ref);
for (Bundle bundle : packageAdmin.getBundles(BCEL_BUNDLE_NAME, BCEL_VERSION_RANGE)) {
- BCEL_PATH = new Path(FileLocator.toFileURL(bundle.getEntry("/")).getFile());
+ BCEL_PATH = new Path(FileLocator.toFileURL(bundle.getEntry("/")).getFile()); //$NON-NLS-1$
return;
}
- throw new RuntimeException("bundle org.apache.bcel not found");
+ throw new RuntimeException("bundle org.apache.bcel not found"); //$NON-NLS-1$
+ }
+
+ public String getResolvedPathString() {
+ return getClasspathEntries()[0].getPath().toOSString();
}
}
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainerInitializer.java b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainerInitializer.java
index 61689ac..6bd9c28 100644
--- a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainerInitializer.java
+++ b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainerInitializer.java
@@ -49,12 +49,7 @@
JavaCore.setClasspathContainer(
containerPath,
new IJavaProject[] { project },
- new IClasspathContainer[] { createOTREContainer() },
+ new IClasspathContainer[] { new OTREContainer() },
null);
}
-
- private IClasspathContainer createOTREContainer()
- {
- return new OTREContainer();
- }
}
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTVariableInitializer.java b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTVariableInitializer.java
index d774f8c..8936cdd 100644
--- a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTVariableInitializer.java
+++ b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTVariableInitializer.java
@@ -24,16 +24,19 @@
import java.net.URL;
import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.ClasspathVariableInitializer;
import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
import org.osgi.framework.Bundle;
/**
- * ClassPathVariableInitializer to initialize the OTRE_INSTALL variable.
+ * ClassPathVariableInitializer to initialize the OTRE_INSTALLDIR variable.
*
* @author gis
* @version $Id: OTVariableInitializer.java 23427 2010-02-03 22:23:59Z stephan $
@@ -47,47 +50,61 @@
public void initialize(String variable)
{
+ String installPath = null;
if (OTDTPlugin.OTDT_INSTALLDIR.equals(variable))
{
- setPluginInstallationPathVariable(OTDTPlugin.getDefault(), null, null, variable);
- }
- else if (OTDTPlugin.OTRE_CONTAINER_PATH.equals(variable))
- {
- setPluginInstallationPathVariable(OTDTPlugin.getDefault(), "org.eclipse.objectteams.runtime", "bin", variable);
+ installPath = getOTDTPluginInstallationPath();
+ } else {
+ OTDTPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, OTDTPlugin.PLUGIN_ID, "Mismatching name for classpath variable during initialization")); //$NON-NLS-1$
}
+ try {
+ JavaCore.setClasspathVariable(variable, new Path(installPath), new NullProgressMonitor());
+ } catch (JavaModelException e) {
+ OTDTPlugin.getExceptionHandler().logException(e);
+ }
}
- public static void setPluginInstallationPathVariable(Plugin relativePlugin, String bundleName, String relativeDir, String variable)
+ public static String getOTDTPluginInstallationPath()
{
try
{
- URL installDirectory;
- if (bundleName == null)
- installDirectory = relativePlugin.getBundle().getEntry("/"); //$NON-NLS-1$
- else
- installDirectory = getBundle(bundleName).getEntry("/"); //$NON-NLS-1$
+ URL installDirectory = OTDTPlugin.getDefault().getBundle().getEntry("/"); //$NON-NLS-1$
+ // On Windows, the next line leads to something like "/C:/Programme/Eclipse/plugins/my.plugin
+ // If we simply make an org.eclipse.core.runtime.Path out of it, the leading '/' makes the
+ // parsing fail (device, e.g. 'C:' is not detected). We must use java.io.File to parse it
+ // properly.
+ String path = FileLocator.toFileURL(installDirectory).getPath();
+ return new File(path).getPath();
+ }
+ catch (Exception ex)
+ {
+ OTDTPlugin.getExceptionHandler().logException(ex);
+ return null;
+ }
+ }
+
+ public static String getInstallatedPath(Plugin hostPlugin, String bundleName, String optionalRelativeDir)
+ {
+ try
+ {
+ URL installDirectory = getBundle(bundleName).getEntry("/"); //$NON-NLS-1$
// On Windows, the next line leads to something like "/C:/Programme/Eclipse/plugins/my.plugin
// If we simply make an org.eclipse.core.runtime.Path out of it, the leading '/' makes the
// parsing fail (device, e.g. 'C:' is not detected). We must use java.io.File to parse it
// properly.
String path = FileLocator.toFileURL(installDirectory).getPath();
- File f = null;
- if (relativeDir != null) {
- f = new File(path + relativeDir);
- if (!f.exists())
- f = null; // proceed with only "path"
- }
- if (f == null)
- f = new File(path);
- String fixedPath = f.getPath();
- JavaCore.setClasspathVariable(variable, new Path(fixedPath), new NullProgressMonitor());
+ File f = new File(path + optionalRelativeDir);
+ if (!f.exists())
+ f = new File(path); // proceed with only "path"
+ return f.getPath();
}
catch (Exception ex)
{
OTDTPlugin.getExceptionHandler().logException(ex);
+ return null;
}
}