-
Notifications
You must be signed in to change notification settings - Fork 33
/
build.sbt
106 lines (95 loc) · 3.75 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
100
101
102
103
104
105
106
name := "silencer"
val saveTestClasspath = taskKey[File](
"Saves test classpath to a file so that it can be used by embedded scalac in tests")
def crossSources = Def.settings(
unmanagedSourceDirectories ++= unmanagedSourceDirectories.value.flatMap { dir =>
val path = dir.getPath
val sv = scalaVersion.value
val suffixes = CrossVersion.partialVersion(sv) match {
case Some((2, 11)) => Seq("2.11", "2.11-12")
case Some((2, 12)) => Seq("2.11-12", "2.12", "2.12-13")
case Some((2, 13)) => Seq("2.12-13", "2.13")
case _ => throw new IllegalArgumentException("unsupported scala version")
}
suffixes.map(s => file(s"$path-$s"))
}
)
inThisBuild(Seq(
organization := "com.github.ghik",
scalaVersion := crossScalaVersions.value.head,
crossScalaVersions := Seq(
"2.13.15", "2.13.14", "2.13.13", "2.13.12", "2.13.11", "2.13.10", "2.13.9", "2.13.8", "2.13.7", "2.13.6", "2.13.5", "2.13.4", "2.13.3", "2.13.2",
"2.12.20", "2.12.19", "2.12.18", "2.12.17", "2.12.16", "2.12.15", "2.12.14", "2.12.13", "2.11.12"
),
githubWorkflowTargetTags ++= Seq("v*"),
githubWorkflowJavaVersions := Seq(JavaSpec.temurin("17")),
githubWorkflowPublishTargetBranches := Seq(RefPredicate.StartsWith(Ref.Tag("v"))),
githubWorkflowPublish := Seq(WorkflowStep.Sbt(
List("ci-release"),
env = Map(
"PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}",
"PGP_SECRET" -> "${{ secrets.PGP_SECRET }}",
"SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}",
"SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}"
)
)),
))
val commonSettings = Def.settings(
projectInfo := ModuleInfo(
nameFormal = "Silencer",
description = "Scala compiler plugin for annotation-based warning suppression",
homepage = Some(url("https://github.com/ghik/silencer")),
startYear = Some(2015),
licenses = Vector(
"The Apache License, Version 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")
),
organizationName = "ghik",
organizationHomepage = Some(url("https://github.com/ghik")),
scmInfo = Some(ScmInfo(
browseUrl = url("https://github.com/ghik/silencer.git"),
connection = "scm:git:[email protected]:ghik/silencer.git",
devConnection = Some("scm:git:[email protected]:ghik/silencer.git")
)),
developers = Vector(
Developer("ghik", "Roman Janusz", "[email protected]", url("https://github.com/ghik"))
),
),
crossVersion := CrossVersion.full,
inConfig(Compile)(crossSources),
inConfig(Test)(crossSources),
)
val subprojectSettings = Def.settings(
commonSettings,
publishMavenStyle := true,
pomIncludeRepository := { _ => false },
publishTo := sonatypePublishToBundle.value,
)
lazy val silencer = (project in file(".")).aggregate(`silencer-lib`, `silencer-plugin`)
.settings(commonSettings*)
.settings(
publishArtifact := false,
PgpKeys.publishSigned := {}
)
lazy val `silencer-lib` = project
.settings(subprojectSettings*)
.settings(
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value % Test,
"org.scala-lang.modules" %% "scala-collection-compat" % "2.4.1" % Test
)
)
lazy val `silencer-plugin` = project.dependsOn(`silencer-lib`)
.settings(subprojectSettings*)
.settings(
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-compiler" % scalaVersion.value,
"org.scalatest" %% "scalatest-funsuite" % "3.2.0" % Test
),
Test / resourceGenerators += Def.task {
val result = (Test / resourceManaged).value / "embeddedcp"
IO.write(result, (`silencer-lib` / Test / fullClasspath).value.map(_.data.getAbsolutePath).mkString("\n"))
Seq(result)
}.taskValue,
Test / fork := true,
Test / baseDirectory := (ThisBuild / baseDirectory).value,
)