Skip to content

Use gradle-buildconfig-plugin to generate dependency versions #2705

Closed

Description

@Goooler

Generate build config for the versions like

googleJavaFormatCompileOnly 'com.google.googlejavaformat:google-java-format:1.28.0'

And refer to the generated config for

There is an example like https://github.com/vanniktech/gradle-maven-publish-plugin/blob/d0e50fec7a07ef91fde62ae5cb0e4b4b4769d797/plugin/build.gradle.kts#L35-L110

This should be stacked on #2704.

Activity

  1. added theissue type on Oct 28, 2025
  2. nedtwigg commented on Nov 3, 2025

    @nedtwigg
    Member

    I'm not familiar with this, but I'm open to it. What is the problem that it solves?

  3. Goooler commented on Nov 4, 2025

    @Goooler
    MemberAuthor

    @renovate-bot send the updates like #2345, we have to update GoogleJavaFormatStep.java manually to reflect the latest version string. If we apply the build config stuff, the latest version in the lib will always be refed by

    .add(17, BuildConfig.VERSION_GJF); // default version 

    and BuildConfig.VERSION_GJF always reflects the latest version bumped by @renovate-bot.

  4. nedtwigg commented on Nov 5, 2025

    @nedtwigg
    Member

    Wow! Great idea, I like it!

  5. builtbyjuls commented on Sep 8, 2026

    @builtbyjuls
    Contributor

    Hi, I would like to work on this. I reviewed current main now that #2704 has been merged, and the google-java-format defaults are now split by JVM compatibility.

    Is the intended scope now to generate BuildConfig.VERSION_GJF from the version in libs.google.java.format and use it for the JVM 21+ recommended default, while keeping the JVM 17 default at 1.28.0 and the JVM 25 minimum at 1.30.0?

    I would keep the dependency bump in #2706 outside this PR so the change remains focused on wiring the version catalog value into the generated build config.

  6. Goooler commented on Sep 8, 2026

    @Goooler
    MemberAuthor

    addMin(25, BuildConfig.VERSION_GJF) for

    .addMin(25, "1.30.0") // import module (JEP 511) requires google-java-format >= 1.30.0 (https://github.com/google/google-java-format/issues/1213)

    Always ref the latest dependency version in the buildconfig

  7. builtbyjuls commented on Sep 8, 2026

    @builtbyjuls
    Contributor

    Thanks! One concern: if only the Java 25 minimum uses BuildConfig.VERSION_GJF, while the Java 21+ default remains hardcoded to 1.30.0, a future Renovate update would make Spotless select 1.30.0 and then reject it for being below the new minimum.

    Should both the Java 21+ default and the Java 25 minimum use BuildConfig.VERSION_GJF, while Java 17 remains on 1.28.0?

  8. Goooler commented on Sep 8, 2026

    @Goooler
    MemberAuthor

    Good question! I was wrong. We should only replace

    .add(21, "1.30.0"); // default on JVM 21+ (1.30.0+ handles `import module` in RemoveUnusedImports on JVM 25+)
    instead of addMin. That's the default one when users use googleJavaFormat.

    I filed this FR a long time ago and haven't contributed to this codebase for a while, so I missed some context!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions