Duplicate results when finding owners
CsCherrYY opened this issue · comments
Issue
This issue can be reproduced in both VS Code and eclipse.
Steps to reproduce:
- Given the newest spring-petclinic (0962ed7 for now)
- run
./gradlew build
in the project folder - Open the project in either VS Code or eclipse, import as Gradle project, and wait for the project imported
- Run the spring-petclinic application, and open the browser
- Go to "Find Owners" page, input "C" and try to find Owner
- We can see the result:
Finding
- We can find there are several unexpected source folders in the project dependencies, view the project dependencies:
- in VS Code, open "Java Projects" view, expand "Project and External Dependencies" node
- in eclipse, open "Package Explorer" view, expand "Project and External Dependencies" node
I can confirm before commit 0962ed7 everything works well. The root cause is that Gradle plugin org.graalvm.buildtools.native
, which will introduce the spring aot plugin org.springframework.boot.aot
that causes this issue. After disabling that plugin, the application works well.
if you can't reproduce this issue, please run ./gradlew build
and clean workspace, see step 2 above.
It seems to be an issue with vscode/buildship not the PetClinic? Is there anything we can do here?
It looks like the issue is related to the interaction between aot plugin and buildship/Gradle eclipse plugin. I guess the root cause is about the aot plugin will add each source set's output to the runtime classpath. See : https://github.com/spring-projects/spring-boot/blob/5d49889bfde45ec0cf1d73b96ae61096add9dae7/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/SpringBootAotPlugin.java#L78 and https://github.com/spring-projects/spring-boot/blob/5d49889bfde45ec0cf1d73b96ae61096add9dae7/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/SpringBootAotPlugin.java#L92
I'm not sure I follow that reasoning. I also can't reproduce the problem - maybe you have a different version of the VSCode plugins (I have the "Extension Pack for Java" v0.25.10)? I can see that there are duplicate .class
files in the runtime classpath, but I don't understand how the extra database records get created because the .sql
scripts are resources (not classes) and they are not duplicated in the runtime classpath.
Nevermind, I can reproduce it now. I don't think I was using Gradle in VSCode before. We should open an issue in Spring Boot. Do you want to do that?
Do you want to do that?
Can we just transfer this issue there and change the title? If that's not suitable, I can create a new issue there.
The Boot team say it's a problem in Buildship, so you should open the issue there (and this one can't be transferred). I have a small reproducer if you want to link to that, or copy it: https://github.com/scratches/gradle-aot.
@dsyer Thanks a lot for the project, that's cool! issue created: eclipse/buildship#1236
@dsyer You can try the following patch
diff --git a/build.gradle b/build.gradle
index d0a34bf..aeee005 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,6 +3,7 @@ plugins {
id 'org.springframework.boot' version '3.0.4'
id 'io.spring.dependency-management' version '1.1.0'
id 'org.graalvm.buildtools.native' version '0.9.20'
+ id 'eclipse'
}
apply plugin: 'java'
@@ -40,3 +41,18 @@ dependencies {
tasks.named('test') {
useJUnitPlatform()
}
+
+eclipse {
+ classpath {
+ defaultOutputDir = file('build-default')
+ file {
+ whenMerged {
+ cp -> cp.getEntries().forEach{
+ cpEntry -> if(cpEntry.path=='src/main/resources') {
+ cpEntry.output = 'build/resources/main'
+ }
+ }
+ }
+ }
+ }
+}