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

Please provide Eclipse plugin in version 1.7 #331

Closed
PhilippWendler opened this issue Jan 10, 2019 · 25 comments
Closed

Please provide Eclipse plugin in version 1.7 #331

PhilippWendler opened this issue Jan 10, 2019 · 25 comments
Labels

Comments

@PhilippWendler
Copy link

The release page for version 1.7 does not contain an Eclipse plugin like the previous versions. The readme still mentions that page as the download source of the Eclipse plugin.

So please provide a JAR with the Eclipse plugin as part of the relase.

@cushon cushon added the Eclipse label Jan 14, 2019
@arifogel
Copy link

I was able to build by following:
#190
https://github.com/google/google-java-format/blob/master/eclipse_plugin/README.md

My steps (use attached diff):

git clone https://github.com/google/google-java-format
cd google-java-format
git checkout google-java-format-1.7
git apply < build-ecliipse-plugin-from-release-1.7.diff.txt
mvn install ### THIS STEP IS SUPPOSED TO FAIL

Then follow eclipse plugin build instructions starting at step 2.

build-ecliipse-plugin-from-release-1.7.diff.txt

@arifogel
Copy link

I've attached a build using above instructions for convenience.
google-java-format-eclipse-plugin-1.7.0.jar.zip

@PhilippWendler
Copy link
Author

Please provide an official build in the GitHub release. I would like to be able to tell our project contributors to go there and download it.

@wacaine
Copy link

wacaine commented May 30, 2019

The attached unofficial build for 1.7 above does not work when I attempt to install it in eclipse. eclipse does not appear to recognize it at all. When I tried the provided steps to reproduce I get a compile error

$ mvn install
[INFO] Scanning for projects...
[INFO] Computing target platform for MavenProject: com.google.googlejavaformat:google-java-format-eclipse-plugin:1.7.0 @ /Users/wac84s/Downloads/google-java-format-master/eclipse_plugin/pom.xml
[INFO] Fetching p2.index from http://download.eclipse.org/releases/mars/
[INFO] Adding repository http://download.eclipse.org/releases/mars
[INFO] Fetching p2.index from http://download.eclipse.org/technology/epp/packages/mars/
[INFO] Fetching p2.index from http://download.eclipse.org/technology/epp/packages/mars/
[INFO] Fetching p2.index from http://download.eclipse.org/releases/mars/201506241002/
[INFO] Fetching p2.index from http://download.eclipse.org/releases/mars/201506241002/
[INFO] Fetching p2.index from http://download.eclipse.org/releases/mars/201510021000/
[INFO] Fetching p2.index from http://download.eclipse.org/releases/mars/201510021000/
[INFO] Fetching p2.index from http://download.eclipse.org/releases/mars/201602261000/
[INFO] Fetching p2.index from http://download.eclipse.org/releases/mars/201602261000/
[INFO] Resolving dependencies of MavenProject: com.google.googlejavaformat:google-java-format-eclipse-plugin:1.7.0 @ /Users/wac84s/Downloads/google-java-format-master/eclipse_plugin/pom.xml
[INFO] Resolving class path of MavenProject: com.google.googlejavaformat:google-java-format-eclipse-plugin:1.7.0 @ /Users/wac84s/Downloads/google-java-format-master/eclipse_plugin/pom.xml
[INFO] 
[INFO] ---< com.google.googlejavaformat:google-java-format-eclipse-plugin >----
[INFO] Building google-java-format Plugin for Eclipse 4.5+ 1.7.0
[INFO] ---------------------------[ eclipse-plugin ]---------------------------
[INFO] 
[INFO] --- tycho-packaging-plugin:0.26.0:build-qualifier (default-build-qualifier) @ google-java-format-eclipse-plugin ---
[INFO] The project's OSGi version is 1.7.0
[INFO] 
[INFO] --- tycho-packaging-plugin:0.26.0:validate-id (default-validate-id) @ google-java-format-eclipse-plugin ---
[INFO] 
[INFO] --- tycho-packaging-plugin:0.26.0:validate-version (default-validate-version) @ google-java-format-eclipse-plugin ---
[INFO] 
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ google-java-format-eclipse-plugin ---
[INFO] 
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ google-java-format-eclipse-plugin ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/wac84s/Downloads/google-java-format-master/eclipse_plugin/src/main/resources
[INFO] 
[INFO] --- tycho-compiler-plugin:0.26.0:compile (default-compile) @ google-java-format-eclipse-plugin ---
[INFO] Compiling 1 source file to /Users/wac84s/Downloads/google-java-format-master/eclipse_plugin/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.584 s
[INFO] Finished at: 2019-05-30T13:29:21-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:0.26.0:compile (default-compile) on project google-java-format-eclipse-plugin: Compilation failure: Compilation failure: 
[ERROR] /Users/wac84s/Downloads/google-java-format-master/eclipse_plugin/src/com/google/googlejavaformat/java/GoogleJavaFormatter.java:[17] 
[ERROR] 	import com.google.common.base.Preconditions;
[ERROR] 	       ^^^^^^^^^^^^^^^^^
[ERROR] The import com.google.common cannot be resolved
[ERROR] /Users/wac84s/Downloads/google-java-format-master/eclipse_plugin/src/com/google/googlejavaformat/java/GoogleJavaFormatter.java:[18] 
[ERROR] 	import com.google.common.collect.Range;
[ERROR] 	       ^^^^^^^^^^^^^^^^^
...... truncted list. it is as if it does not see guava on classpath

