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

[2.x] Refactor dependencyTree into an input task #7849

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

Friendseeker
Copy link
Member

Following Eugene's comment, this PR refactors dependencyTree into an input task, with the aim of

  • Featuring minimal additional settings key (to avoid settings key explosion)
  • Supporting all capabilities of MiniDependencyTreePlugin
  • Supporting most capabilities of the full DependencyTreePlugin
  • Supporting json output to both terminal & file
  • Featuring a simple API

The refactored input task is called dependencyReport. Old MiniDependencyTreePlugin settings are still kept for compatibility purpose.

Syntax

dependencyReport [format] [subformat]

Parameters

  • format: text|json|html|graphml: specifies the format of the output, defaults to text
  • subformat: if applicable further specifies format of output
    • text format: subformat takes list|stat|info, corresponding to dependencyList, dependencyStats, dependencyLicenseInfo. Empty subformat corresponds to dependencyTree
    • html format: subformat takes tree|graph, corresponding to browseTreeHTMLTask, browseGraphHTMLTask
    • json/graphml format: does not take subformat

Example

sbt:contraband> dependencyReport
[info] org.scala-sbt:contraband_2.12:0.5.3-SNAPSHOT [S]
[info]    -com.eed3si9n:sjson-new-scalajson_2.12:0.10.0 [S]
[info]   |  -com.eed3si9n:shaded-jawn-parser_2.12:1.3.2 [S]
[info]   |  -com.eed3si9n:shaded-scalajson_2.12:1.0.0-M4 [S]
[info]   |  -com.eed3si9n:sjson-new-core_2.12:0.10.0 [S]
[info]   |
[info]    -org.parboiled:parboiled_2.12:2.5.1 [S]
[info]
[info] Dependency report written to D:\Repos\contraband\library\target\compile\dependencies.txt

sbt:contraband> dependencyReport json
[info] [{"text":"org.scala-sbt:contraband_2.12:0.5.3-SNAPSHOT","children":[{"text":"com.eed3si9n:sjson-new-scalajson_2.12:0.10.0","children"
:[{"text":"com.eed3si9n:shaded-jawn-parser_2.12:1.3.2","children":[]},{"text":"com.eed3si9n:shaded-scalajson_2.12:1.0.0-M4","children":[]},{"text":"com.eed3si9n:sjson-new-core_2.12:0.10.0","children":[]}]},{"text":"org.parboiled:parboiled_2.12:2.5.1","children":[]}]}]
[info] Dependency report written to D:\Repos\contraband\library\target\compile\dependencies.json
[success] Total time: 0 s, completed Oct 30, 2024, 6:11:06 p.m.

sbt:contraband> Test / dependencyReport html graph
[info] Dependency report written to D:\Repos\contraband\library\target\test\graph\graph.html

Closes #7770

import sbt.Project._
import sbt.librarymanagement.Configurations.{ Compile, Test }

object DependencyReportPlugin extends AutoPlugin {
Copy link
Member

Choose a reason for hiding this comment

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

For sbt 2.x, I wonder if we could consolidate 3 dependency-tree plugins into one. When we in-sourced it to sbt/sbt we had to split it into two because of the amount of setting keys it introduced to all subproject slowed down large builds. If we can reduce the number of injected settings we use this opportunity to do so.

Copy link
Member Author

Choose a reason for hiding this comment

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

My concern is that there's some settings that are currently unsupported as they are ugly to support via command line argument (e.g. Graph customization options as part of full dependency tree plugin).

I don't know whether people actually use these settings though.

Copy link
Member Author

@Friendseeker Friendseeker Nov 1, 2024

Choose a reason for hiding this comment

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

@mkurz What is your opinion on Eugene's idea of consolidating 3 dependency-tree plugins into one?

I personally don't use dependency tree plugin often so need feedback from dependency tree plugin users to make major decisions like this.

Copy link
Member

Choose a reason for hiding this comment

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

I can confirm that the lack of consolidation is rather mystifying for users. It comes up from time to time on Discord.

@@ -35,6 35,12 @@ trait MiniDependencyTreeKeys {

object MiniDependencyTreeKeys extends MiniDependencyTreeKeys

trait DependencyReportKeys {
val dependencyReport = inputKey[Unit]("Generates a report of the project dependencies")
Copy link
Member

Choose a reason for hiding this comment

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

Not everything is a tree, but here too I'm thinking we should just use dependencyTree key in sbt 2.x, and maybe dependencyTreeNext or something if we introduce it to 1.x?

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.

3 participants