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

Question: Is multi-module maven projects compiled using multiple threads? #3380

Closed
tsaarni opened this issue Nov 8, 2023 · 14 comments · Fixed by eclipse-jdtls/eclipse.jdt.ls#2976
Assignees
Labels

Comments

@tsaarni
Copy link

tsaarni commented Nov 8, 2023

Question: I would like to know if vscode-java is compiling multi-module maven project in parallel, using multiple threads?

Is there way to control that?

I have a problem opening maven-based project in vscode. It seems to result in broken build. I suspect the problem might originate from the maven project, which does not compile in parallel due to conflicts between its modules. The errors in language server logs look similar to what I get if I compile the project by using mvn -T4C clean install on command line.

Environment
  • Operating System: Linux / Ubuntu 22.04
  • JDK version: 17
  • Visual Studio Code version: October 2023 1.84.1
  • Java extension version: 1.24.0
Steps To Reproduce

The project I'm working with is Keycloak. Here is an overview of the problem I'm experiencing:

  1. I compile project on command line mvn clean install -DskipTests. I'm able to run the application from the project directory.
  2. I then open the project in vscode. I wait for vscode-java to compile the workspace.
  3. After this the application cannot be executed and the build in the project directory seems to be in inconsistent state.

The situation seems tricky to me: for working with the code, I need vscode. For running the code, I cannot have vscode open.

I'd be grateful for any tips on how to work with a project that does not compile with vscode-java.

@snjeza
Copy link
Contributor

snjeza commented Nov 10, 2023

@tsaarni You may want to take a look at #2537 (comment)

@tsaarni
Copy link
Author

tsaarni commented Nov 10, 2023

Thanks @snjeza 😅 I did try that then, but it ended being impossible to come up with a working set of exclusions for that project. Also, Keycloak luckily changed to direction that it was possible to work with it in vscode, until now.

To answer to my own question about if maven projects are executed in parallel by vscode-java: no, I do not believe so.

I have now learned that the maven implementation used is called m2eclipse or m2e and that it sometimes acts differently compared to maven, in this case in context of maven-replacer-plugin and frontend-maven-plugin, which were recently introduced to the project. After investigating this, I do not think there is any settings on vscode-java side that would help.

@tsaarni tsaarni closed this as completed Nov 10, 2023
@snjeza
Copy link
Contributor

snjeza commented Nov 10, 2023

@tsaarni could you try the following:

  1. set the property
"java.import.exclusions": [
        "**/node_modules/**",
        "**/.metadata/**",
        "**/archetype-resources/**",
        "**/META-INF/maven/**",
        "**/themes/**",
        "**/js/**",
        "**/node/**",
        "**/testsuite/**",
        "**/distribution/**",
        "**/docs/**",
    ],

  1. apply the patch
diff --git a/adapters/oidc/jakarta-servlet-filter/pom.xml b/adapters/oidc/jakarta-servlet-filter/pom.xml
index c2105f8e1e..de588c411b 100755
--- a/adapters/oidc/jakarta-servlet-filter/pom.xml
+++ b/adapters/oidc/jakarta-servlet-filter/pom.xml
@@ -114,6 +114,7 @@
                 <version>3.0.0</version>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <id>transform</id>
                         <phase>initialize</phase>
                         <goals>
diff --git a/adapters/oidc/js/pom.xml b/adapters/oidc/js/pom.xml
index f2f1488e03..c80f7b3b0a 100644
--- a/adapters/oidc/js/pom.xml
+++ b/adapters/oidc/js/pom.xml
@@ -53,6 +53,7 @@
                 <artifactId>frontend-maven-plugin</artifactId>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <goals>
                             <goal>install-node-and-pnpm</goal>
                         </goals>
