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

fix: Use hidden project configuration for dependency management #194

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ runner.dialect = scala212
maxColumn = 120
align.preset = none
rewrite.trailingCommas.style = always

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ object ScapegoatSbtPlugin extends AutoPlugin {

object autoImport {
val Scapegoat = config("scapegoat") extend Compile
val ScapegoatDeps = (config("scapegoat-dep") extend Compile).hide

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

override def projectConfigurations: Seq[Configuration] = Seq(Scapegoat)
override def projectConfigurations: Seq[Configuration] = Seq(ScapegoatDeps)

override def trigger = allRequirements

Expand Down Expand Up @@ -69,7 +70,7 @@ object ScapegoatSbtPlugin extends AutoPlugin {
unmanagedClasspath := (Compile / unmanagedClasspath).value,
scalacOptions := {
// find all deps for the compile scope
val scapegoatDependencies = (Scapegoat / update).value matching configurationFilter(Scapegoat.name)
val scapegoatDependencies = (ScapegoatDeps / update).value matching configurationFilter(ScapegoatDeps.name)
// ensure we have the scapegoat dependency on the classpath and if so add it as a scalac plugin
scapegoatDependencies.find(_.getAbsolutePath.contains(ArtifactId)) match {
case None =>
Expand Down Expand Up @@ -149,7 +150,7 @@ object ScapegoatSbtPlugin extends AutoPlugin {
case _ => "1.4.17"
}
}
crossVersion(GroupId %% ArtifactId % selectedScapegoatVersion) % Scapegoat
crossVersion(GroupId %% ArtifactId % selectedScapegoatVersion) % ScapegoatDeps
},
)
}
Expand Down
3 changes: 2 additions & 1 deletion src/sbt-test/artifacts/report-and-inclusion/build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
lazy val root = (project in file("."))
.settings(
name := "test-scapegoat-inclusion-in-pom",
ThisBuild / scalaVersion := "2.13.10",
libraryDependencies += "org.typelevel" %% "cats-core" % "2.12.0",
ThisBuild / scalaVersion := "2.13.14",
TaskKey[Unit]("check") := {
val pom = scala.xml.XML.loadFile(makePom.value)
(pom \\ "dependencies").map(_ \ "dependency").find(dependency =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import cats.syntax.all._

object Boot extends App {

println("Hello World")
// Depend on Cats to verify that dependencies are maintained
println("Hello " |+| " World")

val ohno = Option(42).get

}
6 changes: 5 additions & 1 deletion src/sbt-test/artifacts/report-and-inclusion/test
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
> compile
> clean
-> scapegoat
$ exists target/scala-2.13/scapegoat-report/scapegoat.xml
-$ exists target/scala-2.13/classes/Boot.class
> clean
> compile
> makePom
-$ exists target/scala-2.13/scapegoat-report/scapegoat.xml
> check