Skip to content

Commit 86434a2

Browse files
authored
fix: Use hidden project configuration for dependency management (#194)
1 parent 0766a8c commit 86434a2

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

.scalafmt.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ runner.dialect = scala212
33
maxColumn = 120
44
align.preset = none
55
rewrite.trailingCommas.style = always
6-

src/main/scala/com/sksamuel/scapegoat/sbt/ScapegoatSbtPlugin.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ object ScapegoatSbtPlugin extends AutoPlugin {
1212

1313
object autoImport {
1414
val Scapegoat = config("scapegoat") extend Compile
15+
val ScapegoatDeps = (config("scapegoat-dep") extend Compile).hide
1516

1617
lazy val scapegoat = taskKey[Unit]("Run scapegoat quality checks")
1718
lazy val scapegoatCleanTask = taskKey[Unit]("Conditionally clean the scapegoat output directories")
@@ -41,7 +42,7 @@ object ScapegoatSbtPlugin extends AutoPlugin {
4142
}
4243
}
4344

44-
override def projectConfigurations: Seq[Configuration] = Seq(Scapegoat)
45+
override def projectConfigurations: Seq[Configuration] = Seq(ScapegoatDeps)
4546

4647
override def trigger = allRequirements
4748

@@ -69,7 +70,7 @@ object ScapegoatSbtPlugin extends AutoPlugin {
6970
unmanagedClasspath := (Compile / unmanagedClasspath).value,
7071
scalacOptions := {
7172
// find all deps for the compile scope
72-
val scapegoatDependencies = (Scapegoat / update).value matching configurationFilter(Scapegoat.name)
73+
val scapegoatDependencies = (ScapegoatDeps / update).value matching configurationFilter(ScapegoatDeps.name)
7374
// ensure we have the scapegoat dependency on the classpath and if so add it as a scalac plugin
7475
scapegoatDependencies.find(_.getAbsolutePath.contains(ArtifactId)) match {
7576
case None =>
@@ -149,7 +150,7 @@ object ScapegoatSbtPlugin extends AutoPlugin {
149150
case _ => "1.4.17"
150151
}
151152
}
152-
crossVersion(GroupId %% ArtifactId % selectedScapegoatVersion) % Scapegoat
153+
crossVersion(GroupId %% ArtifactId % selectedScapegoatVersion) % ScapegoatDeps
153154
},
154155
)
155156
}

src/sbt-test/artifacts/report-and-inclusion/build.sbt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
lazy val root = (project in file("."))
22
.settings(
33
name := "test-scapegoat-inclusion-in-pom",
4-
ThisBuild / scalaVersion := "2.13.10",
4+
libraryDependencies += "org.typelevel" %% "cats-core" % "2.12.0",
5+
ThisBuild / scalaVersion := "2.13.14",
56
TaskKey[Unit]("check") := {
67
val pom = scala.xml.XML.loadFile(makePom.value)
78
(pom \\ "dependencies").map(_ \ "dependency").find(dependency =>
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
import cats.syntax.all._
2+
13
object Boot extends App {
24

3-
println("Hello World")
5+
// Depend on Cats to verify that dependencies are maintained
6+
println("Hello " |+| " World")
7+
48
val ohno = Option(42).get
59

610
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
> compile
1+
> clean
22
-> scapegoat
33
$ exists target/scala-2.13/scapegoat-report/scapegoat.xml
4+
-$ exists target/scala-2.13/classes/Boot.class
5+
> clean
6+
> compile
47
> makePom
8+
-$ exists target/scala-2.13/scapegoat-report/scapegoat.xml
59
> check

0 commit comments

Comments
 (0)