|
| 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 | +} |
0 commit comments