spring-io / spring-javaformat

Apache License 2.0
806 stars 111 forks source link

Upgrade to Eclipse 2022-09 #342

Closed hjoeren closed 1 year ago

hjoeren commented 2 years ago

During "Updating Maven Project" in Eclipse 2022-09, a NoSuchMethodException occurs. Here is the output of the Eclipse Error Log:

java.lang.NoSuchMethodError: 'org.apache.maven.project.MavenProject org.eclipse.m2e.core.project.configurator.ProjectConfigurationRequest.getMavenProject()'
    at io.spring.javaformat.eclipse.m2e.MavenProjectSettingsConfigurator.getSearchFolders(MavenProjectSettingsConfigurator.java:52)
    at io.spring.javaformat.eclipse.m2e.MavenProjectSettingsConfigurator.lambda$0(MavenProjectSettingsConfigurator.java:44)
    at io.spring.javaformat.eclipse.Executor.run(Executor.java:48)
    at io.spring.javaformat.eclipse.m2e.MavenProjectSettingsConfigurator.configure(MavenProjectSettingsConfigurator.java:43)
    at org.eclipse.m2e.core.project.configurator.AbstractLifecycleMapping.configure(AbstractLifecycleMapping.java:125)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda$6(ProjectConfigurationManager.java:475)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:350)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:262)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:469)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda$4(ProjectConfigurationManager.java:413)
    at java.base/java.util.Collection.removeIf(Collection.java:576)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration0(ProjectConfigurationManager.java:407)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda$3(ProjectConfigurationManager.java:339)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:350)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:262)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:205)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1093)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:338)
    at org.eclipse.m2e.core.ui.internal.UpdateMavenProjectJob.runInWorkspace(UpdateMavenProjectJob.java:80)
    at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:43)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

(If helpful) here is the session data:

eclipse.buildId=4.25.0.I20220831-1800
java.version=17.0.2
java.vendor=Eclipse Adoptium
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -data file:/home/hjoeren/git/ -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.jee.product

After the update from Eclipse 2022-06 to 2022-09, org.eclipse.m2e:m2e-core:2.0.3 is in use, and it looks like several classes were replaced by records. ProjectConfigurationRequest is one of those replaced classes:

https://github.com/eclipse-m2e/m2e-core/blob/2.0.3/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/ProjectConfigurationRequest.java

Here is the commit with the replacement of classes with records: https://github.com/eclipse-m2e/m2e-core/commit/c3ade997e33c06d9a5863aa4985446bdb71e49a2

wilkinsona commented 2 years ago

Thanks for the report. Adapting to the breaking API changes is further complicated by the fact that m2e-core requires Java 17.

wilkinsona commented 2 years ago

https://github.com/wilkinsona/spring-javaformat/tree/m2e-2.0. I haven't yet checked if JDT has moved to Java 17 as well.

hjoeren commented 2 years ago

Just tried to build the m2e-2.0-branch of the fork: Out of the box I was not able to package the whole project but after disabling some modules and excluding some plugins I got it working.

(I used the sdkman environment)

After installing the plugin in 2022-09 with the generated site-archive, at first glance everything was alright ("Update Maven Project" was working, Copyright header was generated, auto-formatting worked, ...)

Reasons why I had to disable some modules/exclude some plugins:

Diffs I made to package the project:

diff --git a/pom.xml b/pom.xml
index 8e1477c..0bed82b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -377,7 +377,7 @@
                    <target>${java.version}</target>
                </configuration>
            </plugin>
-           <plugin>
+           <!--<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <executions>
@@ -388,7 +388,7 @@
                        </goals>
                    </execution>
                </executions>
-           </plugin>
+           </plugin>-->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>flatten-maven-plugin</artifactId>
@@ -598,9 +598,9 @@
    <modules>
        <module>spring-javaformat</module>
        <module>spring-javaformat-maven</module>
-       <module>spring-javaformat-gradle</module>
+       <!--<module>spring-javaformat-gradle</module>-->
        <module>spring-javaformat-eclipse</module>
-       <module>spring-javaformat-intellij-idea</module>
+       <!--<module>spring-javaformat-intellij-idea</module>-->
    </modules>
    <profiles>
        <profile>
diff --git a/spring-javaformat-eclipse/pom.xml b/spring-javaformat-eclipse/pom.xml
index 4300f9d..5f1bd68 100644
--- a/spring-javaformat-eclipse/pom.xml
+++ b/spring-javaformat-eclipse/pom.xml
@@ -88,7 +88,7 @@
    </build>
    <modules>
        <module>io.spring.javaformat.eclipse</module>
-       <module>io.spring.javaformat.eclipse.tests</module>
+       <!--<module>io.spring.javaformat.eclipse.tests</module>-->
        <module>io.spring.javaformat.eclipse.feature</module>
        <module>io.spring.javaformat.eclipse.site</module>
    </modules>
diff --git a/spring-javaformat/spring-javaformat-formatter-eclipse-jdk11/pom.xml b/spring-javaformat/spring-javaformat-formatter-eclipse-jdk11/pom.xml
index eb0b837..43fccad 100644
--- a/spring-javaformat/spring-javaformat-formatter-eclipse-jdk11/pom.xml
+++ b/spring-javaformat/spring-javaformat-formatter-eclipse-jdk11/pom.xml
@@ -151,7 +151,7 @@
                    </execution>
                </executions>
            </plugin>
-           <plugin>
+           <!--<plugin>
                <groupId>com.github.wvengen</groupId>
                <artifactId>proguard-maven-plugin</artifactId>
                <executions>
@@ -183,7 +183,7 @@
                        </configuration>
                    </execution>
                </executions>
-           </plugin>
+           </plugin>-->
        </plugins>
    </build>
    <dependencies>
diff --git a/spring-javaformat/spring-javaformat-formatter-eclipse-jdk8/pom.xml b/spring-javaformat/spring-javaformat-formatter-eclipse-jdk8/pom.xml
index 8957826..7fa6999 100644
--- a/spring-javaformat/spring-javaformat-formatter-eclipse-jdk8/pom.xml
+++ b/spring-javaformat/spring-javaformat-formatter-eclipse-jdk8/pom.xml
@@ -151,7 +151,7 @@
                    </execution>
                </executions>
            </plugin>
-           <plugin>
+           <!--<plugin>
                <groupId>com.github.wvengen</groupId>
                <artifactId>proguard-maven-plugin</artifactId>
                <executions>
@@ -183,7 +183,7 @@
                        </configuration>
                    </execution>
                </executions>
-           </plugin>
+           </plugin>-->
        </plugins>
    </build>
    <dependencies>
diff --git a/spring-javaformat/spring-javaformat-formatter-eclipse-runtime/pom.xml b/spring-javaformat/spring-javaformat-formatter-eclipse-runtime/pom.xml
index c537bd4..1b8d8c0 100644
--- a/spring-javaformat/spring-javaformat-formatter-eclipse-runtime/pom.xml
+++ b/spring-javaformat/spring-javaformat-formatter-eclipse-runtime/pom.xml
@@ -23,7 +23,7 @@
    </dependencies>
    <build>
        <plugins>
-           <plugin>
+           <!--<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
@@ -38,7 +38,7 @@
                        </configuration>
                    </execution>
                </executions>
-           </plugin>
+           </plugin>-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
philwebb commented 1 year ago

Superseded by #352