-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sbt
82 lines (76 loc) · 3 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
import xerial.sbt.Sonatype.*
inThisBuild(
Seq(
organization := "com.hmemcpy",
homepage := Some(url("https://github.com/hmemcpy/zio-clippy")),
licenses := License.Apache2 :: Nil,
developers := List(
Developer(
"hmemcpy",
"Igal Tabachnik",
url("https://hmemcpy.com")
)
),
crossScalaVersions := List(
"2.13.14",
"2.13.13",
"2.13.12",
"2.13.10",
"2.12.15", // the version of scala used by sbt 1.6.2
"2.12.16", // the version of scala used by sbt 1.7.2
"2.12.17", // the version of scala used by sbt 1.8.2
"3.2.2"
),
scalaVersion := (ThisBuild / crossScalaVersions).value.head,
libraryDependencies ++= Seq(
"dev.zio" %% "zio-test" % "2.0.13" % Test
)
)
)
val install = taskKey[Unit]("Install the ZIO Clippy compiler plugin.")
def beforeScala2_13_12(scalaVersion: VersionNumber): Boolean =
scalaVersion.matchesSemVer(SemanticSelector("<2.13.12"))
def afterScala2_13_12(scalaVersion: VersionNumber): Boolean =
scalaVersion.matchesSemVer(SemanticSelector(">=2.13.12"))
lazy val root = (project in file(".")).settings(
name := "zio-clippy",
Compile / unmanagedSourceDirectories ++= {
val dir = (Compile / scalaSource).value
val Some((major, minor)) = CrossVersion.partialVersion(scalaVersion.value)
val versionNumber = VersionNumber(scalaVersion.value)
val specific = major match {
case 2 if minor <= 12 => file(s"${dir.getPath}-2.12") :: Nil
case 2 if minor == 13 && beforeScala2_13_12(versionNumber) => file(s"${dir.getPath}-2.13.x") :: Nil
case 2 if minor == 13 && afterScala2_13_12(versionNumber) => file(s"${dir.getPath}-2.13.12+") :: Nil
case _ => Nil
}
file(s"${dir.getPath}-$major") :: specific
},
libraryDependencies ++= {
if (scalaVersion.value.startsWith("3."))
Seq(
"org.scala-lang" % "scala3-compiler_3" % scalaVersion.value % "provided"
)
else
Seq(
"org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided",
"org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided"
)
},
crossTarget := target.value / s"scala-${scalaVersion.value}",
assembly / assemblyOption ~= {
_.withIncludeScala(false)
},
assembly / assemblyJarName := "zio-clippy.jar",
install := {
streams.value.log.info(s"Installing ${zioPluginJar.value}")
IO.write(zioPluginJar.value, IO.readBytes(assembly.value))
val plugin = file(s"""${sys.props("user.home")}/.sbt/1.0/plugins/ZIOPlugin.scala""")
streams.value.log.info(s"Installing $plugin")
IO.copyFile(file("project/ZIOPlugin.scala"), plugin)
},
sonatypeCredentialHost := "s01.oss.sonatype.org",
sonatypeRepository := "https://s01.oss.sonatype.org/service/local",
sonatypeProjectHosting := Some(GitHubHosting("hmemcpy", "zio-clippy", "Igal Tabachnik", "[email protected]"))
)