Skip to content

Commit 4fe2f8e

Browse files
committed
Split to MiniDependencyTreePlugin
Ref sbt#5880 This split the dependency-graph plugin into MiniDependencyTreePlugin and DependencyTreePlugin.
1 parent 54747b8 commit 4fe2f8e

File tree

14 files changed

+198
-164
lines changed

14 files changed

+198
-164
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ env:
1515
matrix:
1616
- SBT_CMD="mimaReportBinaryIssues ; javafmtCheck ; Test / javafmtCheck; scalafmtCheckAll ; scalafmtSbtCheck; serverTestProj/scalafmtCheckAll; headerCheck ;test:headerCheck ;whitesourceOnPush ;test:compile; publishLocal; test; serverTestProj/test; doc; $UTIL_TESTS; ++$SCALA_213; $UTIL_TESTS"
1717
- SBT_CMD="scripted actions/* apiinfo/* compiler-project/* ivy-deps-management/* reporter/* tests/* watch/* classloader-cache/* package/*"
18-
- SBT_CMD="scripted dependency-graph/* dependency-management/* plugins/* project-load/* java/* run/* nio/*"
18+
- SBT_CMD="dependencyTreeProj/publishLocal; scripted dependency-graph/* dependency-management/* plugins/* project-load/* java/* run/* nio/*"
1919
- SBT_CMD="repoOverrideTest:scripted dependency-management/*; scripted source-dependencies/* project/*"
2020

2121
matrix:

build.sbt

+10
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,15 @@ lazy val scriptedPluginProj = (project in file("scripted-plugin"))
648648
),
649649
)
650650

