google-java-format icon indicating copy to clipboard operation
google-java-format copied to clipboard

Eclipse drop in downloaded from 1.16.0 does not format long line of "throws" like the command line

Open deckrider opened this issue 2 years ago • 7 comments

Eclipse drop in downloaded from 1.16.0 does not format long line of "throws" like the command line.

And I don't see a command line option to make it format like the Eclipse drop in.

(Also in the 1.16.0 release, the Eclipse drop claims to be 1.13.0)

deckrider avatar Mar 28 '23 15:03 deckrider

I was able to build a working eclipse dropin myself by:

  1. download source from https://github.com/google/google-java-format/archive/refs/tags/v1.16.0.tar.gz
  2. search and replace "1.13.0" with "1.16.0" as shown below
  3. run 'mvn clean verify' using OpenJDK 17.0.6 and Maven 3.9.1
$ diff -ruNp google-java-format-1.16.0-old google-java-format-1.16.0-new
diff -ruNp google-java-format-1.16.0-old/eclipse_plugin/META-INF/MANIFEST.MF google-java-format-1.16.0-new/eclipse_plugin/META-INF/MANIFEST.MF
--- google-java-format-1.16.0-old/eclipse_plugin/META-INF/MANIFEST.MF	2023-02-24 14:54:02.000000000 -0700
+++ google-java-format-1.16.0-new/eclipse_plugin/META-INF/MANIFEST.MF	2023-03-30 10:09:40.449595120 -0600
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
 Bundle-Name: google-java-format
 Bundle-SymbolicName: google-java-format-eclipse-plugin;singleton:=true
 Bundle-Vendor: Google
-Bundle-Version: 1.13.0
+Bundle-Version: 1.16.0
 Bundle-RequiredExecutionEnvironment: JavaSE-11
 Require-Bundle: org.eclipse.jdt.core;bundle-version="3.10.0",
  org.eclipse.jface,
diff -ruNp google-java-format-1.16.0-old/eclipse_plugin/pom.xml google-java-format-1.16.0-new/eclipse_plugin/pom.xml
--- google-java-format-1.16.0-old/eclipse_plugin/pom.xml	2023-02-24 14:54:02.000000000 -0700
+++ google-java-format-1.16.0-new/eclipse_plugin/pom.xml	2023-03-30 10:09:40.441595568 -0600
@@ -22,7 +22,7 @@
   <groupId>com.google.googlejavaformat</groupId>
   <artifactId>google-java-format-eclipse-plugin</artifactId>
   <packaging>eclipse-plugin</packaging>
-  <version>1.13.0</version>
+  <version>1.16.0</version>
 
   <name>Google Java Format Plugin for Eclipse 4.5+</name>
 

deckrider avatar Mar 30 '23 16:03 deckrider

Before it was not working, did you update your Eclipse plugin from 1.13.0 to 1.16.0 by simply dropping the new JAR in dropins? My suspicion is (cf. https://github.com/google/google-java-format/issues/744#issuecomment-1398056103) that Eclipse sees that the new JAR has the same version number as the previously installed one and simply ignores it. It would probably have worked to remove google-java-format and then install the "really version 1.16.0 but claims to be 1.13.0" JAR.

If this is correct, this issue essentially becomes a duplicate of #744.

PhilippWendler avatar Mar 30 '23 16:03 PhilippWendler

The issue is that the wrong version (that I corrected above) was being used to build the Eclipse dropin

deckrider avatar Apr 04 '23 13:04 deckrider

Why not use Maven interpolation to fix the version issue? For example:

Bundle-Version: ${project.version}

Or:

<version>${project.version}</version>

deckrider avatar Apr 05 '23 11:04 deckrider

My understanding is that Eclipse is still and always built with/against gjf 1.13.0; it has never been updated: https://github.com/google/google-java-format/blob/master/eclipse_plugin/pom.xml

tbroyer avatar Apr 05 '23 12:04 tbroyer

Ah yes of course, line 25 is picked up in line 42!

So when I changed the source as shown, I also changed which version was being used, which is why it started working

deckrider avatar Apr 05 '23 12:04 deckrider

Please try with version 1.18.1 of the plugin. It has the correct version number and should work.

PhilippWendler avatar Oct 06 '23 05:10 PhilippWendler