-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sbt
165 lines (140 loc) · 6.11 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import _root_.io.isomarcte.sbt.version.scheme.enforcer.build.GAVs._
import _root_.io.isomarcte.sbt.version.scheme.enforcer.build.JREMajorVersion
import _root_.io.isomarcte.sbt.version.scheme.enforcer.build._
import java.net.URL
// Constants //
lazy val isomarcteOrg: String = "io.isomarcte"
lazy val jreVersionForDocs: String = JREMajorVersion.majorVersion
lazy val projectName: String = "sbt-version-scheme-enforcer"
lazy val projectUrl: URL = url("https://github.com/isomarcte/sbt-version-scheme-enforcer")
lazy val scala212: String = "2.12.18"
lazy val scalaVersions: Set[String] = Set(scala212)
// SBT Command Aliases //
// Usually run before making a PR
addCommandAlias(
"full_build",
";+clean;githubWorkflowGenerate;+test;+test:doc;+versionSchemeEnforcerCheck;+scalafmtAll;+scalafmtSbt;+scalafixAll;+scripted;"
)
// ThisBuild //
// General
ThisBuild / versionScheme := Some("pvp")
ThisBuild / scalacOptions ++= List("-target:jvm-1.8")
ThisBuild / organization := isomarcteOrg
ThisBuild / scalafixScalaBinaryVersion := scalaBinaryVersion.value
ThisBuild / semanticdbEnabled := true
ThisBuild / semanticdbVersion := scalafixSemanticdb.revision
// We only publish on 2.12.x to keep in line with SBT, but it is assumed that
// SBT will get to 2.13.x someday, so this ensures we stay up to date.
ThisBuild / crossScalaVersions := scalaVersions.toSeq
// MUnit
ThisBuild / testFrameworks += new TestFramework("munit.Framework")
// GithubWorkflow
ThisBuild / githubWorkflowPublishTargetBranches := Nil
ThisBuild / githubWorkflowOSes := Set("ubuntu-latest", "macos-latest").toList
ThisBuild / githubWorkflowJavaVersions :=
Set(JavaSpec.temurin("11"), JavaSpec.temurin("16"), JavaSpec.temurin("8"), JavaSpec.temurin("21")).toSeq
ThisBuild / githubWorkflowBuildPreamble :=
List(
WorkflowStep.Sbt(List("scalafmtSbtCheck", "scalafmtCheckAll", "versionSchemeEnforcerCheck")),
WorkflowStep.Run(List("sbt 'scalafixAll --check'")),
WorkflowStep.Sbt(List("publishLocal")),
WorkflowStep.Run(List("sbt scripted", "./run-vcs-tests.sh")),
WorkflowStep.Sbt(List("doc"))
)
ThisBuild / githubWorkflowBuildPostamble := List(WorkflowStep.Sbt(List("test:doc")))
// Doc Settings //
lazy val docSettings: List[Def.Setting[_]] = List(
apiURL := {
val moduleName: String = name.value
val org: String = organization.value
Some(url(s"https://www.javadoc.io/doc/${org}/${moduleName}_${scalaBinaryVersion.value}/latest/index.html"))
},
autoAPIMappings := true,
Compile / doc / apiMappings ++= {
ScalaDocLinks.mappings(Seq((Compile / dependencyClasspathAsJars).value), scalaBinaryVersion.value) ++
ScalaDocLinks.jreModuleLinks(jreVersionForDocs)
},
Compile / doc / scalacOptions ++= List("-no-link-warnings") // JDK module linking is broken on 2.12.12
)
// Common Settings //
lazy val commonSettings: List[Def.Setting[_]] = List(
scalaVersion := scala212,
addCompilerPlugin(betterMonadicForG %% betterMonadicForA % betterMonadicForV),
addCompilerPlugin(typelevelG % kindProjectorA % kindProjectorV cross CrossVersion.full)
)
// Publish Settings //
lazy val publishSettings = List(
homepage := Some(projectUrl),
licenses := Seq("BSD3" -> url("https://opensource.org/licenses/BSD-3-Clause")),
publishMavenStyle := true,
Test / publishArtifact := false,
pomIncludeRepository := { _ =>
false
},
publishTo := {
val nexus: String = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
scmInfo := Some(ScmInfo(projectUrl, s"scm:git:[email protected]:isomarcte/${projectName}.git")),
developers :=
List(Developer("isomarcte", "David Strawn", "[email protected]", url("https://github.com/isomarcte"))),
credentials += Credentials(Path.userHome / ".sbt" / ".credentials")
)
// Root //
lazy val root: Project = (project in file("."))
.settings(commonSettings, publishSettings)
.settings(
List(
name := projectName,
Compile / packageBin / publishArtifact := false,
Compile / packageSrc / publishArtifact := false
)
)
.settings(inThisBuild(commonSettings))
.aggregate(core, plugin)
.disablePlugins(SbtVersionSchemeEnforcerPlugin)
// Core //
lazy val core: Project = project
.settings(commonSettings, publishSettings)
.settings(
name := s"${projectName}-core",
libraryDependencies ++= List(coursierG %% coursierVersionsA % coursierVersionsV) ++
List(
scalacheckG %% scalacheckA % scalacheckV,
scalametaG %% munitA % munitV,
typelevelG %% catsKernelA % catsV,
typelevelG %% catsLawsA % catsV,
typelevelG %% disciplineMunitA % disciplineMunitV
).map(_ % Test),
docSettings
)
// Plugin //
lazy val plugin: Project = project
.settings(commonSettings, publishSettings)
.settings(
name := s"${projectName}-plugin",
addSbtPlugin(typesafeG % sbtMimaPluginA % sbtMimaPluginV),
libraryDependencies ++=
List(
coursierG %% coursierVersionsA % coursierVersionsV,
scalaSbtG % sbtA % sbtVersion.value % Provided,
scalaSbtG %% sbtCollectionsA % sbtVersion.value % Provided,
scalaSbtG %% sbtCoreMacrosA % sbtVersion.value % Provided,
scalaSbtG %% sbtLibraryManagementCoreA % sbtLibraryManagementCoreV % Provided,
scalaSbtG %% sbtMainA % sbtVersion.value % Provided,
scalaSbtG %% sbtMainSettingsA % sbtVersion.value % Provided,
scalaSbtG %% sbtTaskSystemA % sbtVersion.value % Provided,
scalaSbtG %% sbtUtilPositionA % sbtVersion.value % Provided,
scalametaG %% munitA % munitV % Test
),
scriptedLaunchOpts := {
scriptedLaunchOpts.value ++ Seq("-Dplugin.version=" + version.value)
},
scriptedBufferLog := false
)
.enablePlugins(SbtPlugin)
.disablePlugins(SbtVersionSchemeEnforcerPlugin)
.dependsOn(core)