Skip to content

Commit 7ec8bc1

Browse files
committed
Adopt Boot Launch to the latest Java launch changes
1 parent 6de76d8 commit 7ec8bc1

File tree

2 files changed

+52
-3
lines changed

2 files changed

+52
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2024 Broadcom, Inc.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Broadcom, Inc. - initial API and implementation
10+
*******************************************************************************/
11+
package org.springframework.ide.eclipse.boot.launch;
12+
13+
import org.eclipse.core.resources.IProject;
14+
import org.eclipse.core.runtime.CoreException;
15+
import org.eclipse.debug.core.ILaunchConfiguration;
16+
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
17+
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaDependenciesTab;
18+
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
19+
import org.springframework.ide.eclipse.boot.core.SpringBootCore;
20+
import org.springsource.ide.eclipse.commons.livexp.util.Log;
21+
22+
public class BootDependenciesTab extends JavaDependenciesTab {
23+
24+
@Override
25+
public void initializeFrom(ILaunchConfiguration conf) {
26+
//See bug: https://github.com/spring-projects/spring-ide/issues/222
27+
// If user did not create boot launch config via boot dash and tries to immediately edit classpath
28+
// an incorrect default classpath will be computed because of the missing classpath provider.
29+
// So make sure the classpath provider is present.
30+
IProject project = BootLaunchConfigurationDelegate.getProject(conf);
31+
try {
32+
if (project!=null && project.hasNature(SpringBootCore.M2E_NATURE) && !conf.hasAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER)) {
33+
ILaunchConfigurationWorkingCopy wc = conf.getWorkingCopy();
34+
BootLaunchConfigurationDelegate.enableMavenClasspathProviders(wc);
35+
conf = wc;
36+
}
37+
} catch (CoreException e) {
38+
Log.log(e);
39+
}
40+
super.initializeFrom(conf);
41+
}
42+
43+
}

eclipse-extensions/org.springframework.ide.eclipse.boot.launch/src/org/springframework/ide/eclipse/boot/launch/BootLaunchConfigurationTabGroup.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,37 @@
1111
package org.springframework.ide.eclipse.boot.launch;
1212

1313

14+
import org.eclipse.debug.core.ILaunchConfiguration;
1415
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
1516
import org.eclipse.debug.ui.CommonTab;
17+
import org.eclipse.debug.ui.DebugUITools;
1618
import org.eclipse.debug.ui.EnvironmentTab;
1719
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
1820
import org.eclipse.debug.ui.ILaunchConfigurationTab;
1921
import org.eclipse.debug.ui.ILaunchConfigurationTabGroup;
22+
import org.eclipse.debug.ui.PrototypeTab;
2023
import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
2124
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaArgumentsTab;
22-
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaClasspathTab;
2325
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaJRETab;
26+
import org.eclipse.jdt.launching.JavaRuntime;
2427

2528
public class BootLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
2629

2730
/**
2831
* @see ILaunchConfigurationTabGroup#createTabs(ILaunchConfigurationDialog, String)
2932
*/
3033
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
34+
ILaunchConfiguration configuration = DebugUITools.getLaunchConfiguration(dialog);
35+
boolean isModularConfiguration = configuration != null && JavaRuntime.isModularConfiguration(configuration);
3136
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
3237
new BootMainTab(),
3338
new JavaArgumentsTab(),
3439
new JavaJRETab(),
35-
new BootClasspathTab(),
40+
isModularConfiguration ? new BootDependenciesTab() : new BootClasspathTab(),
3641
new SourceLookupTab(),
3742
new EnvironmentTab(),
38-
new CommonTab()
43+
new CommonTab(),
44+
new PrototypeTab()
3945
};
4046
setTabs(tabs);
4147
}

0 commit comments

Comments
 (0)