diff --git a/adapters/saml/jakarta-servlet-filter/pom.xml b/adapters/saml/jakarta-servlet-filter/pom.xml
index f7ee0ee6bc..6c67c33373 100755
--- a/adapters/saml/jakarta-servlet-filter/pom.xml
+++ b/adapters/saml/jakarta-servlet-filter/pom.xml
@@ -96,6 +96,7 @@
                 <version>3.0.0</version>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <id>transform</id>
                         <phase>initialize</phase>
                         <goals>
diff --git a/adapters/saml/wildfly-elytron-jakarta/pom.xml b/adapters/saml/wildfly-elytron-jakarta/pom.xml
index c6b6ff388d..6de435a86f 100755
--- a/adapters/saml/wildfly-elytron-jakarta/pom.xml
+++ b/adapters/saml/wildfly-elytron-jakarta/pom.xml
@@ -112,6 +112,7 @@
                 <version>3.0.0</version>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <id>transform</id>
                         <phase>initialize</phase>
                         <goals>
diff --git a/adapters/saml/wildfly/wildfly-jakarta-subsystem/pom.xml b/adapters/saml/wildfly/wildfly-jakarta-subsystem/pom.xml
index 016a1037a8..d9056374d5 100755
--- a/adapters/saml/wildfly/wildfly-jakarta-subsystem/pom.xml
+++ b/adapters/saml/wildfly/wildfly-jakarta-subsystem/pom.xml
@@ -47,6 +47,7 @@
                 <version>3.0.0</version>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <id>transform</id>
                         <phase>initialize</phase>
                         <goals>
diff --git a/distribution/maven-plugins/pom.xml b/distribution/maven-plugins/pom.xml
index fe9b7db2e3..b642a0d7e2 100644
--- a/distribution/maven-plugins/pom.xml
+++ b/distribution/maven-plugins/pom.xml
@@ -85,6 +85,7 @@
                     <artifactId>maven-plugin-plugin</artifactId>
                     <executions>
                         <execution>
+                            <?m2e ignore>
                             <id>generate-descriptor</id>
                             <goals>
                                 <goal>descriptor</goal>
diff --git a/distribution/saml-adapters/wildfly-adapter/wildfly-adapter-jakarta-zip/pom.xml b/distribution/saml-adapters/wildfly-adapter/wildfly-adapter-jakarta-zip/pom.xml
index 794389bd16..ef0f063f6c 100755
--- a/distribution/saml-adapters/wildfly-adapter/wildfly-adapter-jakarta-zip/pom.xml
+++ b/distribution/saml-adapters/wildfly-adapter/wildfly-adapter-jakarta-zip/pom.xml
@@ -67,6 +67,7 @@
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <id>generate-jakarta-cli</id>
                         <phase>prepare-package</phase>
                         <configuration>
diff --git a/distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/pom.xml b/distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/pom.xml
index db6047180c..37ed321763 100755
--- a/distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/pom.xml
+++ b/distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/pom.xml
@@ -174,6 +174,7 @@
                 <inherited>false</inherited>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <id>build-dist</id>
                         <goals>
                             <goal>run</goal>
diff --git a/distribution/saml-adapters/wildfly-adapter/wildfly-modules/pom.xml b/distribution/saml-adapters/wildfly-adapter/wildfly-modules/pom.xml
index 68cc6b7070..f3aedfdef9 100755
--- a/distribution/saml-adapters/wildfly-adapter/wildfly-modules/pom.xml
+++ b/distribution/saml-adapters/wildfly-adapter/wildfly-modules/pom.xml
@@ -174,6 +174,7 @@
                 <inherited>false</inherited>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <id>build-dist</id>
                         <goals>
                             <goal>run</goal>
diff --git a/docs/documentation/aggregation/pom.xml b/docs/documentation/aggregation/pom.xml
index af92b7cdde..010701fc7a 100644
--- a/docs/documentation/aggregation/pom.xml
+++ b/docs/documentation/aggregation/pom.xml
@@ -212,6 +212,7 @@
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <id>echo-output-aggregation</id>
                         <phase>process-resources</phase>
                         <goals>
