vscode-maven icon indicating copy to clipboard operation
vscode-maven copied to clipboard

Maven build fails when VSCode is open.

Open alphanout opened this issue 4 years ago • 6 comments
trafficstars

When I run command mvn clean install It gives a compilation error because AspectJ was unable to compile classes.

But when I run this above command when VSCode is closed and then run normally on terminal it works fine.

I know AspectJ doesn't support VSCode but it should be built my project when VSCode is open.

The error which I face is -

[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.11:compile (default) on project task-management: AJC compiler errors: [ERROR] error at import com.annotations.DataSourceSelector; [ERROR] /Users/b0224378/Documents/workspace/task-manager/src/main/java/com/config/datasource/DataSourceSelectorAspect.java:3:0::0 The import com.annotations.DataSourceSelector cannot be resolved

Environments:

  • OS: MacOs Big sure 11.5.1
  • VS Code version: 1.59.0
  • Extension version v0.32.2

Pom.xml config-

Screenshot 2021-08-09 at 11 23 39 PM

I have also tried adding m2e execute onConfiguration,onIncremental in executions But it didn't work.

alphanout avatar Aug 09 '21 17:08 alphanout

Is it possible that Java Language Server is doing something wrong? @testforstephen can you take a look?

Eskibear avatar Aug 10 '21 02:08 Eskibear

Any updates?

Is it possible that Java Language Server is doing something wrong? @testforstephen can you take a look?

alphanout avatar Aug 19 '21 22:08 alphanout

Looks like the autobuild of vscode-java extension conflicts with the command line mvn build. Can you try to change the user setting java.autobuild.enabled to false to see whether it works?

testforstephen avatar Aug 20 '21 01:08 testforstephen

Yes, after setting java.autobuild.enabled to false, I ran mvn install and my build was successful.

alphanout avatar Aug 20 '21 18:08 alphanout

I've also been seeing random build failures when running maven from the command line for some projects. Is this something that will be resolved at some point or is the only fix to disable autobuilds as per above?

yeroc avatar Oct 01 '21 20:10 yeroc

For anyone stumbling upon this issue: This is the corresponding issue in the vscode-java plugin: redhat-developer/vscode-java#1381

schmidti159 avatar Apr 21 '22 06:04 schmidti159