-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sbt
135 lines (128 loc) · 4.71 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
123
124
125
126
127
128
129
130
131
132
133
134
135
import sbt.Defaults.sbtPluginExtra
Global / onChangedBuildSource := ReloadOnSourceChanges
ThisBuild / turbo := true
ThisBuild / scalaVersion := "2.12.19" // scala-steward:off
lazy val sbtDecentScala = project
.in(file("."))
.settings(commonSettings)
.settings(
name := "sbt-decent-scala",
sbtPlugin := true,
addSbtPlugin(Dependencies.sbtBuildinfo),
addSbtPlugin(Dependencies.sbtDynver),
addSbtPlugin(Dependencies.sbtMissinglink),
addSbtPlugin(Dependencies.sbtRewarn),
addSbtPlugin(Dependencies.sbtScalafmt),
addSbtPlugin(Dependencies.sbtScalafix),
addSbtPlugin(Dependencies.sbtTpolecat),
addSbtPlugin(Dependencies.sbtVersionPolicy),
)
.enablePlugins(BuildInfoPlugin)
lazy val commonSettings: List[Def.Setting[_]] = List(
libraryDependencies ++= List(
compilerPlugin(Dependencies.betterMonadicFor),
compilerPlugin(Dependencies.kindProjector),
compilerPlugin(Dependencies.zerowaste),
Dependencies.missinglink,
),
semanticdbEnabled := true, // enable SemanticDB
semanticdbOptions += "-P:semanticdb:synthetics:on",
semanticdbVersion := scalafixSemanticdb.revision, // use Scalafix compatible version
ThisBuild / scalafixDependencies ++= List(
Dependencies.scaluzzi,
),
scalacOptions ++= List(
"-Ywarn-macros:after",
"-Xsource:3",
),
ThisBuild / dynverSonatypeSnapshots := {
!git.gitCurrentBranch.value.contains("master")
},
organization := "com.github.sideeffffect",
homepage := Some(url("https://github.com/sideeffffect/sbt-decent-scala")),
licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
developers := List(
Developer(
"sideeffffect",
"Ondřej Pelech",
url("https://github.com/sideeffffect"),
),
),
buildInfoKeys := List[BuildInfoKey](organization, moduleName, version),
buildInfoPackage := s"${organization.value}.${moduleName.value}".replace("-", "."),
Compile / packageBin / packageOptions += Package.ManifestAttributes(
"Automatic-Module-Name" -> s"${organization.value}.${moduleName.value}".replace("-", "."),
),
version ~= (_.replace('+', '-')),
missinglinkExcludedDependencies ++= List(
moduleFilter( // fails on Java 8: `Problem: Method not found: java.nio.LongBuffer.position(int)`
organization = "com.googlecode.javaewah",
name = "JavaEWAH",
),
moduleFilter(organization = "com.squareup.okhttp3", name = "okhttp"),
moduleFilter(organization = "com.timushev.sbt", name = "sbt-rewarn"),
moduleFilter(organization = "net.openhft", name = "zero-allocation-hashing"),
moduleFilter(organization = "org.apache.logging.log4j", name = "log4j-core"),
moduleFilter(organization = "org.apache.logging.log4j", name = "log4j-slf4j-impl"),
),
mimaBinaryIssueFilters ++= List(
),
ThisBuild / versionPolicyIntention := Compatibility.None,
ciReleaseCont,
)
lazy val ciReleaseCont = {
commands += Command.command("ci-release-cont") { currentState =>
if (!CiReleasePlugin.isSecure) {
println("No access to secret variables, doing nothing")
currentState
} else {
println(
s"Running ci-release-cont.\n" +
s" branch=${CiReleasePlugin.currentBranch}",
)
CiReleasePlugin.setupGpg()
// https://github.com/olafurpg/sbt-ci-release/issues/64
val reloadKeyFiles =
"; set pgpSecretRing := pgpSecretRing.value; set pgpPublicRing := pgpPublicRing.value"
if (!CiReleasePlugin.isTag && !git.gitCurrentBranch.value.contains("master")) {
if (CiReleasePlugin.isSnapshotVersion(currentState)) {
println(s"No tag push, publishing SNAPSHOT")
reloadKeyFiles ::
sys.env.getOrElse("CI_SNAPSHOT_RELEASE", "+publish") ::
currentState
} else {
// Happens when a tag is pushed right after merge causing the master branch
// job to pick up a non-SNAPSHOT version even if TRAVIS_TAG=false.
println(
"Snapshot releases must have -SNAPSHOT version number, doing nothing",
)
currentState
}
} else {
println("Tag push detected, publishing a stable release")
reloadKeyFiles ::
sys.env.getOrElse("CI_CLEAN", "; clean ; sonatypeBundleClean") ::
sys.env.getOrElse("CI_RELEASE", "+publishSigned") ::
sys.env.getOrElse("CI_SONATYPE_RELEASE", "sonatypeBundleRelease") ::
currentState
}
}
}
}
addCommandAlias(
"ci",
"; check; +publishLocal",
)
addCommandAlias(
"check",
"; lint; +missinglinkCheck; +versionPolicyCheck; +test",
)
addCommandAlias(
"lint",
"; scalafmtSbtCheck; scalafmtCheckAll; scalafixAll --check",
)
addCommandAlias(
"fix",
"; scalafixAll; scalafmtSbt; scalafmtAll",
)