diff --git a/docs/documentation/api_documentation/pom.xml b/docs/documentation/api_documentation/pom.xml
index 580cefbb33..07bb722a9a 100644
--- a/docs/documentation/api_documentation/pom.xml
+++ b/docs/documentation/api_documentation/pom.xml
@@ -37,6 +37,7 @@
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <id>echo-output</id>
                     </execution>
                 </executions>
diff --git a/docs/documentation/authorization_services/pom.xml b/docs/documentation/authorization_services/pom.xml
index 6e1042aa84..847d4bbee0 100644
--- a/docs/documentation/authorization_services/pom.xml
+++ b/docs/documentation/authorization_services/pom.xml
@@ -37,6 +37,7 @@
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <id>echo-output</id>
                     </execution>
                 </executions>
diff --git a/docs/documentation/header-maven-plugin/pom.xml b/docs/documentation/header-maven-plugin/pom.xml
index 13fc1f6357..dc31ef82a4 100644
--- a/docs/documentation/header-maven-plugin/pom.xml
+++ b/docs/documentation/header-maven-plugin/pom.xml
@@ -55,6 +55,7 @@
                 </configuration>
                 <executions>
                     <execution>
+                        <?m2e ignore>
                         <id>mojo-descriptor</id>
                         <goals>
                             <goal>descriptor</goal>
diff --git a/docs/documentation/pom.xml b/docs/documentation/pom.xml
index a29f0e5d39..156004abb0 100644
--- a/docs/documentation/pom.xml
+++ b/docs/documentation/pom.xml
@@ -88,6 +88,7 @@
                     <version>${version.plugin.antrun}</version>
                     <executions>
                         <execution>
+                            <?m2e ignore?>
                             <id>echo-output</id>
                             <phase>generate-resources</phase>
                             <goals>
diff --git a/docs/documentation/release_notes/pom.xml b/docs/documentation/release_notes/pom.xml
index 57d62bebae..4aa0511a5f 100644
--- a/docs/documentation/release_notes/pom.xml
+++ b/docs/documentation/release_notes/pom.xml
@@ -31,6 +31,7 @@
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <id>echo-output</id>
                     </execution>
                 </executions>
diff --git a/docs/documentation/securing_apps/pom.xml b/docs/documentation/securing_apps/pom.xml
index 6d8dce060e..61d889c69c 100644
--- a/docs/documentation/securing_apps/pom.xml
+++ b/docs/documentation/securing_apps/pom.xml
@@ -37,6 +37,7 @@
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <id>echo-output</id>
                     </execution>
                 </executions>
diff --git a/docs/documentation/server_admin/pom.xml b/docs/documentation/server_admin/pom.xml
index cb0c3fdffe..9ca7d97685 100644
--- a/docs/documentation/server_admin/pom.xml
+++ b/docs/documentation/server_admin/pom.xml
@@ -37,6 +37,7 @@
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <id>echo-output</id>
                     </execution>
                 </executions>
diff --git a/docs/documentation/server_development/pom.xml b/docs/documentation/server_development/pom.xml
index 6e0ec2e820..643fada7f7 100644
--- a/docs/documentation/server_development/pom.xml
+++ b/docs/documentation/server_development/pom.xml
@@ -37,6 +37,7 @@
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <id>echo-output</id>
                     </execution>
                 </executions>
diff --git a/docs/documentation/upgrading/pom.xml b/docs/documentation/upgrading/pom.xml
index 9c081109a5..1e37e4f557 100644
--- a/docs/documentation/upgrading/pom.xml
+++ b/docs/documentation/upgrading/pom.xml
@@ -37,6 +37,7 @@
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <id>echo-output</id>
                     </execution>
                 </executions>
