-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathbuild.sbt
140 lines (128 loc) · 4.23 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
import ReleaseTransformations._
import sbtcrossproject.CrossPlugin.autoImport.crossProject
organization in ThisBuild := "io.estatico"
lazy val root = project.in(file("."))
.aggregate(newtypeJS, newtypeJVM, catsTestsJVM)
.settings(noPublishSettings)
lazy val newtype = crossProject(JSPlatform, JVMPlatform).in(file("."))
.settings(defaultSettings)
.settings(releasePublishSettings)
.settings(name := "newtype")
lazy val newtypeJVM = newtype.jvm
lazy val newtypeJS = newtype.js
lazy val catsTests = crossProject(JVMPlatform).in(file("cats-tests"))
.dependsOn(newtype)
.settings(defaultSettings)
.settings(noPublishSettings)
.settings(
name := "newtype-cats-tests",
description := "Test suite for newtype + cats interop",
libraryDependencies +=
(CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v >= 12 =>
"org.typelevel" %%% "cats-core" % "2.1.1"
case _ =>
"org.typelevel" %%% "cats-core" % "2.0.0"
})
)
lazy val catsTestsJVM = catsTests.jvm
lazy val noPublishSettings = Seq(
publish := {},
publishLocal := {},
publishArtifact := false
)
lazy val releasePublishSettings = Seq(
releaseCrossBuild := true,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
publishArtifacts,
setNextVersion,
commitNextVersion,
ReleaseStep(action = Command.process("sonatypeReleaseAll", _)),
pushChanges
),
homepage := Some(url("https://github.com/estatico/scala-newtype")),
licenses := Seq("Apache 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
publishMavenStyle := true,
publishArtifact in Test := false,
pomIncludeRepository := { _ => false },
publishTo in ThisBuild := {
val nexus = "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(
url("https://github.com/estatico/scala-newtype"),
"scm:git:[email protected]:estatico/scala-newtype.git"
)
),
developers := List(
Developer("caryrobbins", "Cary Robbins", "[email protected]", url("http://caryrobbins.com"))
),
credentials ++= (
for {
username <- Option(System.getenv().get("SONATYPE_USERNAME"))
password <- Option(System.getenv().get("SONATYPE_PASSWORD"))
} yield Credentials(
"Sonatype Nexus Repository Manager",
"oss.sonatype.org",
username,
password
)
).toSeq
)
lazy val defaultSettings = Seq(
defaultScalacOptions,
scalacOptions ++= PartialFunction.condOpt(CrossVersion.partialVersion(scalaVersion.value)) {
case Some((2, n)) if n >= 13 =>
Seq(
"-Ymacro-annotations"
)
}.toList.flatten,
defaultLibraryDependencies,
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v <= 12 =>
Seq(
compilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full)
)
case _ =>
// if scala 2.13.0-M4 or later, macro annotations merged into scala-reflect
// https://github.com/scala/scala/pull/6606
Nil
}
}
)
lazy val defaultScalacOptions = scalacOptions ++= Seq(
"-Xfatal-warnings",
"-Yno-predef", // needed to ensure users can use -Yno-predef
"-unchecked",
"-feature",
"-deprecation",
"-language:higherKinds",
"-language:implicitConversions",
"-language:experimental.macros"
) ++ (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) =>
Seq("-Xlint")
case _ =>
// on scala 2.12+ some spurious unused warnings get triggered
Seq("-Xlint:-unused,_")
})
lazy val defaultLibraryDependencies = libraryDependencies ++= Seq(
scalaOrganization.value % "scala-reflect" % scalaVersion.value % Provided,
scalaOrganization.value % "scala-compiler" % scalaVersion.value % Provided,
"org.scalacheck" %%% "scalacheck" % "1.14.3" % Test,
"org.scalatest" %%% "scalatest" % "3.1.1" % Test,
"org.scalatestplus" %%% "scalacheck-1-14" % "3.1.1.1" % Test,
)