Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building a project never finishes #3639

Open
tsaarni opened this issue May 3, 2024 · 6 comments
Open

Building a project never finishes #3639

tsaarni opened this issue May 3, 2024 · 6 comments
Assignees
Labels

Comments

@tsaarni
Copy link

tsaarni commented May 3, 2024

Background:

I'm working on Keycloak using vscode-java. This project has proven to be quite challenging before, and unfortunately I now again have new problems that I'd kindly ask for help to troubleshoot.

The problem:

When opening the project the Java build never finishes. The constant re-compilation on the background will consume considerable CPU resources and heat up the machine.

The project builds correctly from command line using mvn.

Environment
  • Operating System: Ubuntu 23.10
  • JDK version: openjdk 17.0.10
  • Visual Studio Code version: 1.89.0
  • Java extension version: v1.30.0
Steps To Reproduce
  1. git clone https://github.com/keycloak/keycloak.git
  2. cd keycloak
  3. mvn clean install -DskipTestsuite -DskipExamples -DskipTests
  4. open vscode
  5. observe jdt starting to build the project but getting into infinite loop
Current Result

The loop that gets executed again and again consists of following sequence of maven modules (grepping from logs):

  message: '[Info  - 2:28:33 PM] May 3, 2024, 2:28:32 PM Built project keycloak-parent in 3798 ms',
  message: '[Info  - 2:28:34 PM] May 3, 2024, 2:28:34 PM Built project keycloak-admin-ui in 1665 ms',
  message: '[Info  - 2:28:34 PM] May 3, 2024, 2:28:34 PM Built project keycloak-distribution-licenses-common in 4 ms',
  message: '[Info  - 2:28:34 PM] May 3, 2024, 2:28:34 PM Built project keycloak-distribution-parent in 1 ms',
  message: '[Info  - 2:28:34 PM] May 3, 2024, 2:28:34 PM Built project keycloak-js-adapter in 3 ms',
  message: '[Info  - 2:28:34 PM] May 3, 2024, 2:28:34 PM Built project keycloak-js-admin-client in 48 ms',
  message: '[Info  - 2:28:35 PM] May 3, 2024, 2:28:35 PM Built project keycloak-js-parent in 479 ms',
  message: '[Info  - 2:28:36 PM] May 3, 2024, 2:28:36 PM Built project keycloak-account-ui in 1605 ms',
  message: '[Info  - 2:28:36 PM] May 3, 2024, 2:28:36 PM Built project keycloak-distribution-licenses-common in 5 ms',
  message: '[Info  - 2:28:36 PM] May 3, 2024, 2:28:36 PM Built project keycloak-distribution-parent in 1 ms',
  message: '[Info  - 2:28:36 PM] May 3, 2024, 2:28:36 PM Built project keycloak-js-parent in 1 ms',
  message: '[Info  - 2:28:40 PM] May 3, 2024, 2:28:40 PM Built project keycloak-parent in 3745 ms',
  message: '[Info  - 2:28:42 PM] May 3, 2024, 2:28:42 PM Built project keycloak-admin-ui in 1718 ms',
  message: '[Info  - 2:28:42 PM] May 3, 2024, 2:28:42 PM Built project keycloak-distribution-licenses-common in 6 ms',
  message: '[Info  - 2:28:42 PM] May 3, 2024, 2:28:42 PM Built project keycloak-distribution-parent in 1 ms',
  message: '[Info  - 2:28:42 PM] May 3, 2024, 2:28:42 PM Built project keycloak-js-adapter in 5 ms',
  message: '[Info  - 2:28:42 PM] May 3, 2024, 2:28:42 PM Built project keycloak-js-admin-client in 49 ms',
  message: '[Info  - 2:28:42 PM] May 3, 2024, 2:28:42 PM Built project keycloak-js-parent in 486 ms',
  message: '[Info  - 2:28:44 PM] May 3, 2024, 2:28:44 PM Built project keycloak-account-ui in 1663 ms',
  message: '[Info  - 2:28:44 PM] May 3, 2024, 2:28:44 PM Built project keycloak-distribution-licenses-common in 5 ms',
  message: '[Info  - 2:28:44 PM] May 3, 2024, 2:28:44 PM Built project keycloak-distribution-parent in 0 ms',
  message: '[Info  - 2:28:44 PM] May 3, 2024, 2:28:44 PM Built project keycloak-js-parent in 1 ms',

it will then start from the keycloak-parent again, and continue forever, trying to build this set of modules. I'm not able to identify the reason why the build is (re)triggered again and again.

Here are some log files from build:

Expected Result

Build should finish.

Additional Informations