diff --git a/integration/admin-client/pom.xml b/integration/admin-client/pom.xml
index b1b9a79cfa..b2d0c4c44e 100755
--- a/integration/admin-client/pom.xml
+++ b/integration/admin-client/pom.xml
@@ -87,6 +87,7 @@
                 <version>3.0.0</version>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <id>transform</id>
                         <phase>initialize</phase>
                         <goals>
diff --git a/js/apps/account-ui/pom.xml b/js/apps/account-ui/pom.xml
index 2eb40d0362..8544e2d601 100644
--- a/js/apps/account-ui/pom.xml
+++ b/js/apps/account-ui/pom.xml
@@ -36,6 +36,7 @@
                 <artifactId>frontend-maven-plugin</artifactId>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <goals>
                             <goal>install-node-and-pnpm</goal>
                         </goals>
@@ -65,6 +66,7 @@
                 <artifactId>maven-replacer-plugin</artifactId>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <phase>process-resources</phase>
                         <goals>
                             <goal>replace</goal>
diff --git a/js/apps/admin-ui/pom.xml b/js/apps/admin-ui/pom.xml
index bb8c059f4c..b6522bd878 100644
--- a/js/apps/admin-ui/pom.xml
+++ b/js/apps/admin-ui/pom.xml
@@ -78,6 +78,7 @@
                 <artifactId>frontend-maven-plugin</artifactId>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <goals>
                             <goal>install-node-and-pnpm</goal>
                         </goals>
@@ -107,6 +108,7 @@
                 <artifactId>maven-replacer-plugin</artifactId>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <phase>process-resources</phase>
                         <goals>
                             <goal>replace</goal>
diff --git a/js/libs/keycloak-admin-client/pom.xml b/js/libs/keycloak-admin-client/pom.xml
index d6b8c82c4e..18455aa5b5 100644
--- a/js/libs/keycloak-admin-client/pom.xml
+++ b/js/libs/keycloak-admin-client/pom.xml
@@ -29,6 +29,7 @@
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <id>create-target-dir</id>
                         <phase>prepare-package</phase>
                         <configuration>
@@ -47,6 +48,7 @@
                 <artifactId>frontend-maven-plugin</artifactId>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <goals>
                             <goal>install-node-and-pnpm</goal>
                         </goals>
diff --git a/js/libs/keycloak-js/pom.xml b/js/libs/keycloak-js/pom.xml
index 2a6543760c..79fdec79d8 100644
--- a/js/libs/keycloak-js/pom.xml
+++ b/js/libs/keycloak-js/pom.xml
@@ -29,6 +29,7 @@
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <id>create-target-dir</id>
                         <phase>prepare-package</phase>
                         <configuration>
@@ -47,6 +48,7 @@
                 <artifactId>frontend-maven-plugin</artifactId>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <goals>
                             <goal>install-node-and-pnpm</goal>
                         </goals>
diff --git a/js/pom.xml b/js/pom.xml
index 27f67e4663..3f99c371f2 100644
--- a/js/pom.xml
+++ b/js/pom.xml
@@ -36,6 +36,7 @@
                 <artifactId>frontend-maven-plugin</artifactId>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <goals>
                             <goal>install-node-and-pnpm</goal>
                         </goals>
diff --git a/testsuite/integration-arquillian/servers/adapter-spi/undertow-adapter-jakarta/pom.xml b/testsuite/integration-arquillian/servers/adapter-spi/undertow-adapter-jakarta/pom.xml
index 7539a2caf5..74d9487e2f 100644
--- a/testsuite/integration-arquillian/servers/adapter-spi/undertow-adapter-jakarta/pom.xml
+++ b/testsuite/integration-arquillian/servers/adapter-spi/undertow-adapter-jakarta/pom.xml
@@ -98,6 +98,7 @@
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <id>transform</id>
                         <phase>initialize</phase>
                         <goals>