@arifogel
Copy link

From the above instructions:

mvn install ### THIS STEP IS SUPPOSED TO FAIL

Did you follow up that step with:

Then follow eclipse plugin build instructions starting at step 2.

as indicated in that comment?

@arifogel
Copy link

Also @wacaine this might be a stupid question, but did you unzip the jar first before placing the jar in the dropins folder?

@arifogel
Copy link

I mean, did you unzip the jar out of the attached zip? I had to pack the jar inside a zip because of github file posting rules.

$ unzip -t google-java-format-eclipse-plugin-1.7.0.jar.zip 
Archive:  google-java-format-eclipse-plugin-1.7.0.jar.zip
    testing: plugins/                 OK
    testing: plugins/google-java-format-eclipse-plugin_1.7.0.jar   OK
No errors detected in compressed data of google-java-format-eclipse-plugin-1.7.0.jar.zip.

You need to put the plugins/google-java-format-eclipse-plugin_1.7.0.jar file in the eclipse dropins folder.

@wacaine
Copy link

wacaine commented May 30, 2019

I unzipped and put in drop ins. It works for 1.6 (official download). Does not work for 1.7 unofficial download. I unzipped the file and placed the jar in correct place and restarted eclipse in-between. See attached screenshot. I am using eclipse oxygen3.a.
side-by-side

@arifogel
Copy link

@wacaine I believe I built it with a later version than oxygen. I would suggest attempting to complete the build on your older version of eclipse as instructed above, and seeing if that produces a usable output jar.

@wacaine
Copy link

wacaine commented May 31, 2019

@arifogel See my earlier post above with the output from the mvn install . It throws a ton of compiler errors not being able to find classes (missing guava classes). When I check the target folder no jar was built (because of the compile time issues).

org.eclipse.tycho:tycho-compiler-plugin:0.26.0:compile (default-compile) on project google-java-format-eclipse-plugin: Compilation failure: Compilation failure

I am not familiar with Tycho and how it resolves classpaths. Any suggestions or reference materials you can point me at? I am not clear on how to build against a different version of eclipse. From what I see it builds against the Eclipse Mars release which is older than Oxygen

Screen Shot 2019-05-31 at 9 08 36 AM

@DanVanAtta
Copy link

Custom building an eclipse plugin does not seem to be a really good long term solution and also goes against the goal of having a simple formatter that an entire team can install and then not worry about. Just encountered this problem and found out it's a version issue.

The README instructions for installing goole java formatter are not consistent with itself, it has 1.7 dependencies yet the eclipse plugin is 1.6

Out of the box the intellij plugin and gradle plugin spotless use 1.7, which clashes with 1.6. I'd suggest it's really important then for the eclipse plugin to reach parity to avoid a problem of differing formatters.

Is there an ETA for when the eclipse 1.7 plugin would be available and the readme instructions updated?

@ddellspe
Copy link

of note, because I know it might help others after I dropped the .jar into my dropins folder, I still didn't ever see the items, even after eclipse and machine restart. when I ran eclipse via command line with eclipse -clean that made it show up.

@PhilippWendler
Copy link
Author

The 1.7 release is now more than one year old, and there is still no build of the Eclipse plugin available.

Please provide an official build of the plugin or tell us if you will never do so such that we can look for alternate solutions (and remove the outdated plugin link from the readme in this case).

@av1m
Copy link
Contributor

av1m commented May 23, 2020

Release 1.8 is out and I encountered the same problem when I ran a test (CLI, IntelliJ, Idea).
(By the time I find that the problem came from the version ...)
It is also impossible to generate the plugin by following this documentation : google-java-format Eclipse Plugin

For information, there is a pull request #465 which is currently in progress, and which could solve the problem.
In the meantime, has anyone found a solution to benefit from google-java-format 1.8 on eclipse?

@jan-z
Copy link

jan-z commented Jun 7, 2020

For the impatient: google-java-format-eclipse-plugin-1.8.0.jar.zip is a build (using JDK14) of version 1.8.0, created out of this pull request: #465.

Unzip the zip file and put the jar file into the dropins folder. Works fine for me on Eclipse 2020-03.

@oliviercailloux
Copy link

@avim did you find a satisfactory solution for using Eclipse together with google style? I suppose your team used some Eclipse plugin together with the coveooss:fmt-maven-plugin in your own project: what did you use and what was your experience with this? What would you recommend? The build referenced here above, or something else?

@av1m
Copy link
Contributor

av1m commented Jul 14, 2020

