-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathbuild.sbt
122 lines (115 loc) · 4.55 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
val buildName = "jardiff"
val scala212Version = "2.12.20"
val scala213Version = "2.13.16"
inThisBuild(Seq[Setting[_]](
organization := "com.lightbend",
scalaVersion := "2.13.16",
startYear := Some(2017),
organizationName := "Lightbend Inc. <https://www.lightbend.com>",
licenses := List(("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0.txt"))),
homepage := Some(url("https://github.com/lightbend-labs/jardiff")),
scmInfo := Some(ScmInfo(url("https://github.com/lightbend-labs/jardiff"), "scm:git:[email protected]:lightbend-labs/jardiff.git")),
developers := List(
Developer("retronym", "Jason Zaugg", "@retronym", url("https://github.com/retronym")),
),
scalacOptions := Seq("-feature", "-deprecation", "-Xlint", "-Werror"),
githubWorkflowOSes := Seq("ubuntu-latest", "macos-latest"),
githubWorkflowJavaVersions := Seq(
JavaSpec.zulu("8"), // macos-latest lacks Temurin 8
JavaSpec.temurin("11"),
JavaSpec.temurin("17"),
JavaSpec.temurin("21"),
JavaSpec.temurin("22"),
),
githubWorkflowTargetTags ++= Seq ("v*"),
githubWorkflowPublishTargetBranches := Seq(
RefPredicate.StartsWith(Ref.Tag("v")),
RefPredicate.Equals(Ref.Branch("main"))
),
githubWorkflowPublish := Seq (
WorkflowStep.Sbt(
commands = List("ci-release"),
name = Some("Publish project"),
env = Map(
"PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}",
"PGP_SECRET" -> "${{ secrets.PGP_SECRET }}",
"SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}",
"SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}"
)
)
),
headerLicense := Some(HeaderLicense.Custom("Copyright (C) Lightbend Inc. <https://www.lightbend.com>")),
))
ThisBuild / pomIncludeRepository := (_ => false)
lazy val root = (
project.in(file("."))
aggregate(core, cli)
settings(
name := buildName,
publish / skip := true,
// See https://github.com/sbt/sbt/issues/4262#issuecomment-405607763
crossScalaVersions := Seq.empty
)
)
val AsmVersion = "9.7.1"
lazy val core = project.
settings(
libraryDependencies ++= Seq(
"org.ow2.asm" % "asm" % AsmVersion,
"org.ow2.asm" % "asm-util" % AsmVersion,
"org.scala-lang" % "scalap" % System.getProperty("scalap.version", scalaVersion.value),
"org.eclipse.jgit" % "org.eclipse.jgit" % "5.13.2.202306221912-r",
"org.slf4j" % "slf4j-api" % "2.0.16",
"org.slf4j" % "log4j-over-slf4j" % "2.0.16", // for any java classes looking for this
"ch.qos.logback" % "logback-classic" % "1.3.11",
"org.scalatest" %% "scalatest" % "3.2.19" % Test,
),
name := buildName + "-core",
crossScalaVersions := Seq(scala212Version, scala213Version),
scalaVersion := scala212Version,
scalacOptions ++= {
// We publish the core library into maven which is done in CI via ci-release
// so we should only enable the optimizer in CI
if (insideCI.value) {
val log = sLog.value
log.info("Running in CI, enabling Scala2 optimizer <sources> mode for core")
Seq(
"-opt-inline-from:<sources>",
"-opt:l:inline"
)
} else Nil
}
)
lazy val cli = project.
settings(
libraryDependencies ++= Seq(
"commons-cli" % "commons-cli" % "1.9.0",
),
name := buildName + "-cli",
assembly / assemblyMergeStrategy := {
case "rootdoc.txt" => MergeStrategy.discard
case x if x.endsWith("module-info.class") => MergeStrategy.discard
case x => (assembly / assemblyMergeStrategy).value(x)
},
// Having Scala 2.13 here in crossScalaVersions is redundant but due to how
// sbt-github-actions generates the sbt test command (i.e. sbt '++ 2.13.12' test),
// sbt's update task cannot handle projects with different crossScalaVersions well
crossScalaVersions := Seq(scala212Version, scala213Version),
scalaVersion := scala212Version,
// cli is not meant to be published
publish / skip := true,
// We are creating a fatjar here for distribution so we can do global optimization
// using scala.** while omitting the JDK stdlib since we don't know what JDK version
// the user will run on. If we implement a way to make the cli release in CI then we
// can also use insideCI
scalacOptions ++= Seq(
"-opt-inline-from:scala.**",
"-opt:l:inline"
),
assembly := {
// The Scala 2 optimizer can cause issues if the codebase is not compiled in a clean
// state so lets make sure that we force clean before assembling the cli jar
val _ = clean.value
assembly.value
}
).dependsOn(core)