eclipse-m2e / m2e-core

Eclipse Public License 2.0
113 stars 115 forks source link

Launch configuration Executing references non-existing project #1293

Closed laeubi closed 1 year ago

laeubi commented 1 year ago

Launching under windows a pom.xml either from the context menu or with creating a new launch config results in

Launch configuration Executing clean in D__DevFiles_Eclipse_Tools_IndentGuide_net.certiv.tools.indentguide references non-existing project net.certiv.tools.indentguide.

see originally posted by @grosenberg in https://github.com/eclipse-m2e/m2e-core/discussions/1290

laeubi commented 1 year ago

FYI @HannesWell Reproducer is:

grafik

laeubi commented 1 year ago

The Stacktrace for the error is:


org.eclipse.core.runtime.CoreException: Launch configuration Executing install in_m2e-core_m2e-maven-runtime references non-existing project m2e-maven-runtime.
    at org.eclipse.jdt.launching.JavaRuntime.abort(JavaRuntime.java:1861)
    at org.eclipse.jdt.launching.JavaRuntime.getJavaProject(JavaRuntime.java:1736)
    at org.eclipse.jdt.launching.JavaRuntime.computeVMInstall(JavaRuntime.java:1775)
    at org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate.getVMInstall(AbstractJavaLaunchConfigurationDelegate.java:129)
    at org.eclipse.m2e.internal.launch.MavenLaunchDelegate.getVMInstall(MavenLaunchDelegate.java:240)
    at org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate.getBootpathExt(AbstractJavaLaunchConfigurationDelegate.java:363)
    at org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate.getVMSpecificAttributesMap(AbstractJavaLaunchConfigurationDelegate.java:679)
    at org.eclipse.jdt.launching.JavaLaunchDelegate.getVMRunnerConfiguration(JavaLaunchDelegate.java:92)
    at org.eclipse.jdt.launching.JavaLaunchDelegate.launch(JavaLaunchDelegate.java:160)
    at org.eclipse.m2e.internal.launch.MavenLaunchDelegate.launch(MavenLaunchDelegate.java:132)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:806)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:717)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1021)
    at org.eclipse.debug.internal.ui.DebugUIPlugin$2.run(DebugUIPlugin.java:1224)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
laeubi commented 1 year ago

The problem is when you launch a pom.xml from a project that is an m2e -project but not a java project! In that case, we can't set the project because otherwise JDT complains!

HannesWell commented 1 year ago

The problem is when you launch a pom.xml from a project that is an m2e -project but not a java project! In that case, we can't set the project because otherwise JDT complains!

Can confirm that. Filtering the project optional if it is an existing java-project here, https://github.com/eclipse-m2e/m2e-core/blob/dc018c73e7ca9443277a737b2be743217a464596/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchDelegate.java#L231

Did the job for me. Something like the following lets the launch succeed for me.

    Optional<IProject> project = getContainer(pomDirectory).map(IContainer::getProject)
        .filter(p -> JavaCore.create(p).exists());
laeubi commented 1 year ago

Also in the launch config it looks a bit strange as it says there is no JRE should it not just use the workspace default JRE in such case? grafik