Bug 522581 - Cannot run ant build file from generic project
Change-Id: I55bc89e35c092127d6581d64f9d7f3e221124ff6
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/launchConfigurations/JavaJRETab.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/launchConfigurations/JavaJRETab.java
index cbef81e..c301204 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/launchConfigurations/JavaJRETab.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/launchConfigurations/JavaJRETab.java
@@ -504,7 +504,14 @@
protected void setLaunchConfiguration(ILaunchConfiguration launchConfiguration) {
fLaunchConfiguration = launchConfiguration;
- fCurrentJREModular = JavaRuntime.isModularConfiguration(getLaunchConfiguration());
+ try {
+ JavaRuntime.getJavaProject(launchConfiguration);
+ fCurrentJREModular = JavaRuntime.isModularConfiguration(getLaunchConfiguration());
+ }
+ catch (CoreException ex) {
+ // If not a Java project
+ fCurrentJREModular = false;
+ }
}
/**
@@ -630,7 +637,7 @@
}
}
}
-
+
/**
* @since 3.9
*/
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaLaunchDelegate.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaLaunchDelegate.java
index 87c363c..43eef88 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaLaunchDelegate.java
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaLaunchDelegate.java
@@ -70,7 +70,7 @@
// VM-specific attributes
Map<String, Object> vmAttributesMap = getVMSpecificAttributesMap(configuration);
- // Bug 522333 :to be used for modulepath only for 4.7.*
+ // Bug 522333 :to be used for modulepath only for 4.7.*
String[][] paths = getClasspathAndModulepath(configuration);
// Create VM config
VMRunnerConfiguration runConfig = new VMRunnerConfiguration(mainTypeName, getClasspath(configuration));
@@ -80,14 +80,19 @@
runConfig.setWorkingDirectory(workingDirName);
runConfig.setVMSpecificAttributesMap(vmAttributesMap);
// current module name, if so
- IJavaProject proj = JavaRuntime.getJavaProject(configuration);
- if (proj != null) {
- IModuleDescription module = proj == null ? null : proj.getModuleDescription();
- String modName = module == null ? null : module.getElementName();
- if (modName != null) {
- runConfig.setModuleDescription(modName);
+ try {
+ IJavaProject proj = JavaRuntime.getJavaProject(configuration);
+ if (proj != null) {
+ IModuleDescription module = proj == null ? null : proj.getModuleDescription();
+ String modName = module == null ? null : module.getElementName();
+ if (modName != null) {
+ runConfig.setModuleDescription(modName);
+ }
}
}
+ catch (CoreException e) {
+ // Not a java Project so no need to set module description
+ }
if (!JavaRuntime.isModularConfiguration(configuration)) {
// Bootpath
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java
index 159b512..665d913 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java
@@ -1521,18 +1521,22 @@
for (IRuntimeClasspathEntry entry : entries1) {
switch (entry.getClasspathEntry().getEntryKind()) {
case IClasspathEntry.CPE_LIBRARY:
- IJavaProject project = JavaRuntime.getJavaProject(configuration);
- if (project == null) {
- entries2.add(entry);
+ try {
+ IJavaProject project = JavaRuntime.getJavaProject(configuration);
+ if (project == null) {
+ entries2.add(entry);
+ } else {
+ IPackageFragmentRoot root = project.findPackageFragmentRoot(entry.getPath());
+ if (root == null) {
+ entries2.add(entry);
+ } else if (root != null && !root.getRawClasspathEntry().getPath().segment(0).contains("JRE_CONTAINER")) { //$NON-NLS-1$
+ entries2.add(entry);
+ }
+ }
}
- else {
- IPackageFragmentRoot root = project.findPackageFragmentRoot(entry.getPath());
- if ( root == null) {
- entries2.add(entry);
- }
- else if (root != null && !root.getRawClasspathEntry().getPath().segment(0).contains("JRE_CONTAINER")) { //$NON-NLS-1$
- entries2.add(entry);
- }
+ catch (CoreException ex) {
+ // Not a java project
+ entries2.add(entry);
}
break;
default: