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

Switch code style to Google's Java Code Style #661

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open

Switch code style to Google's Java Code Style #661

wants to merge 25 commits into from

Conversation

koppor
Copy link
Owner

@koppor koppor commented Oct 26, 2023

I am so fed up that

Thus, I am looking for good autoformatting tools. The most prominent tool with style guide is Google's:

This PR adds it.

Let's hope for the best that the reformatting action a) really adds a new commit and b) the contributors will be able to pull these changes 😅🙈

I am aware, that there is no maintained gradle plugin.

I am also aware, that there is no AOSP support for Eclipse since 5 years (google/google-java-format#251), but maybe, this will be resolved.

One needs to run it twice for coments: google/google-java-format#211


Blockers

Mandatory checks

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

@koppor koppor force-pushed the main branch 2 times, most recently from 9799dc4 to d6a0e59 Compare October 27, 2023 01:32
@Siedlerchr
Copy link
Collaborator

Mabye spotless ? https://github.com/diffplug/spotless

@koppor
Copy link
Owner Author

koppor commented Oct 28, 2023

Wait for another PR - I have success with palantir-java-format.

That is a) more maintained and b) seems to work well and c) has better formatting than GJF:

(1) google-java-format output:

private static void configureResolvedVersionsWithVersionMapping(Project project) {
    project.getPluginManager()
            .withPlugin(
                    "maven-publish",
                    plugin -> {
                        project.getExtensions()
                                .getByType(PublishingExtension.class)
                                .getPublications()
                                .withType(MavenPublication.class)
                                .configureEach(
                                        publication ->
                                                publication.versionMapping(
                                                        mapping -> {
                                                            mapping.allVariants(
                                                                    VariantVersionMappingStrategy
                                                                            ::fromResolutionResult);
                                                        }));
                    });
}

(1) palantir-java-format output:

private static void configureResolvedVersionsWithVersionMapping(Project project) {
    project.getPluginManager().withPlugin("maven-publish", plugin -> {
        project.getExtensions()
                .getByType(PublishingExtension.class)
                .getPublications()
                .withType(MavenPublication.class)
                .configureEach(publication -> publication.versionMapping(mapping -> {
                    mapping.allVariants(VariantVersionMappingStrategy::fromResolutionResult);
                }));
    });
}

@koppor koppor closed this Oct 28, 2023
@koppor koppor deleted the add-gjf branch October 28, 2023 20:20
@koppor koppor mentioned this pull request Oct 28, 2023
9 tasks
@koppor
Copy link
Owner Author

koppor commented Oct 28, 2023

New try at #663

@koppor koppor restored the add-gjf branch October 5, 2024 18:52
@koppor koppor reopened this Oct 5, 2024
@koppor
Copy link
Owner Author

koppor commented Oct 5, 2024

I applied the binary from https://github.com/google/google-java-format/releases/tag/v1.24.0

MINGW64 /c/git-repositories/jabref (add-gjf)
$ find . -name "*.java" -exec /c/Users/koppor/Downloads/google-java-format_windows-x86-64.exe -r -a --skip-reflowing-long-strings --skip-javadoc-formatting "{}" \;

@koppor
Copy link
Owner Author

koppor commented Oct 5, 2024

OMG - the windows binary of GJF behaves differently to the JAR -- google/google-java-format#1171

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

Successfully merging this pull request may close these issues.

2 participants