Author: rob.stryker(a)jboss.com
Date: 2008-11-06 20:10:51 -0500 (Thu, 06 Nov 2008)
New Revision: 11600
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractJBossLaunchConfigType.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/StopLaunchConfiguration.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/TwiddleLaunchConfiguration.java
Log:
JBIDE-2742 - adding tools.jar (if it exists) to jboss launches version 4.0.x
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractJBossLaunchConfigType.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractJBossLaunchConfigType.java 2008-11-07
00:59:41 UTC (rev 11599)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractJBossLaunchConfigType.java 2008-11-07
01:10:51 UTC (rev 11600)
@@ -7,6 +7,7 @@
import java.util.Map;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -148,22 +149,18 @@
}
protected static void addCPEntry(ArrayList<IRuntimeClasspathEntry> list,
JBossServer jbs, String relative) {
- list.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new
Path(getServerHome(jbs)).append(relative)));
+ addCPEntry(list, new Path(getServerHome(jbs)).append(relative));
}
+ protected static void addCPEntry(ArrayList<IRuntimeClasspathEntry> list, IPath
path) {
+ list.add(JavaRuntime.newArchiveRuntimeClasspathEntry(path));
+ }
- @Deprecated
- protected static ArrayList<String>
convertClasspath(ArrayList<IRuntimeClasspathEntry> cp, IVMInstall vmInstall) {
- addJREEntry(cp, vmInstall);
- return convertClasspath(cp);
- }
-
protected static void addJREEntry(ArrayList<IRuntimeClasspathEntry> cp, IVMInstall
vmInstall) {
if (vmInstall != null) {
try {
cp.add(JavaRuntime.newRuntimeContainerClasspathEntry(
new Path(JavaRuntime.JRE_CONTAINER)
.append(vmInstall.getVMInstallType().getId()).append(vmInstall.getName()),
-// "org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType")
IRuntimeClasspathEntry.BOOTSTRAP_CLASSES));
} catch (CoreException e) {
IStatus s = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
@@ -173,6 +170,15 @@
}
}
+ protected static void addToolsJar(ArrayList<IRuntimeClasspathEntry> cp, IVMInstall
vmInstall) {
+ File f = vmInstall.getInstallLocation();
+ File c1 = new File(f, "lib");
+ File c2 = new File(c1, "tools.jar");
+ if( c2.exists())
+ addCPEntry(cp, new Path(c2.getAbsolutePath()));
+ }
+
+
protected static ArrayList<String>
convertClasspath(ArrayList<IRuntimeClasspathEntry> cp) {
Iterator<IRuntimeClasspathEntry> cpi = cp.iterator();
ArrayList<String> list = new ArrayList<String>();
@@ -206,7 +212,7 @@
classpath.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(
libPath + File.separator + libs[i].getName())));
}
- } // end method
+ }
public static String getServerHome(JBossServer jbs) {
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java 2008-11-07
00:59:41 UTC (rev 11599)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java 2008-11-07
01:10:51 UTC (rev 11600)
@@ -22,7 +22,6 @@
package org.jboss.ide.eclipse.as.core.server.internal.launch;
import java.util.ArrayList;
-import java.util.HashMap;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -41,7 +40,6 @@
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.jdt.launching.StandardClasspathProvider;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.ServerUtil;
@@ -83,49 +81,53 @@
IRuntime rt = jbs.getServer().getRuntime();
String jrePath = null;
+ IJBossServerRuntime jbrt = null;
if( rt != null ) {
- IJBossServerRuntime jbrt =
(IJBossServerRuntime)rt.getAdapter(IJBossServerRuntime.class);
- if( jbrt != null ) {
- IVMInstall install = jbrt.getVM();
- IPath path = JavaRuntime.newJREContainerPath(install);
- jrePath = path.toPortableString();
- }
+ jbrt = (IJBossServerRuntime)rt.getAdapter(IJBossServerRuntime.class);
}
+ if( jbrt == null )
+ throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
"Runtime not found"));
+
+ IVMInstall install = jbrt.getVM();
+ IPath path = JavaRuntime.newJREContainerPath(install);
+ jrePath = path.toPortableString();
+
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
getDefaultArgs(jbs));
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
getDefaultVMArgs(jbs));
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
jbrt.getDefaultRunVMArgs());
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
START_MAIN_TYPE);
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, serverHome +
Path.SEPARATOR + "bin");
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER,
"org.jboss.ide.eclipse.as.core.launch.classpathProvider");
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, jrePath);
- wc.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, getDefaultEnvVars(jbs));
+ wc.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES,
jbrt.getDefaultRunEnvVars());
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, getClasspath(jbs));
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
+
wc.setAttribute(DEFAULTS_SET, true);
}
+ public static ArrayList<String> getClasspath(JBossServer jbs) throws CoreException
{
+ IJBossServerRuntime jbrt = findJBossServerRuntime(jbs.getServer());
+ ArrayList<IRuntimeClasspathEntry> classpath = new
ArrayList<IRuntimeClasspathEntry>();
+ addCPEntry(classpath, jbs, START_JAR_LOC);
+ addJREEntry(classpath, jbrt.getVM());
+
+ String version = jbs.getServer().getRuntime().getRuntimeType().getVersion();
+ if( version.equals("4.0"))
+ addToolsJar(classpath, jbrt.getVM());
+
+ ArrayList<String> runtimeClassPaths = convertClasspath(classpath);
+ return runtimeClassPaths;
+
+ }
+
public static String getDefaultArgs(JBossServer jbs) throws CoreException {
IJBossServerRuntime rt = findJBossServerRuntime(jbs.getServer());
if (rt != null) {
return rt.getDefaultRunArgs() + " -b " + jbs.getServer().getHost();
}
- throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
"Runtime not found"));
+ return null;
}
-
- public static String getDefaultVMArgs(JBossServer jbs) throws CoreException {
- IJBossServerRuntime rt = findJBossServerRuntime(jbs.getServer());
- if (rt != null) {
- return rt.getDefaultRunVMArgs();
- }
- throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
"Runtime not found"));
- }
- public static HashMap<String, String> getDefaultEnvVars(JBossServer jbs) throws
CoreException {
- IJBossServerRuntime rt = findJBossServerRuntime(jbs.getServer());
- if (rt != null) {
- return rt.getDefaultRunEnvVars();
- }
- throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
"Runtime not found"));
- }
-
protected void preLaunch(ILaunchConfiguration configuration,
String mode, ILaunch launch, IProgressMonitor monitor) {
try {
@@ -201,31 +203,5 @@
ILaunchConfigurationWorkingCopy wc = launchConfigType.newInstance(null, launchName);
wc.setAttribute(SERVER_ID, server.getId());
return wc;
- }
-
-
- public static class StartupClasspathProvider extends StandardClasspathProvider {
-
- public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration
configuration) throws CoreException {
- boolean useDefault =
configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH,
true);
- if (useDefault) {
- return computeUnresolvedDefaultClasspath(configuration);
- }
- // recover persisted classpath
- return recoverRuntimePath(configuration,
IJavaLaunchConfigurationConstants.ATTR_CLASSPATH);
- }
-
- protected IRuntimeClasspathEntry[]
computeUnresolvedDefaultClasspath(ILaunchConfiguration configuration) throws CoreException
{
- String serverId = configuration.getAttribute(SERVER_ID, (String)null);
- JBossServer jbs = findJBossServer(serverId);
- IJBossServerRuntime jbrt = findJBossServerRuntime(jbs.getServer());
- ArrayList<IRuntimeClasspathEntry> classpath = new
ArrayList<IRuntimeClasspathEntry>();
- addCPEntry(classpath, jbs, START_JAR_LOC);
- addJREEntry(classpath, jbrt.getVM());
- return (IRuntimeClasspathEntry[]) classpath
- .toArray(new IRuntimeClasspathEntry[classpath.size()]);
- }
-
- }
-
+ }
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/StopLaunchConfiguration.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/StopLaunchConfiguration.java 2008-11-07
00:59:41 UTC (rev 11599)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/StopLaunchConfiguration.java 2008-11-07
01:10:51 UTC (rev 11600)
@@ -90,7 +90,8 @@
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, serverHome +
Path.SEPARATOR + "bin");
ArrayList<IRuntimeClasspathEntry> classpath = new
ArrayList<IRuntimeClasspathEntry>();
addCPEntry(classpath, jbs, STOP_JAR_LOC);
- ArrayList runtimeClassPaths = convertClasspath(classpath, jbrt.getVM());
+ addJREEntry(classpath, jbrt.getVM());
+ ArrayList<String> runtimeClassPaths = convertClasspath(classpath);
String cpKey = IJavaLaunchConfigurationConstants.ATTR_CLASSPATH;
wc.setAttribute(cpKey, runtimeClassPaths);
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/TwiddleLaunchConfiguration.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/TwiddleLaunchConfiguration.java 2008-11-07
00:59:41 UTC (rev 11599)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/TwiddleLaunchConfiguration.java 2008-11-07
01:10:51 UTC (rev 11600)
@@ -31,6 +31,7 @@
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
@@ -62,13 +63,14 @@
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, serverHome +
Path.SEPARATOR + "bin");
wc.setAttribute(TwiddleLaunchConfiguration.SERVER_ID, server.getId());
- ArrayList classpath = new ArrayList();
+ ArrayList<IRuntimeClasspathEntry> classpath = new
ArrayList<IRuntimeClasspathEntry>();
addCPEntry(classpath, jbs, TWIDDLE_JAR_LOC);
// Twiddle requires more classes and I'm too lazy to actually figure OUT which ones
it needs.
addDirectory (serverHome, classpath, "lib");
addDirectory (serverHome, classpath, "lib" + File.separator +
"endorsed");
addDirectory (serverHome, classpath, "client");
- ArrayList runtimeClassPaths = convertClasspath(classpath, jbrt.getVM());
+ addJREEntry(classpath, jbrt.getVM());
+ ArrayList<String> runtimeClassPaths = convertClasspath(classpath);
String cpKey = IJavaLaunchConfigurationConstants.ATTR_CLASSPATH;
wc.setAttribute(cpKey, runtimeClassPaths);
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);