I was waiting for the Eclipse plugin. The latest current version of the Eclipse plugin is 1.6.
The latest version of google-java-format is 1.8 (so the name of the issue already seems to be obsolete)
However, PR #465 is still pending merger and should resolve this issue.

Not being able to use the google-java-format version for Eclipse, I was able to use workarounds.
I give you my feedback. I try :

  • Google Actions: At each event (described in our configuration file), we check that the code is well formatted. If not, a bot will execute google-java-format and commit. This is a very good way to do it and allow a team to work on files that are necessarily formatted but cause an increase in commits (and the need to do git fetch). In addition, developers don't even have to use google-java-format locally.
  • The coveooss plugin: fmt-maven-plugin also works very well: It allows you to execute google-java-format by integrating into maven, so at each once we make a maven command, google-java-format is called. However, I was able to raise two constraints.
    • When a new release of google-java-format comes out, you have to wait for the update of fmt-maven-plugin
    • We don't always think about launching a maven command (if our IDE already does the work without going through maven)
  • Use a git hook: before each commit (for example), google-java-format is automatically called. Very practical because we directly control the version of google-java-format using the jar
  • A somewhat technical solution: place the jar (with all the dependencies) and use a script that executes google-java-format (in the project you want). A defect is that you have to remember to execute the script ...

Using git hooks is the most efficient way for me to work. We forget that we are using google-java-format

I also wrote a small note on this repository. It generally resumes what is written in the official repository.

I hope you are satisfied with this answer. cc @oliviercailloux

@oliviercailloux
Copy link

oliviercailloux commented Jul 14, 2020

Thanks a lot.

FTR (and in order to argue for the usefulness of the corresponding PR), none of these solutions seem great to me. I don’t like anything to re-format automatically behind the scenes; I think the re-format should be done where I code, and in such a way that I can see its consequences (e.g., in case something goes wrong, I can see it and act) before me committing. I also don’t want to force developers (or myself) to think about running maven “manually” (meaning, in a way that is not integrated in the IDE) on a regular basis. Finally, in a teaching context as I am, I find it important that student-developers understand the importance and the concept of formatting their code, and don’t want to automate this “too much” for them. As a consequence, I want some integration within Eclipse itself.

coveooss:fmt-maven-plugin is great but I’d use it only for checking that everything is properly formatted, for the above reason.

I guess I’ll wait that the corresponding PR gets merged, as I am not impatient enough to use a non-official build as proposed here above.

@ativ97
Copy link

ativ97 commented Aug 12, 2020

For the impatient: google-java-format-eclipse-plugin-1.8.0.jar.zip is a build (using JDK14) of version 1.8.0, created out of this pull request: #465.

Unzip the zip file and put the jar file into the dropins folder. Works fine for me on Eclipse 2020-03.

Hey, So some of my team members are running the intellij plugin but I am using eclipse so I tried to use the jar file you provided. I am facing some issues trying to get this to work. I dropped in the jar file in the drop ins folder and did a eclipse -clean but the plug-in still was not showing up. So i opened an OSGi console and ran ss and I saw that the plug-in was installed but now resolved. After running the diag command in the console i get the following error-

osgi> diag 649 google-java-format-eclipse-plugin [649] Unresolved requirement: Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=11))"

image

The project I am trying to use the plug-in on, uses java 1.8 and I saw jdk 11 mentioned somewhere. Does this means that the plug-in won't be supported for projects below jdk 11 from now on. I thought that didn't make sense as my other team members on intellij are working on the same project as me and for them the plug-in works fine.

Any help will be appreciated!

@Stephan202
Copy link
Contributor

@ativ97 indeed, as the release notes for GJF 1.8 indicate the minimum supported runtime version is now JDK 11. Note that this means that the IDE/plugin needs to run on JDK 11, but the code base being formatted can target an earlier Java version.

@aaiezza
Copy link

aaiezza commented Sep 28, 2020

For the impatient: google-java-format-eclipse-plugin-1.8.0.jar.zip is a build (using JDK14) of version 1.8.0, created out of this pull request: #465.

Unzip the zip file and put the jar file into the dropins folder. Works fine for me on Eclipse 2020-03.

This doesn't seem to work for 2020-09.
I would love it if the eclipse plugin worked the same as the coveo format maven plugin though! There are some slight differences in the output, and I'm assuming that bumping to version 1.8.0 will fix it.

@sarguin-lacapitale
Copy link

Please provide Eclipse plugin in version 1.9

@PhilippWendler
Copy link
Author

Big thanks @cushon for building and uploading version 1.11.0 of the Eclipse plugin!

This resolves this issue, but you might want to update the link to the Eclipse plugin in the README?

@av1m
Copy link
Contributor

av1m commented Aug 2, 2021

@PhilippWendler check #639

@cushon
Copy link
Collaborator

cushon commented Aug 2, 2021

https://github.com/google/google-java-format/releases/tag/v1.11.0

@cushon cushon closed this as completed Aug 2, 2021
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