651+
lazy val dependencyTreeProj = (project in file("dependency-tree"))
652+
.dependsOn(sbtProj)
653+
.settings(
654+
sbtPlugin := true,
655+
baseSettings,
656+
name := "sbt-dependency-tree",
657+
// mimaSettings,
658+
)
659+
651660
// Implementation and support code for defining actions.
652661
lazy val actionsProj = (project in file("main-actions"))
653662
.dependsOn(
@@ -1361,6 +1370,7 @@ def allProjects =
13611370
scriptedSbtReduxProj,
13621371
scriptedSbtOldProj,
13631372
scriptedPluginProj,
1373+
dependencyTreeProj,
13641374
protocolProj,
13651375
actionsProj,
13661376
commandProj,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* sbt
3+
* Copyright 2011 - 2018, Lightbend, Inc.
4+
* Copyright 2008 - 2010, Mark Harrah
5+
* Licensed under Apache License 2.0 (see LICENSE)
6+
*/
7+
8+
package sbt
9+
package plugins
10+
11+
object DependencyTreePlugin extends AutoPlugin {
12+
object autoImport extends DependencyTreeKeys
13+
override def trigger = AllRequirements
14+
override def requires = MiniDependencyTreePlugin
15+
16+
val configurations = Vector(Compile, Test, IntegrationTest, Runtime, Provided, Optional)
17+
18+
// MiniDependencyTreePlugin provides baseBasicReportingSettings for Compile and Test
19+
override def projectSettings: Seq[Def.Setting[_]] =
20+
((configurations diff Vector(Compile, Test)) flatMap { config =>
21+
inConfig(config)(DependencyTreeSettings.baseBasicReportingSettings)
22+
}) ++
23+
(configurations flatMap { config =>
24+
inConfig(config)(DependencyTreeSettings.baseFullReportingSettings)
25+
})
26+
}

main/src/main/scala/sbt/Defaults.scala

+10
Original file line numberDiff line numberDiff line change
@@ -3983,6 +3983,16 @@ trait BuildExtra extends BuildCommon with DefExtra {
39833983
Seq(compose(onLoad, add), compose(onUnload, remove))
39843984
}
39853985

3986+
/**
3987+
* Adds Maven resolver plugin.
3988+
*/
3989+
def addDependencyTreePlugin: Setting[Seq[ModuleID]] =
3990+
libraryDependencies += sbtPluginExtra(
3991+
ModuleID("org.scala-sbt", "sbt-dependency-tree", sbtVersion.value),
3992+
sbtBinaryVersion.value,
3993+
scalaBinaryVersion.value
3994+
)
3995+
39863996
/**
39873997
* Adds Maven resolver plugin.
39883998
*/

main/src/main/scala/sbt/internal/PluginDiscovery.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ object PluginDiscovery {
5252
"sbt.plugins.SemanticdbPlugin" -> sbt.plugins.SemanticdbPlugin,
5353
"sbt.plugins.JUnitXmlReportPlugin" -> sbt.plugins.JUnitXmlReportPlugin,
5454
"sbt.plugins.Giter8TemplatePlugin" -> sbt.plugins.Giter8TemplatePlugin,
55-
"sbt.plugins.DependencyGraphPlugin" -> sbt.plugins.DependencyGraphPlugin,
55+
"sbt.plugins.MiniDependencyTreePlugin" -> sbt.plugins.MiniDependencyTreePlugin,
5656
)
5757
val detectedAutoPlugins = discover[AutoPlugin](AutoPlugins)
5858
val allAutoPlugins = (defaultAutoPlugins ++ detectedAutoPlugins.modules) map {

main/src/main/scala/sbt/internal/graph/DependencyGraphKeys.scala main/src/main/scala/sbt/plugins/DependencyTreeKeys.scala

+22-31
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,36 @@
66
*/
77

88
package sbt
9-
package internal
10-
package graph
9+
package plugins
1110

1211
import java.io.File
1312
import java.net.URI
13+
import sbt.internal.graph._
1414
import sbt.BuildSyntax._
1515
import sbt.librarymanagement.{ ModuleID, UpdateReport }
1616

17-
trait DependencyGraphKeys {
17+
trait MiniDependencyTreeKeys {
18+
val dependencyTreeIncludeScalaLibrary = settingKey[Boolean](
19+
"Specifies if scala dependency should be included in dependencyTree output"
20+
)
21+
val dependencyTree = taskKey[Unit]("Prints an ascii tree of all the dependencies to the console")
1822
val asString = taskKey[String]("Provides the string value for the task it is scoped for")
1923
// val printToConsole = TaskKey[Unit]("printToConsole", "Prints the tasks value to the console")
2024
val toFile = inputKey[File]("Writes the task value to the given file")
2125

22-
val dependencyTreeIncludeScalaLibrary = settingKey[Boolean](
23-
"Specifies if scala dependency should be included in dependencyTree output"
24-
)
26+
// internal
27+
private[sbt] val ignoreMissingUpdate =
28+
TaskKey[UpdateReport]("dependencyUpdate", "sbt-dependency-graph version of update")
29+
private[sbt] val moduleGraphStore =
30+
TaskKey[ModuleGraph]("module-graph-store", "The stored module-graph from the last run")
31+
val whatDependsOn =
32+
InputKey[String]("what-depends-on", "Shows information about what depends on the given module")
33+
private[sbt] val crossProjectId = SettingKey[ModuleID]("dependency-graph-cross-project-id")
34+
}
2535

36+
object MiniDependencyTreeKeys extends MiniDependencyTreeKeys
37+
38+
abstract class DependencyTreeKeys {
2639
val dependencyGraphMLFile =
2740
settingKey[File]("The location the graphml file should be generated at")
2841
val dependencyGraphML =
@@ -59,37 +72,15 @@ trait DependencyGraphKeys {
5972
val dependencyBrowseTree = taskKey[URI](
6073
"Opens an HTML page that can be used to view the dependency tree"
6174
)
62-
val moduleGraph = taskKey[ModuleGraph]("The dependency graph for a project")
63-
val moduleGraphIvyReport = taskKey[ModuleGraph](
64-
"The dependency graph for a project as generated from an Ivy Report XML"
65-
)
66-
val moduleGraphSbt = taskKey[ModuleGraph](
67-
"The dependency graph for a project as generated from SBT data structures."
68-
)
69-
val dependencyGraph = inputKey[Unit]("Prints the ascii graph to the console")
70-
val dependencyTree = taskKey[Unit]("Prints an ascii tree of all the dependencies to the console")
75+
val dependencyTreeModuleGraph = taskKey[ModuleGraph]("The dependency graph for a project")
76+
7177
val dependencyList =
7278
taskKey[Unit]("Prints a list of all dependencies to the console")
7379
val dependencyStats =
7480
taskKey[Unit]("Prints statistics for all dependencies to the console")
75-
val ivyReportFunction = taskKey[String => File](
76-
"A function which returns the file containing the ivy report from the ivy cache for a given configuration"
77-
)
78-
val ivyReport = taskKey[File](
79-
"A task which returns the location of the ivy report file for a given configuration (default `compile`)."
80-
)
8181
val dependencyLicenseInfo = taskKey[Unit](
8282
"Aggregates and shows information about the licenses of dependencies"
8383
)
84-
85-
// internal
86-
private[sbt] val ignoreMissingUpdate =
87-
TaskKey[UpdateReport]("dependencyUpdate", "sbt-dependency-graph version of update")
88-
private[sbt] val moduleGraphStore =
89-
TaskKey[ModuleGraph]("module-graph-store", "The stored module-graph from the last run")
90-
val whatDependsOn =
91-
InputKey[String]("what-depends-on", "Shows information about what depends on the given module")
92-
private[sbt] val crossProjectId = SettingKey[ModuleID]("dependency-graph-cross-project-id")
9384
}
9485

95-
object DependencyGraphKeys extends DependencyGraphKeys
86+
object DependencyTreeKeys extends DependencyTreeKeys

0 commit comments

Comments
 (0)