diff --git a/testsuite/integration-arquillian/servers/adapter-spi/undertow-adapter-saml-jakarta/pom.xml b/testsuite/integration-arquillian/servers/adapter-spi/undertow-adapter-saml-jakarta/pom.xml
index 2745582341..1d10d76613 100644
--- a/testsuite/integration-arquillian/servers/adapter-spi/undertow-adapter-saml-jakarta/pom.xml
+++ b/testsuite/integration-arquillian/servers/adapter-spi/undertow-adapter-saml-jakarta/pom.xml
@@ -88,6 +88,7 @@
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <id>transform</id>
                         <phase>initialize</phase>
                         <goals>
diff --git a/testsuite/integration-arquillian/servers/adapter-spi/undertow-adapter-spi-jakarta/pom.xml b/testsuite/integration-arquillian/servers/adapter-spi/undertow-adapter-spi-jakarta/pom.xml
index 3fe965d904..4e37e2878b 100644
--- a/testsuite/integration-arquillian/servers/adapter-spi/undertow-adapter-spi-jakarta/pom.xml
+++ b/testsuite/integration-arquillian/servers/adapter-spi/undertow-adapter-spi-jakarta/pom.xml
@@ -44,6 +44,7 @@
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <id>transform</id>
                         <phase>initialize</phase>
                         <goals>
diff --git a/testsuite/integration-arquillian/servers/app-server/jboss/eap6/pom.xml b/testsuite/integration-arquillian/servers/app-server/jboss/eap6/pom.xml
index e5bbcdd78b..47b3cb61dc 100644
--- a/testsuite/integration-arquillian/servers/app-server/jboss/eap6/pom.xml
+++ b/testsuite/integration-arquillian/servers/app-server/jboss/eap6/pom.xml
@@ -266,6 +266,7 @@
                         <artifactId>maven-antrun-plugin</artifactId>
                         <executions>
                             <execution>
+                                <?m2e ignore?>
                                 <id>move-configs-fuse</id>
                                 <phase>process-test-sources</phase>
                                 <goals>
diff --git a/testsuite/integration-arquillian/servers/auth-server/quarkus/pom.xml b/testsuite/integration-arquillian/servers/auth-server/quarkus/pom.xml
index 1d6c3b4406..b305980cea 100644
--- a/testsuite/integration-arquillian/servers/auth-server/quarkus/pom.xml
+++ b/testsuite/integration-arquillian/servers/auth-server/quarkus/pom.xml
@@ -238,6 +238,7 @@
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <id>ant-generate-default</id>
                         <phase>generate-resources</phase>
                         <goals>
diff --git a/testsuite/integration-arquillian/servers/cache-server/infinispan/pom.xml b/testsuite/integration-arquillian/servers/cache-server/infinispan/pom.xml
index 80b68a9d82..4444123614 100644
--- a/testsuite/integration-arquillian/servers/cache-server/infinispan/pom.xml
+++ b/testsuite/integration-arquillian/servers/cache-server/infinispan/pom.xml
@@ -220,6 +220,7 @@
                         <artifactId>maven-antrun-plugin</artifactId>
                         <executions>
                             <execution>
+                                <?m2e ignore?>
                                 <id>remove-empty-xmlns</id>
                                 <phase>process-test-resources</phase>
                                 <goals>
diff --git a/testsuite/integration-arquillian/test-apps/test-apps-dist/pom.xml b/testsuite/integration-arquillian/test-apps/test-apps-dist/pom.xml
index e937de7a67..08fe714e88 100644
--- a/testsuite/integration-arquillian/test-apps/test-apps-dist/pom.xml
+++ b/testsuite/integration-arquillian/test-apps/test-apps-dist/pom.xml
@@ -31,6 +31,7 @@
                 <inherited>false</inherited>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <id>build-test-apps</id>
                         <goals>
                             <goal>run</goal>
diff --git a/testsuite/integration-arquillian/tests/base/pom.xml b/testsuite/integration-arquillian/tests/base/pom.xml
index dae7c005a6..c4b3c73327 100644
--- a/testsuite/integration-arquillian/tests/base/pom.xml
+++ b/testsuite/integration-arquillian/tests/base/pom.xml
@@ -248,6 +248,7 @@
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>
                     <execution>
