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

Gradle build: cleanup of dependency resolution and consolidation of dependency versions #13484

Merged
merged 15 commits into from
Jun 17, 2024

Conversation

dweiss
Copy link
Contributor

@dweiss dweiss commented Jun 13, 2024

This patch attempts to clean up and consolidate all kinds of aspects related to dependencies used throughout the build and "versions", understood not only as dependency versions but also minimum java version, google java format version, etc.

Notable changes.

  • palantir-consistent-versions plugin is dropped entirely and replaced with explicit versions using a single gradle's version catalog (top-level versions.toml file). This file contains all dependencies for plugins, build script dependencies and module dependencies, along with their version numbers. It also contains the minimum java version, google formatter version and min gradle version to run the build. The same catalog is reused for included builds (composite builds) as well.
  • buildSrc is replaced with build-tools/build-infra composite build project. This is the first step on the long road to move some of the scripts into a convention/ build helper plugin, making them hopefully faster to load and execute.
  • tidy and forbidden apis are now applied to composite builds as well.

While this isn't strictly necessary, the concept of a "lock file" for dependencies used in the main and test modules is useful - it allows some manual control when transitive dependency versions or dependencies change (otherwise they'd go unnoticed). I used my own small plugin to collect these dependencies and update/ verify their consistency (on tidy and check tasks). This plugin does not alter dependency resolution (like palantir's did). It merely sums up what is used, in which version and where. See versions.lock to see the output.

I also corrected a few deprecations and minor glitches in gradle files.

This patch does not upgrade any dependencies - it's left as a follow up.

@dweiss dweiss added this to the 10.0.0 milestone Jun 13, 2024
@dweiss dweiss marked this pull request as ready for review June 13, 2024 15:40
@dweiss dweiss self-assigned this Jun 17, 2024
@dweiss
Copy link
Contributor Author

dweiss commented Jun 17, 2024

I'm going to merge this in. Please report any problems with the build if you encounter them.

@dweiss dweiss merged commit dc28786 into apache:main Jun 17, 2024
3 checks passed
asfgit pushed a commit that referenced this pull request Jun 18, 2024
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall; thanks for doing this @dweiss !

What script generates versions.lock? The "because" sections look mysterious.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A plugin does this. It is similar in nature to palantir's but "passive" - it only collects dependencies from selected configurations and makes sure they're consistent, it won't lock their versions or try to force them. It's more of a safety/ early warning mechanism - you'll have to use gradle's own mechanisms for version alignment, if something is not right.

The documentation is non-existent but you can grep through the code, if you're interested.

https://github.com/carrotsearch/gradle-dependencychecks-plugin

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh - the "because" contain a hash key and all configurations/projects which refer to a dependency. These hashes are used next to dependencies to shorten up the list. For example these are pulled in by the same set of configurations:

      "net.sourceforge.nekohtml:nekohtml:1.9.17" : "6f16ff86,refs=2",
      "org.apache.commons:commons-compress:1.19" : "6f16ff86,refs=2",

from:

"because" : {
    ...
    "6f16ff86" : [
      {
        "configuration" : "testCompileClasspath",
        "projectPath" : ":lucene:benchmark"
      },
      {
        "configuration" : "testRuntimeClasspath",
        "projectPath" : ":lucene:benchmark"
      }
    ],

the plugin needs a set of projects and configurations to take into account - this is set up in dependencies.gradle.

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