redhat-developer / vscode-java

Java Language Support for Visual Studio Code
Eclipse Public License 2.0
2.08k stars 438 forks source link

Building Java project shows error: "Build failed, do you want to continue?" #495

Open niiiksh opened 6 years ago

niiiksh commented 6 years ago

Building Java project shows error: "Build failed, do you want to continue?" when the build is actually completed because when I click "Proceed" it will run updated version of my code and autobuild enabled when I type new code. javatest.zip

Environment
Steps To Reproduce
  1. Open attached java project in Visual Studio Code with Java Extensions Pack installed
  2. Start debugging by F5

javatest.zip

.log

Current Result

Build error

Expected Result

No error

Additional Informations

I have another project built with this extension and it builds without any error.

wjx0912 commented 3 years ago

same problem, does it fixed?

himmish commented 3 years ago

My problem was that the promt showed build failed but if i click on proceed it work just fine. to remove the annoying promt all i did was: Go to java extension pack-> click on any extension settings icon -> click extension settings -> uncheck (Java › Debug › Settings: Force Build Before Launch)

I hope this answer helps

Zeba14 commented 3 years ago

Same problem , couldn't fix it

DoganM95 commented 3 years ago

Damn, this issue is now over 3 years old, still getting notifications on this

n614cd commented 2 years ago

I am getting a buildpath incomplete error on a multi-project build on Quartz. Short version:

Same error posted above.. Has anyone found a way to debug or printout what the compiler is doing?

snjeza commented 2 years ago

@n614cd could you, please, attach a project example?

n614cd commented 2 years ago

@snjeza

Unfortunately this is private code I am working with. I have tried to strip the project down multiple ways (such as removing the java source files). Once I strip the code from the project (I have tried to remove test code, all code, core libraries...). I am no longer getting the error. Which leads me to believe that the problem is less likely with the build itself, and more likely with some hidden error. Hence why I am trying to work it now before it somehow raises an issue in production.

Tim

BeMxself commented 2 years ago

If a maven module uses Lombok, it will build failed.

theAnkitt commented 2 years ago

I had the same issue but when i deleted the java file containing error in that same folder where current java file is, then warning disappeared. you can also try to delete the file or correct the code in the folder your are working in they error should disappear.

Nicolamunozi commented 2 years ago

This solve my problem. In my case, I'm using Vscode for developing in Java. For previous configurations (when I was studing Python) VSCode did create a .history folder containing versions of the code. Deleting that folder I could solve the problem.

Thanks!

@DoganM95

I guess you are trying to compile a .java file in a folder hierarchy where other .java files exist and have errors. check your "problems" tab and see if there are any. if so, the project will probably show the error message until all problems are resolved. After that you should stop getting the "Build failed..." Message.

a-st commented 1 year ago

@snjeza I manage to provide a sample project (like @n614cd) which showcases the issue. Please have a look at https://github.com/a-st/vscode-java-issue-495

After opening the project, vscode shows following problems image

snjeza commented 1 year ago

@a-st This is an upstream buildship issue - https://github.com/eclipse/buildship/issues/1131 You can try the following patch:

diff --git a/app_a/build.gradle b/app_a/build.gradle
index def2540..2305e10 100644
--- a/app_a/build.gradle
+++ b/app_a/build.gradle
@@ -1,6 +1,7 @@
 plugins {
     id 'java'
     id "org.springframework.boot"
+    id "eclipse"
 }

 dependencies {
@@ -9,4 +10,19 @@ dependencies {

     implementation group: 'org.springframework.boot', name: 'spring-boot-starter', version: '2.7.5'
     testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '2.7.5'
-}
\ No newline at end of file
+}
+
+eclipse {
+  classpath {
+    containsTestFixtures = true
+    file {
+        whenMerged {
+            cp -> cp.getEntries().forEach{
+                cpEntry -> if(cpEntry.kind=='src') {
+                    cpEntry.output = cpEntry.output.replace('bin/', 'build/classes/java/')
+                }
+            }
+        }
+    }
+  }
+}
diff --git a/module_a/build.gradle b/module_a/build.gradle
index aeb004d..92d39bc 100644
--- a/module_a/build.gradle
+++ b/module_a/build.gradle
@@ -1,6 +1,22 @@
 apply plugin: 'java-library'
+apply plugin: 'eclipse'

 dependencies {
     testImplementation project (':module_b').sourceSets.test.output
     testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '2.7.5'
+}
+
+eclipse {
+  classpath {
+    containsTestFixtures = true
+    file {
+        whenMerged {
+            cp -> cp.getEntries().forEach{
+                cpEntry -> if(cpEntry.kind=='src') {
+                    cpEntry.output = cpEntry.output.replace('bin/', 'build/classes/java/')
+                }
+            }
+        }
+    }
+  }
 }
\ No newline at end of file
diff --git a/module_b/build.gradle b/module_b/build.gradle
index 20a07af..ab40b96 100644
--- a/module_b/build.gradle
+++ b/module_b/build.gradle
@@ -1,5 +1,21 @@
 apply plugin: 'java-library'
+apply plugin: 'eclipse'

 dependencies {
     testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '2.7.5'
+}
+
+eclipse {
+  classpath {
+    containsTestFixtures = true
+    file {
+        whenMerged {
+            cp -> cp.getEntries().forEach{
+                cpEntry -> if(cpEntry.kind=='src') {
+                    cpEntry.output = cpEntry.output.replace('bin/', 'build/classes/java/')
+                }
+            }
+        }
+    }
+  }
 }
\ No newline at end of file