google / google-java-format

Reformats Java source code to comply with Google Java Style.
Other
5.63k stars 855 forks source link

IJ 2020.1 compatibility #449

Closed krasa closed 4 years ago

krasa commented 4 years ago

They changed API...

https://github.com/krasa/EclipseCodeFormatter/commit/73d5a38e6a6cb7216415e69de3fcc52d8fb933ed

plumpy commented 4 years ago

Thanks for the heads up...

sormuras commented 4 years ago

Also being hit by this issue today.

IntelliJ IDEA 2020.1 Beta (Community Edition)
Build #IC-201.6668.13, built on March 25, 2020
Runtime version: 11.0.6+8-b765.17 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 1979M
Cores: 16
Non-Bundled Plugins: org.jetbrains.kotlin, google-java-format
java.lang.NoClassDefFoundError: com/intellij/serviceContainer/PlatformComponentManagerImpl
    at com.google.googlejavaformat.intellij.GoogleJavaFormatInstaller.setManager(GoogleJavaFormatInstaller.java:61)
    at com.google.googlejavaformat.intellij.GoogleJavaFormatInstaller.installFormatter(GoogleJavaFormatInstaller.java:56)
    at com.google.googlejavaformat.intellij.GoogleJavaFormatInstaller.projectOpened(GoogleJavaFormatInstaller.java:46)
    at com.intellij.openapi.project.impl.ProjectManagerImpl.lambda$null$13(ProjectManagerImpl.java:790)
    at com.intellij.ide.startup.impl.StartupManagerImpl.runActivity(StartupManagerImpl.java:458)
    at com.intellij.openapi.project.impl.ProjectManagerImpl.lambda$fireProjectOpened$14(ProjectManagerImpl.java:788)
    at com.intellij.serviceContainer.ContainerUtilKt.processProjectComponents(containerUtil.kt:31)
    at com.intellij.openapi.project.impl.ProjectManagerImpl.fireProjectOpened(ProjectManagerImpl.java:787)
    at com.intellij.openapi.project.impl.ProjectManagerImpl.lambda$doLoadProject$6(ProjectManagerImpl.java:455)
    at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:201)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:831)
    at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeAndWait$8(ApplicationImpl.java:480)
    at com.intellij.openapi.application.impl.LaterInvocator$1.run(LaterInvocator.java:124)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:80)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:128)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:46)
    at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:184)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:974)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:847)
    at com.intellij.ide.IdeEventQueue.lambda$null$8(IdeEventQueue.java:449)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:728)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:448)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:831)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:496)
    at com.intellij.ide.IdeEventQueue.pumpEventsForHierarchy(IdeEventQueue.java:1030)
    at com.intellij.openapi.progress.util.ProgressWindow.pumpEventsForHierarchy(ProgressWindow.java:199)
    at com.intellij.openapi.progress.util.ProgressWindow.lambda$startBlocking$3(ProgressWindow.java:189)
    at com.intellij.openapi.application.impl.ApplicationImpl.runUnlockingIntendedWrite(ApplicationImpl.java:857)
    at com.intellij.openapi.progress.util.ProgressWindow.startBlocking(ProgressWindow.java:188)
    at com.intellij.openapi.progress.impl.ProgressRunner.lambda$legacyExec$6(ProgressRunner.java:302)
    at java.base/java.util.concurrent.CompletableFuture.uniAcceptNow(CompletableFuture.java:753)
    at java.base/java.util.concurrent.CompletableFuture.uniAcceptStage(CompletableFuture.java:731)
    at java.base/java.util.concurrent.CompletableFuture.thenAccept(CompletableFuture.java:2108)
    at com.intellij.openapi.progress.impl.ProgressRunner.legacyExec(ProgressRunner.java:300)
    at com.intellij.openapi.progress.impl.ProgressRunner.submit(ProgressRunner.java:248)
    at com.intellij.openapi.progress.impl.ProgressRunner.submitAndGet(ProgressRunner.java:169)
    at com.intellij.openapi.application.impl.ApplicationImpl.runProcessWithProgressSynchronously(ApplicationImpl.java:426)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcessWithProgressSynchronously(CoreProgressManager.java:492)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcessWithProgressSynchronously(ProgressManagerImpl.java:84)
    at com.intellij.platform.ProjectUiFrameAllocator$run$1.run(ProjectFrameAllocator.kt:85)
    at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:201)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:831)
    at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeAndWait$8(ApplicationImpl.java:480)
    at com.intellij.openapi.application.impl.LaterInvocator$1.run(LaterInvocator.java:124)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:80)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:128)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:46)
    at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:184)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:974)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:847)
    at com.intellij.ide.IdeEventQueue.lambda$null$8(IdeEventQueue.java:449)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:739)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:448)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:831)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:496)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: java.lang.ClassNotFoundException: com.intellij.serviceContainer.PlatformComponentManagerImpl PluginClassLoader[google-java-format, 1.7.0.3] com.intellij.ide.plugins.cl.PluginClassLoader@63cccd2f
    at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:115)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 75 more
lorenzleutgeb commented 4 years ago

I can confirm that the plugin does not work in conjunction with the preview of IntelliJ 2020 Ultimate Edition and Java 14 running on Linux (the previous comment is about the Community Edition and Java 11 running on Windows).