+                        <?m2e ignore?>
                         <phase>process-test-resources</phase>
                         <goals>
                             <goal>run</goal>
diff --git a/testsuite/integration-arquillian/tests/pom.xml b/testsuite/integration-arquillian/tests/pom.xml
index 7f2d9ac546..a52e1c55f4 100644
--- a/testsuite/integration-arquillian/tests/pom.xml
+++ b/testsuite/integration-arquillian/tests/pom.xml
@@ -467,6 +467,7 @@
                     <artifactId>maven-antrun-plugin</artifactId>
                     <executions>
                         <execution>
+                            <?m2e ignore?>
                             <id>clean-second-cache-server-arquillian-bug-workaround</id><!--https://issues.jboss.org/browse/WFARQ-44-->
                             <phase>process-test-resources</phase>
                             <goals><goal>run</goal></goals>
@@ -904,6 +905,7 @@
                             <artifactId>maven-antrun-plugin</artifactId>
                             <executions>
                                 <execution>
+                                    <?m2e ignore?>
                                     <id>copy-auth-server-crossdc-nodes</id>
                                     <phase>process-resources</phase>
                                     <goals>
@@ -1222,6 +1224,7 @@
                             <artifactId>maven-antrun-plugin</artifactId>
                             <executions>
                                 <execution>
+                                    <?m2e ignore?>
                                     <id>copy-cache-server-standalone-infinispan-nodes</id>
                                     <phase>process-resources</phase>
                                     <goals>
@@ -1319,6 +1322,7 @@
                             <artifactId>maven-antrun-plugin</artifactId>
                             <executions>
                                 <execution>
+                                    <?m2e ignore?>
                                     <id>copy-cache-server-standalone-infinispan-nodes</id>
                                     <phase>process-resources</phase>
                                     <goals>
diff --git a/themes/pom.xml b/themes/pom.xml
index 4a878a781a..7c88203160 100755
--- a/themes/pom.xml
+++ b/themes/pom.xml
@@ -126,6 +126,7 @@
                         <artifactId>frontend-maven-plugin</artifactId>
                         <executions>
                             <execution>
+                                <?m2e ignore?>
                                 <id>install-node-and-pnpm-account2</id>
                                 <goals>
                                     <goal>install-node-and-pnpm</goal>
@@ -181,6 +182,7 @@
                         <artifactId>frontend-maven-plugin</artifactId>
                         <executions>
                             <execution>
+                                <?m2e ignore?>
                                 <id>install-node-and-pnpm-common</id>
                                 <goals>
                                     <goal>install-node-and-pnpm</goal>
  1. Clean the workspace directory

@snjeza snjeza reopened this Nov 10, 2023
@tsaarni
Copy link
Author

tsaarni commented Nov 15, 2023

Really big thanks @snjeza for helping me understand the problem!

What I believe is happening, is that m2e will run clean phase when I open vscode which removes some necessary files to run Keycloak that were previously successfully built via command line (in js and themes modules). Tagging the plugins with <?m2e ignore?> will not help since the build is now broken (e.g. I cannot launch Keycloak in debugger). I've also experimented by adding <?m2e execute?> to places that I think are required to run in order to fix the (now broken) build, but it requires quite deep understanding on what goes wrong. For some reason the language server logs will not have proper logging from m2e run including logs from maven plugins themselves, and I have not managed to enable that.

@snjeza
Copy link
Contributor

snjeza commented Nov 15, 2023

<?m2e execute?> is default. You can try to use the java.configuration.maven.defaultMojoExecutionAction VS Code property (ignore, warn, error execute)

@tsaarni
Copy link
Author

tsaarni commented Nov 15, 2023

From the doc I understood the default is "ignore".

@tsaarni
Copy link
Author

tsaarni commented Nov 15, 2023

