palantir / gradle-consistent-versions

Compact, constraint-friendly lockfiles for your dependencies
Apache License 2.0
112 stars 15 forks source link

Support dependency option in why task #1115

Closed pkoenig10 closed 8 months ago

pkoenig10 commented 8 months ago

Before this PR

Using the why task to get information about multiple dependencies is rather cumbersome.

For example, I may want to get information about all Jackson dependencies. The only way to do that today is providing all the relevant hashes as a comma-separated value, which requires some command line manipulation:

rg jackson versions.lock | rg 'constraints: (\w+)' -or '$1' | tr '\n' ',' | xargs ./gradlew why --hash

After this PR

The dependencyInsight command uses --dependency parameter which matches uses a simple contains check.

https://github.com/gradle/gradle/blob/5479bbb152f69f27746c4528778b5c01e6eb794a/subprojects/diagnostics/src/main/java/org/gradle/api/tasks/diagnostics/internal/dsl/DependencyResultSpec.java#L34-L43

I find this easy to use and sufficient for nearly all the queries I want to make.

There's also value is offering an interface that is consistent with dependencyInsight.

This PR adds a --dependency option to the why task that behaves more-or-less identically to the same parameter with dependencyInsight.

For example, here's the output running against https://github.com/palantir/tritium:

tritium develop .$ ./gradlew --no-scan why --dependency safe-logging

> Task :why
com.palantir.safe-logging:logger:3.7.0
        projects -> 3.7.0
        com.palantir.nylon:nylon-threads -> 3.6.0
        com.palantir.tracing:tracing -> 3.5.0

com.palantir.safe-logging:logger-slf4j:3.7.0
        com.palantir.safe-logging:logger -> 3.7.0

com.palantir.safe-logging:logger-spi:3.7.0
        com.palantir.safe-logging:logger -> 3.7.0
        com.palantir.safe-logging:logger-slf4j -> 3.7.0

com.palantir.safe-logging:preconditions:3.7.0
        projects -> 3.7.0
        com.palantir.nylon:nylon-threads -> 3.6.0
        com.palantir.tracing:tracing -> 3.5.0

com.palantir.safe-logging:safe-logging:3.7.0
        projects -> 3.7.0
        com.palantir.nylon:nylon-threads -> 3.6.0
        com.palantir.safe-logging:logger -> 3.7.0
        com.palantir.safe-logging:logger-spi -> 3.7.0
        com.palantir.safe-logging:preconditions -> 3.7.0
        com.palantir.tracing:tracing -> 3.5.0

The --hash parameter is still supported to maintain backwards compatibility.

changelog-app[bot] commented 8 months ago

Generate changelog in changelog-dir>`changelog/@unreleased`</changelog-dir

What do the change types mean? - `feature`: A new feature of the service. - `improvement`: An incremental improvement in the functionality or operation of the service. - `fix`: Remedies the incorrect behaviour of a component of the service in a backwards-compatible way. - `break`: Has the potential to break consumers of this service's API, inclusive of both Palantir services and external consumers of the service's API (e.g. customer-written software or integrations). - `deprecation`: Advertises the intention to remove service functionality without any change to the operation of the service itself. - `manualTask`: Requires the possibility of manual intervention (running a script, eyeballing configuration, performing database surgery, ...) at the time of upgrade for it to succeed. - `migration`: A fully automatic upgrade migration task with no engineer input required. _Note: only one type should be chosen._
How are new versions calculated? - ❗The `break` and `manual task` changelog types will result in a major release! - 🐛 The `fix` changelog type will result in a minor release in most cases, and a patch release version for patch branches. This behaviour is configurable in autorelease. - ✨ All others will result in a minor version release.

Type

- [X] Feature - [ ] Improvement - [ ] Fix - [ ] Break - [ ] Deprecation - [ ] Manual task - [ ] Migration

Description

The `why` task now supports a `--dependency` option that matches the behavior of `dependencyInsight`. **Check the box to generate changelog(s)** - [x] Generate changelog entry
svc-autorelease commented 8 months ago

Released 2.19.0