I'm enabled following logs in .vscode/settings.json

  "java.jdt.ls.vmargs": "-Dlog.level=ALL -Djdt.ls.debug=true -Dmaven.plugin.validation=verbose -Xmx16G -Xms100m",
  "java.trace.server": "verbose",

I've also tried excluding submodules by adding following in .vscode/settings.json but build still gets stuck in the same way, even though in theory the looping modules should not even be imported anymore

  "java.import.exclusions": [
        "**/node_modules/**",
        "**/node/**",
        "**/js/**",
        "**/distribution/**",
        "**/themes/**"
  ]

Some time ago I could open the project without infinite build loop. I did not use exclusions or any other workarounds in settings. At the moment, I do not yet know if my problem appeared after changes in Keycloak code or possibly after vscode-java update, or something else.

@rgrunber rgrunber added the bug label May 3, 2024
@rgrunber
Copy link
Member

rgrunber commented May 3, 2024

I'm able to reproduce this as well, though I needed -Xmx4G instead of 1G for java.jdt.ls.vmargs to fully import.

The thing that immediately stood out, and which I saw in my logs as well is :

{   
  message: "[Trace - 10:30:08] Sending notification 'workspace/didChangeWatchedFiles'.",
  level: 'info',
  timestamp: '2024-05-03 10:30:08.190'
}
{
  message: 'Params: {\n' +
    '    "changes": [\n' +
    '        {\n' +
    '            "uri": "file:///home/rgrunber/sample-projects/keycloak/distribution/licenses-common/target/classes/keycloak-licenses-common/LICENSE.txt",\n' +
    '            "type": 2\n' +
    '        }\n' +
    '    ]\n' +
    '}\n' +
    '\n',
  level: 'info',
  timestamp: '2024-05-03 10:30:08.190'
}

Other than progress & diagnostic notifications, I didn't see anything else in the build process that might be responsible for triggering a rebuild.

I think https://github.com/eclipse-jdtls/eclipse.jdt.ls/blob/d6bc183c77428d586b58fe8a5afcd8bd4bc98f20/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/JDTUtils.java#L1266 ( eclipse-jdtls/eclipse.jdt.ls#1207 ) might be responsible since I can stop the cycle just by setting the parent to null.

The pom is https://github.com/keycloak/keycloak/blob/main/distribution/licenses-common/pom.xml and the configuration is handled by build-helper-maven-plugin.

@snjeza , any idea why this happens or how we could deal with it ?

@snjeza
Copy link
Contributor

snjeza commented May 6, 2024

The issue is caused by the maven-antrun-plugin plugin. It creates a java project and restarts the build.
A workaround

  • set
 "java.configuration.maven.defaultMojoExecutionAction": "ignore",`

You can also try VS Code 1.32.0. See eclipse-jdtls/eclipse.jdt.ls#3150

@tsaarni
Copy link
Author

tsaarni commented May 6, 2024

Thanks @snjeza and @rgrunber!

I tried both:

  • setting java.configuration.maven.defaultMojoExecutionAction to ignore (though the readme says ignore is the default?)
  • Installing vscode-java build from your repo

but for some reason, these did not help for me. I still end up in build that never finishes.

As @rgrunber pointed out license file generation, I now tested removing following lines from Keycloak https://github.com/keycloak/keycloak/blob/6a38be6239ad9dad7fb0c4941c117eddadc7958b/distribution/licenses-common/pom.xml#L30-L44. That allowed me to open and build the project again, so it is true that it is the culprit.

@rgrunber
Copy link
Member

rgrunber commented May 6, 2024

I tried eclipse-jdtls/eclipse.jdt.ls#3150 as well and it didn't stop the build loop. I tried with a clear workspace cache for the keycloak project. The default is definitely ignore for java.configuration.maven.defaultMojoExecutionAction so it had no effect.

It could just be that the issues fixed there have no effect here.

Update: Ok, I saw one instance where the build loop stopped after maybe about 6 consecutive build operations. I think I'd have to run this some more times before/after the change to see if it actually improves it or if there's some chance the build loop doesn't occur.

@snjeza
Copy link
Contributor

snjeza commented May 6, 2024

@rgrunber You are right. The keycloak project has other issues. However, eclipse-jdtls/eclipse.jdt.ls#3150 should help.
Did you try the following:

$ cd keycloak
$ code .
wait for the build to finish
reload the VS Code window (this step should be much faster with #3150)

The build should also be faster because we postponed workspace/didChangeWatchedFiles after finishing the build. See eclipse-jdtls/eclipse.jdt.ls@cfb076c#diff-a5ac9de1e29f9f41ff8198d1422328687328e9daacea58594ecd68b4ecde2311R61

@snjeza
Copy link
Contributor

snjeza commented May 7, 2024

... or if there's some chance the build loop doesn't occur.

I will check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants