vscode-java-debug icon indicating copy to clipboard operation
vscode-java-debug copied to clipboard

Debugger mistakenly included Gradle build folder in classpaths

Open akaroml opened this issue 2 years ago • 3 comments
trafficstars

  1. Open spring-petclinic project using VS Code with Java Ext Pack installed
  2. When hint to choose between Maven or Gradle, pick Gradle and import the project
  3. In terminal, build the project using gradle by ./gradlew build
  4. Now launch the project, and inspect the argfile

Both bin and build folders are in the classpath, and it will introduce unexpected consequences.

For example, in the spring-petclinic project, the database initialization script will be executed twice due to the extra classpath entry, resulting in duplicated records in db. This is really hard to troubleshoot and will cause serious confusion.

build folder should not be included in this case.

akaroml avatar Mar 23 '23 08:03 akaroml

I couldn't reproduce the issue. Could you share how .classpath file looks like?

F1 -> Java: Open Java Language Server Log File -> Navigate the log directory to find the \redhat.java\jdt_ws\.metadata\.plugins\org.eclipse.core.resources\.projects\spring-petclinic\.classpath

testforstephen avatar Mar 24 '23 05:03 testforstephen

I finally reproduced this issue with latest https://github.com/spring-projects/spring-petclinic source code. I observed that Java Projects view also listed the build directory under "Project and External Dependencies" node.

image

This should be a bug of buildship, where the computed classpath from buildship includes the gradle build directory mistakenly.

// cc: @jdneo @CsCherrYY

testforstephen avatar Mar 28 '23 07:03 testforstephen

See https://github.com/spring-projects/spring-petclinic/issues/1213, this seems to be an issue with upstream spring gradle plugin.

testforstephen avatar Apr 04 '23 02:04 testforstephen