Skip to content

[2.x] feat: dependencyLicenseInfo#8506

Merged
eed3si9n merged 3 commits intosbt:developfrom
saber04414:add-json-output-for-dependency-commands
Jan 13, 2026
Merged

[2.x] feat: dependencyLicenseInfo#8506
eed3si9n merged 3 commits intosbt:developfrom
saber04414:add-json-output-for-dependency-commands

Conversation

@saber04414
Copy link
Copy Markdown
Contributor

Summary

This PR adds JSON output support to the dependencyLicenseInfo task, addressing issue #7771. The implementation follows the same pattern as the existing dependencyTree task which already supports JSON output (#7770).

Changes

  • Created LicenseInfo.scala in sbt/internal/graph/rendering/:

    • render() method for text output (matches original implementation)
    • renderJson() method for JSON output using LList.iso pattern consistent with codebase
  • Added dependencyLicenseInfo key to DependencyTreeKeys.scala

  • Implemented dependencyLicenseInfo task in DependencyTreeSettings.scala:

    • Supports text output (default)
    • Supports JSON output via json format or .json file extension
    • Supports --out option for file output
    • Supports --quiet option
    • Reuses existing ArgsParser and handleOutput utilities

Features

  • Groups dependencies by license
  • Sorts licenses and modules alphabetically
  • Filters out evicted modules
  • JSON output format: Array of objects with license and modules fields
  • Auto-detects JSON format from file extension (e.g., --out licenses.json)

Usage Examples

# Text output (default)
sbt dependencyLicenseInfo

# JSON output
sbt dependencyLicenseInfo json

# Write to JSON file
sbt dependencyLicenseInfo json --out licenses.json
# or simply
sbt dependencyLicenseInfo --out licenses.json

# Quiet mode (returns output as task value)
sbt "dependencyLicenseInfo json --quiet"

Related Issues

Files Changed

  • main/src/main/scala/sbt/internal/graph/rendering/LicenseInfo.scala (new file, 63 lines)
  • main/src/main/scala/sbt/plugins/DependencyTreeKeys.scala (+1 line)
  • main/src/main/scala/sbt/plugins/DependencyTreeSettings.scala (+44 lines)

Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=157775043

saber04414 and others added 2 commits January 13, 2026 03:04
- Add LicenseInfo rendering object with text and JSON output
- Add dependencyLicenseInfo input task key
- Implement dependencyLicenseInfo task with JSON format support
- Supports --out option for file output
- Auto-detects JSON format from .json file extension
- Follows same pattern as dependencyTree task

Resolves sbt#7771
@eed3si9n
Copy link
Copy Markdown
Member

Thanks for the contribution. Could you add integration test under https://github.com/sbt/sbt/tree/develop/sbt-app/src/sbt-test/dependency-graph please? The details on the scipted tests are here - https://github.com/sbt/sbt/blob/develop/contributing-docs/05_scripted_tests.md

@eed3si9n eed3si9n changed the title Add JSON output support to dependencyLicenseInfo (#7771) [2.x] feat: dependencyLicenseInfo Jan 13, 2026
@eed3si9n eed3si9n merged commit aeabb90 into sbt:develop Jan 13, 2026
14 checks passed
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.

dependencyLicenseInfo should also display/write json, not just text

2 participants