microsoft / vscode-maven

VSCode extension "Maven for Java"
https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-maven
Other
182 stars 88 forks source link

Incorrect debug invocation of `exec:java` on Windows #913

Closed ThePrez closed 1 year ago

ThePrez commented 1 year ago
Environment
Steps To Reproduce
  1. In Maven view ---> "Plugins"
  2. expand the "exec" plugin
  3. Right-click on "java" and go to "Run". Observe that the program runs correctly
  4. Right-click on "java" and go to "Debug"

Log info:

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-12-03 14:59:21.641
!MESSAGE >> workspace/executeCommand vscode.java.startDebugSession

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-12-03 14:59:23.938
!MESSAGE >> workspace/executeCommand vscode.java.fetchUsageData
Current Result

mvn is invoked with "java" on the command line image (this results in a failure due to "java" being an unknown lifecycle phase)

Expected Result

mvn is invoked with "exec:java" on the command line, as is done properly when the "run" action is taken from the plugin

Additional Informations

pom.xml plugin entry:

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>3.1.0</version>
        <configuration>
          <mainClass>io.github.theprez.jtailor.CamelMeUp</mainClass>
          <includePluginDependencies>false</includePluginDependencies>
        </configuration>
      </plugin>
testforstephen commented 1 year ago

this behavior is contributed by https://github.com/microsoft/vscode-maven/issues/, I will transfer this issue to vscode-maven extension for a look. @Eskibear

Eskibear commented 1 year ago

@ThePrez What's the version of your installed "Maven for Java" extension?

It's fixed in v0.40.1. See https://github.com/microsoft/vscode-maven/issues/910

ThePrez commented 1 year ago

@ThePrez What's the version of your installed "Maven for Java" extension?

It's fixed in v0.40.1. See #910

I am running v0.40.1. I also tried v0.40.2022120203 as the most recent release and see the behavior there as well. Uninstalling/reinstalling also does not fix. I also looked in the installed JS on my PC at %USERPROFILE%\.vscode\extensions\vscjava.vscode-maven-0.40.1\dist\extension.js and verified that the code fix is there, but the faulty behavior persists.

Upon cursory inspection of the code, I am curious if the check here is being incorrectly triggered because my maven command, having a fully-qualified Windows path, contains a : (actually two: one for the maven command and one for the fully-qualified path to the pom.xml). I can't figure out a way to test this hypothesis configuration or command line options, though.

ThePrez commented 1 year ago

Upon cursory inspection of the code, I am curious if the check here is being incorrectly triggered because my maven command, having a fully-qualified Windows path, contains a : (actually two: one for the maven command and one for the fully-qualified path to the pom.xml).

After some more code inspection, I don't think this is it. :/

Eskibear commented 1 year ago

I just tried the exec-maven-plugin as you mentioned above but failed to reproduce the issue, it ran exec:java as expected.

Can you check if your maven explorer looks like below? i.e. parent node of java is exec. image

Eskibear commented 1 year ago

Ok now I can reproduce it. It only occur when you "debug" it instead of "run".

Eskibear commented 1 year ago

@ThePrez

It's fixed and shipped in v0.40.2022120507. You can switch to pre-release version to try it.

ThePrez commented 1 year ago

Works beautifully. Thanks!