1616
1717package net .virtualvoid .sbt .graph
1818
19- import scala .language .reflectiveCalls
20-
21- import sbt ._
22- import Keys ._
23- import sbt .complete .Parser
19+ import net .virtualvoid .sbt .graph .GraphTransformations .reverseGraphStartingAt
2420import net .virtualvoid .sbt .graph .backend .{ IvyReport , SbtUpdateReport }
2521import net .virtualvoid .sbt .graph .rendering .{ AsciiGraph , AsciiTree , DagreHTML }
2622import net .virtualvoid .sbt .graph .util .IOUtil
27- import internal .librarymanagement ._
28- import librarymanagement ._
23+ import sbt .Keys ._
24+ import sbt ._
25+ import sbt .complete .Parser
2926import sbt .dependencygraph .DependencyGraphSbtCompat
3027import sbt .dependencygraph .DependencyGraphSbtCompat .Implicits ._
28+ import sbt .internal .librarymanagement ._
29+
30+ import scala .language .reflectiveCalls
3131
3232object DependencyGraphSettings {
3333 import DependencyGraphKeys ._
@@ -48,7 +48,17 @@ object DependencyGraphSettings {
4848 ivyReport := { Def .task { ivyReportFunction.value.apply(config.toString) } dependsOn (ignoreMissingUpdate) }.value,
4949 crossProjectId := sbt.CrossVersion (scalaVersion.value, scalaBinaryVersion.value)(projectID.value),
5050 moduleGraphSbt :=
51- ignoreMissingUpdate.value.configuration(configuration.value).map(report ⇒ SbtUpdateReport .fromConfigurationReport(report, crossProjectId.value)).getOrElse(ModuleGraph .empty),
51+ ignoreMissingUpdate
52+ .value
53+ .configuration(configuration.value)
54+ .map(
55+ report ⇒
56+ SbtUpdateReport .fromConfigurationReport(
57+ report,
58+ crossProjectId.value
59+ )
60+ )
61+ .getOrElse(ModuleGraph .empty),
5262 moduleGraphIvyReport := IvyReport .fromReportFile(absoluteReportPath(ivyReport.value)),
5363 moduleGraph := {
5464 sbtVersion.value match {
@@ -92,8 +102,17 @@ object DependencyGraphSettings {
92102 """ %s<BR/><B>%s</B><BR/>%s""" .format(organisation, name, version)
93103 },
94104 whatDependsOn := {
95- val module = artifactIdParser.parsed
96- streams.value.log.info(AsciiTree (GraphTransformations .reverseGraphStartingAt(moduleGraph.value, module)))
105+ streams
106+ .value
107+ .log
108+ .info(
109+ AsciiTree (
110+ reverseGraphStartingAt(
111+ moduleGraph.value,
112+ artifactIdParser.parsed
113+ )
114+ )
115+ )
97116 },
98117 licenseInfo := showLicenseInfo(moduleGraph.value, streams.value)) ++ AsciiGraph .asciiGraphSetttings)
99118
@@ -105,7 +124,7 @@ object DependencyGraphSettings {
105124 (config : String ) ⇒ {
106125 val org = projectID.organization
107126 val name = crossName(ivyModule)
108- file(s " ${ crossTarget} /resolution-cache/reports/ $org- $name- $config.xml " )
127+ file(s " $crossTarget/resolution-cache/reports/ $org- $name- $config.xml " )
109128 }
110129 }
111130
@@ -151,29 +170,57 @@ object DependencyGraphSettings {
151170 }.mkString(" \n\n " )
152171 streams.log.info(output)
153172 }
154-
155- import Project ._
156173 val shouldForceParser : State ⇒ Parser [Boolean ] = { (state : State ) ⇒
157174 import sbt .complete .DefaultParsers ._
158175
159176 (Space ~> token(" --force" )).? .map(_.isDefined)
160177 }
161178
179+ val filterRulesParser : Def .Initialize [State ⇒ Parser [Seq [FilterRule ]]] =
180+ resolvedScoped { ctx ⇒
181+ (state : State ) ⇒
182+ import sbt .complete .DefaultParsers ._
183+ (Space ~> token(StringBasic , " filter" )).* .map {
184+ _.map(FilterRule (_))
185+ }
186+ }
187+
162188 val artifactIdParser : Def .Initialize [State ⇒ Parser [ModuleId ]] =
163189 resolvedScoped { ctx ⇒
164190 (state : State ) ⇒
165191 val graph = loadFromContext(moduleGraphStore, ctx, state) getOrElse ModuleGraph (Nil , Nil )
166192
167193 import sbt .complete .DefaultParsers ._
168- graph.nodes.map(_.id).map {
169- case id @ ModuleId (org, name, version) ⇒
170- (Space ~ token(org) ~ token(Space ~ name) ~ token(Space ~ version)).map(_ ⇒ id)
171- }.reduceOption(_ | _).getOrElse {
172- (Space ~> token(StringBasic , " organization" ) ~ Space ~ token(StringBasic , " module" ) ~ Space ~ token(StringBasic , " version" )).map {
173- case ((((org, _), mod), _), version) ⇒
174- ModuleId (org, mod, version)
194+ graph
195+ .nodes
196+ .map(_.id)
197+ .map {
198+ case id @ ModuleId (org, name, version) ⇒
199+ (
200+ Space ~
201+ token(org) ~
202+ token(Space ~ name) ~
203+ token(Space ~ version))
204+ .map(_ ⇒ id)
205+ }
206+ .reduceOption(_ | _)
207+ .getOrElse {
208+ (
209+ Space ~>
210+ token(StringBasic , " organization" ) ~ Space ~
211+ token(StringBasic , " module" ) ~ Space ~
212+ token(StringBasic , " version" ))
213+ .map {
214+ case (
215+ (
216+ ((org, _), mod),
217+ _
218+ ),
219+ version
220+ ) ⇒
221+ ModuleId (org, mod, version)
222+ }
175223 }
176- }
177224 }
178225
179226 // This is to support 0.13.8's InlineConfigurationWithExcludes while not forcing 0.13.8
0 commit comments