IntelliJ IDEA 2020.1 Beta (Ultimate Edition)
Build #IU-201.6668.13, built on March 25, 2020
IntelliJ IDEA EAP User
Expiration date: April 24, 2020
Runtime version: 11.0.6+8-b765.17 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 5.5.10-200.fc31.x86_64
GC: ParNew, ConcurrentMarkSweep
Memory: 1502M
Cores: 4
Registry: ide.tooltip.initialDelay=796
Non-Bundled Plugins: Gradle View, IdeaVIM, CheckStyle-IDEA, VisualVMLauncher, org.intellij.plugins.markdown, io.github.takuaraki.dvc, google-java-format, org.antlr.intellij.plugin, org.asciidoctor.intellij.asciidoc
Current Desktop: i3

The stack trace that I get seems to point at the same cause as the one previously posted.

java.lang.NoClassDefFoundError: com/intellij/serviceContainer/PlatformComponentManagerImpl
    at com.google.googlejavaformat.intellij.GoogleJavaFormatInstaller.setManager(GoogleJavaFormatInstaller.java:61)
    at com.google.googlejavaformat.intellij.GoogleJavaFormatInstaller.installFormatter(GoogleJavaFormatInstaller.java:56)
    at com.google.googlejavaformat.intellij.GoogleJavaFormatInstaller.projectOpened(GoogleJavaFormatInstaller.java:46)
    ...
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: java.lang.ClassNotFoundException: com.intellij.serviceContainer.PlatformComponentManagerImpl PluginClassLoader[google-java-format, 1.7.0.3] com.intellij.ide.plugins.cl.PluginClassLoader@26ac28e1
    at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:115)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 75 more
lorenzleutgeb commented 4 years ago

So, I took a closer look and came up with the changeset over at #452.

I ran gradle build on my fork and used IntelliJ's "Install Plugin from Disk..." feature to load google-java-format/idea_plugin/build/distributions/google-java-format.zip, which works fine.

@sormuras, @klaushauschild1984: If you're brave enough to trust me, you could build my fork or try loading google-java-format.zip as extension, and use that until Google has released a fix.

@plumpy: Before you continue/start working on this, please at least have a look at the PR.

sormuras commented 4 years ago

No risk, no fun. Loaded and installed your packaged extension -- works like a charm. ✔

Thus, I support PR #452

legidio commented 4 years ago

Hi all,

Just to report that JetBrains has been rolling out IntelliJ 2020.1 (using snap update here). The plugin doesn't seem to be working since update to IntelliJ 2020.1 on April 7 2020.

@plumpy, is there a scheduled date for an update to the plugin? Thanks in advance for the team effort to roll out an update as quickly as possible.

Stackstrace:

java.lang.NoClassDefFoundError: com/intellij/serviceContainer/PlatformComponentManagerImpl
    at com.google.googlejavaformat.intellij.GoogleJavaFormatInstaller.setManager(GoogleJavaFormatInstaller.java:61)
    at com.google.googlejavaformat.intellij.GoogleJavaFormatInstaller.installFormatter(GoogleJavaFormatInstaller.java:56)
    at com.google.googlejavaformat.intellij.GoogleJavaFormatInstaller.projectOpened(GoogleJavaFormatInstaller.java:46)
    at com.intellij.openapi.project.impl.ProjectManagerImpl.lambda$null$13(ProjectManagerImpl.java:790)
    at com.intellij.ide.startup.impl.StartupManagerImpl.runActivity(StartupManagerImpl.java:458)
    at com.intellij.openapi.project.impl.ProjectManagerImpl.lambda$fireProjectOpened$14(ProjectManagerImpl.java:788)
    at com.intellij.serviceContainer.ContainerUtilKt.processProjectComponents(containerUtil.kt:31)
(...)
Caused by: java.lang.ClassNotFoundException: com.intellij.serviceContainer.PlatformComponentManagerImpl PluginClassLoader[google-java-format, 1.7.0.3] com.intellij.ide.plugins.cl.PluginClassLoader@3b26981b
    at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:115)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)

About Info:

IntelliJ IDEA 2020.1 (Ultimate Edition) Build #IU-201.6668.121, built on April 8, 2020 Runtime version: 11.0.6+8-b765.25 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Linux 4.15.0-91-generic GC: ParNew, ConcurrentMarkSweep Memory: 1956M Cores: 4 Registry: ide.editor.tabs.open.at.the.end=true, debugger.watches.in.variables=false Non-Bundled Plugins: CheckStyle-IDEA, GrepConsole, com.dubreuia, google-java-format, net.seesharpsoft.intellij.plugins.csv, MavenRunHelper, Pythonid, org.intellij.scala, com.dmarcotte.handlebars Current Desktop: XFCE

Screenshot:

image

lorenzleutgeb commented 4 years ago

@legidio if you like, your could try whether my solution posted above works out for you. You can choose to review and compile the changes I PRed or just take the ZIP that I provided. If this resolves the issue, please upvote my PR as well, such that it might get more attention. Thanks.

legidio commented 4 years ago

@plumpy, I cloned @lorenzleutgeb's solution, built it (after setting to my own specific IDEA version on idea_plugin/build.gradle) and successfully installed on IntelliJ. Seems to be working.

Please acknowledge the importance of this fix (based on the suggested solution or not), since JetBrains has indeed begin rolling out the new version and seems strange to have to roll back because of an outdated plugin.

plumpy commented 4 years ago

1.7.0.5 is out now and supports 2020.1.