-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sbt
99 lines (88 loc) · 3.06 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
ThisBuild / scalaVersion := "3.1.3"
val organizeImportVersion = "0.6.0"
val scalaTestVersion = "3.2.17"
val scalaCheckVersion = "3.2.17.0"
// all LTS versions & latest minor ones
val supportedScalaVersions = List(
"2.12.19",
"2.13.13",
"3.1.3",
"3.2.2",
"3.3.0",
"3.3.1",
"3.3.3",
"3.4.1"
)
inThisBuild(
List(
organization := "io.github.polentino",
homepage := Some(url("https://github.com/polentino/redacted")),
licenses := List(
"WTFPL" -> url("http://www.wtfpl.net/")
),
developers := List(
Developer(
"polentino",
"Diego Casella",
"polentino911@gmail.com",
url("https://linkedin.com/in/diegocasella")
)
)
)
)
Global / onChangedBuildSource := ReloadOnSourceChanges
lazy val root = (project in file("."))
.settings(
name := "redacted-root",
crossScalaVersions := Nil,
test / skip := true,
publish / skip := true
)
.aggregate(redactedLibrary, redactedCompilerPlugin, redactedTests)
val scalafixSettings = Seq(
scalafixDependencies += "com.liancheng" %% "organize-imports" % organizeImportVersion,
semanticdbEnabled := true,
semanticdbVersion := scalafixSemanticdb.revision
)
val crossCompileSettings = scalafixSettings ++ Seq(
Test / skip := true,
crossTarget := target.value / s"scala-${scalaVersion.value}", // workaround for https://github.com/sbt/sbt/issues/5097
crossVersion := CrossVersion.full,
crossScalaVersions := supportedScalaVersions
)
lazy val redactedLibrary = (project in file("library"))
.settings(name := "redacted")
.settings(crossCompileSettings)
lazy val redactedCompilerPlugin = (project in file("plugin"))
.settings(name := "redacted-plugin")
.settings(
crossCompileSettings,
libraryDependencies += (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) => "org.scala-lang" %% "scala3-compiler" % scalaVersion.value
case Some((2, _)) => "org.scala-lang" % "scala-compiler" % scalaVersion.value
case v => throw new Exception(s"Scala version $v not recognised")
})
)
lazy val redactedTests = (project in file("tests"))
.dependsOn(redactedLibrary)
.settings(name := "redacted-tests")
.settings(scalafixSettings)
.settings(
publish / skip := true,
crossScalaVersions := supportedScalaVersions,
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % scalaTestVersion % Test,
"org.scalatestplus" %% "scalacheck-1-17" % scalaCheckVersion % Test
),
Test / scalacOptions ++= {
val jar = (redactedCompilerPlugin / Compile / packageBin).value
val addScala2Plugin = "-Xplugin-require:redacted-plugin"
val addScala3Plugin = "-Xplugin:" + jar.getAbsolutePath
val dummy = "-Jdummy=" + jar.lastModified
Seq(addScala2Plugin, addScala3Plugin, dummy)
}
)
addCommandAlias("testAll", "; clean; +test")
addCommandAlias("fmt", "; scalafix; scalafmtAll; scalafmtSbt")
addCommandAlias("fmtCheck", "; scalafmtCheckAll ; scalafmtSbtCheck")
addCommandAlias("crossReleaseAll", "; clean; +publishSigned; sonatypeBundleRelease")