Skip to content

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

Closed
koppor wants to merge 25 commits into
mainfrom
add-gjf
Closed

Switch code style to Google's Java Code Style#661
koppor wants to merge 25 commits into
mainfrom
add-gjf

Conversation

@koppor

@koppor koppor commented Oct 26, 2023

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

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

@koppor

koppor commented Oct 28, 2023

Copy link
Copy Markdown
Member Author

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

koppor commented Oct 28, 2023

Copy link
Copy Markdown
Member Author

New try at #663

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

koppor commented Oct 5, 2024

Copy link
Copy Markdown
Member Author

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

koppor commented Oct 5, 2024

Copy link
Copy Markdown
Member Author

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

@koppor

koppor commented Mar 13, 2025

Copy link
Copy Markdown
Member Author

Palantir is maintained again. GJF is not that good. Closing.

For reference: Main diff: #661 (comment)

@koppor koppor closed this Mar 13, 2025
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