@snjeza Sorry to bother again. I wonder if you know what happens to output from maven modules when they are run via m2e and how to get access to the logs? The logs from language server will just have mojo exceptions, but nothing else. I've even tried modifying the maven module(s) to print to stdout but I cannot see them. The output is visible when running mvn on command line.

@snjeza
Copy link
Contributor

snjeza commented Nov 15, 2023

@tsaarni You can try to add

"java.jdt.ls.vmargs": "-Dlog.level=ALL -Djdt.ls.debug=true  <your_vmargs>",

@tsaarni
Copy link
Author

tsaarni commented Nov 15, 2023

Thank you again @snjeza. I did not manage to get output so I ended up modifying the maven plugin to write output to /tmp/ instead.

Here is a summary of my problems with Keycloak:

  1. By default some maven plugins do not get executed by m2eclipse when opening the project. This has not been problem until now since project started to rely on (rather outdated) maven-replacer-plugin.
  2. Keycloak also started to use variable ${maven.multiModuleProjectDirectory} as install directory in javascript submodules. This variable is empty when building in vscode. It resulted files being installed in various wrong places, breaking the build.

Issue (1) can be worked around by setting java.configuration.maven.defaultMojoExecutionAction to execute or alternatively Keycloak could maybe consider alternative approach compatible with m2e/vscode/Eclipse.

Issue (2) can be worked around by appending java.jdt.ls.vmargs with -Dmaven.multiModuleProjectDirectory=<absolute directory>. Note that ${workspaceFolder} will not expand to a value here, so it cannot be used.

There is still some minor problems left, but this was the major part.

It woud be absolutely fantastic if JDT LS could provide output from maven plugins (like mvn does) and print errors when bumping into undefined variables like maven.multiModuleProjectDirectory. I guess this would be a feature request to JDT LS or m2eclipse?

@snjeza
Copy link
Contributor

snjeza commented Nov 22, 2023

Issue (2) can be worked around by appending java.jdt.ls.vmargs with -Dmaven.multiModuleProjectDirectory=. Note that ${workspaceFolder} will not expand to a value here, so it cannot be used.

It has been fixed. See eclipse-jdtls/eclipse.jdt.ls#2976

It woud be absolutely fantastic if JDT LS could provide output from maven plugins (like mvn does) and print errors when bumping into undefined variables like maven.multiModuleProjectDirectory. I guess this would be a feature request to JDT LS or m2eclipse?

You can try to add

"java.jdt.ls.vmargs": "-Dlog.level=ALL -Djdt.ls.debug=true -Dmaven.plugin.validation=verbose <your_vmargs>",

@rgrunber
Copy link
Member

Thanks for filing upstream at keycloak/keycloak#24781 also. That was my first impression when I saw the PR for maven.multiModuleProjectDirectory=... . That it was just some custom property some project(s) may use and the issue is we have no way of knowing about every project's particular build instructions.

However, it seems like it's an "internal" property ? https://issues.apache.org/jira/browse/MNG-6589 . I guess in that case, it would be convenient for us to just set it.

@fbricon , thoughts ?

@rgrunber rgrunber added the Maven label Nov 22, 2023
@fbricon
Copy link
Collaborator

fbricon commented Nov 22, 2023

can't we use the officially supported project.topdir property instead?

my bad it was not merged.

@fbricon
Copy link
Collaborator

fbricon commented Nov 22, 2023

so yeah just set it

@rgrunber rgrunber added this to the End November 2023 milestone Nov 22, 2023
@snjeza
Copy link
Contributor

snjeza commented Nov 22, 2023

@rgrunber @fbricon I have updated the PR. It sets the maven.multiModuleProjectDirectory property.
We can't set a project property. m2e reads the project and sets its properties.
You may want to take a look at eclipse-m2e/m2e-core#666.
However, m2e doesn't set this property.

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

Successfully merging a pull request may close this issue.

4 participants