Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2013-08-12 06:56:30 +0000
committerIgor Fedorenko2013-08-12 07:29:18 +0000
commita5acb0a34038a2b56144b28c0edc5af465905f0f (patch)
tree20dadc441d463adbe9c8bd075867caf2ac086cb4
parent1486b46af781fb57d24f36f76de937d98624c180 (diff)
downloadm2e-core-a5acb0a34038a2b56144b28c0edc5af465905f0f.tar.gz
m2e-core-a5acb0a34038a2b56144b28c0edc5af465905f0f.tar.xz
m2e-core-a5acb0a34038a2b56144b28c0edc5af465905f0f.zip
414842 use reflection to access Equinox dev classpath
Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/e44/DevClassPathHelper.java61
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenEmbeddedRuntime.java2
2 files changed, 62 insertions, 1 deletions
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/e44/DevClassPathHelper.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/e44/DevClassPathHelper.java
new file mode 100644
index 00000000..371d2bb4
--- /dev/null
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/e44/DevClassPathHelper.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Igor Fedorenko
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Igor Fedorenko - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.m2e.core.internal.e44;
+
+import java.lang.reflect.Method;
+
+
+/**
+ * Reflection based adaptor that provides Equinox development classpath information and is meant to compensate for
+ * implementation changes between Equinox 3.9 and 3.10.
+ *
+ * @see http://dev.eclipse.org/mhonarc/lists/cross-project-issues-dev/msg09424.html
+ * @since 1.5
+ */
+public class DevClassPathHelper {
+
+ private static final String E43 = "org.eclipse.osgi.internal.baseadaptor.DevClassPathHelper";
+
+ private static final String E44 = "org.eclipse.core.internal.runtime.DevClassPathHelper";
+
+ @SuppressWarnings("unchecked")
+ private static <T> T invoke(String methodName, Class<T> returnType, Object... params) {
+ try {
+ ClassLoader cl = DevClassPathHelper.class.getClassLoader();
+ Class<?> helper;
+ try {
+ helper = cl.loadClass(E44);
+ } catch(ClassNotFoundException ex) {
+ helper = cl.loadClass(E43);
+ }
+ Class<?>[] paramTypes = null;
+ if(params != null) {
+ paramTypes = new Class<?>[params.length];
+ for(int i = 0; i < params.length; i++ ) {
+ paramTypes[i] = params[i].getClass();
+ }
+ }
+ Method method = helper.getMethod(methodName, paramTypes);
+ return (T) method.invoke(null, params);
+ } catch(Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static String[] getDevClassPath(String bundleSymbolicName) {
+ return invoke("getDevClassPath", String[].class, bundleSymbolicName);
+ }
+
+ public static boolean inDevelopmentMode() {
+ return invoke("inDevelopmentMode", boolean.class);
+ }
+}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenEmbeddedRuntime.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenEmbeddedRuntime.java
index f9f81f0d..9f7609b0 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenEmbeddedRuntime.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenEmbeddedRuntime.java
@@ -38,7 +38,6 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.osgi.internal.baseadaptor.DevClassPathHelper;
import org.eclipse.osgi.service.resolver.BaseDescription;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.ExportPackageDescription;
@@ -52,6 +51,7 @@ import org.eclipse.m2e.core.embedder.IMavenLauncherConfiguration;
import org.eclipse.m2e.core.embedder.MavenRuntime;
import org.eclipse.m2e.core.embedder.MavenRuntimeManager;
import org.eclipse.m2e.core.internal.Messages;
+import org.eclipse.m2e.core.internal.e44.DevClassPathHelper;
/**

Back to the top