forked from fthomas/singleton-ops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
154 lines (139 loc) · 4.29 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
import scala.sys.process._
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}
/// variables
val groupId = "eu.timepit"
val projectName = "singleton-ops"
val rootPkg = "singleton"
val gitPubUrl = s"https://github.com/fthomas/$projectName.git"
val gitDevUrl = s"[email protected]:fthomas/$projectName.git"
val macroParadiseVersion = "2.1.1"
val shapelessVersion = "2.3.3"
val scalaCheckVersion = "1.14.3"
/// projects
lazy val root = project.in(file("."))
.settings(commonSettings)
.aggregate(singleton_opsJVM, singleton_opsJS)
.settings(
skip in publish := true,
sources in Compile := Seq.empty,
sources in Test := Seq.empty
)
lazy val singleton_ops = crossProject(JVMPlatform, JSPlatform)
.crossType(CrossType.Pure)
.in(file("."))
.settings(commonSettings)
.jsSettings(
coverageEnabled := false
)
lazy val singleton_opsJVM = singleton_ops.jvm
lazy val singleton_opsJS = singleton_ops.js
/// settings
lazy val commonSettings = Def.settings(
metadataSettings,
compileSettings,
scaladocSettings,
miscSettings,
crossVersionSharedSources
)
lazy val metadataSettings = Def.settings(
name := projectName,
organization := groupId,
homepage := Some(url(s"https://github.com/fthomas/$projectName")),
startYear := Some(2016),
licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0")),
scmInfo := Some(ScmInfo(homepage.value.get, s"scm:git:$gitPubUrl", Some(s"scm:git:$gitDevUrl"))),
developers := List(
Developer("fthomas", "Frank S. Thomas", "", url("https://github.com/fthomas")),
Developer("soronpo", "Oron Port", "", url("https://github.com/soronpo"))
)
)
lazy val crossVersionSharedSources: Seq[Setting[_]] =
Seq(Compile, Test).map { sc =>
(unmanagedSourceDirectories in sc) ++= {
(unmanagedSourceDirectories in sc ).value.flatMap { dir: File =>
if(dir.getName != "scala") Seq(dir)
else
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, y)) if y >= 13 => Seq(new File(dir.getPath + "_2.13+"))
case Some((2, y)) if y >= 11 => Seq(new File(dir.getPath + "_2.13-"))
}
}
}
}
lazy val compileSettings = Def.settings(
scalaOrganization := "org.scala-lang",
scalacOptions ++= Seq(
"-deprecation",
"-encoding",
"UTF-8",
"-feature",
"-language:existentials",
"-language:experimental.macros",
"-language:higherKinds",
"-language:implicitConversions",
"-unchecked",
"-Xfatal-warnings",
// "-Xlint:-unused,_",
// "-Yliteral-types",
"-Ywarn-numeric-widen"
// "-Ywarn-value-discard"
),
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v >= 13 =>
Nil
case _ =>
Seq(
"-Yno-adapted-args",
"-Ywarn-unused-import",
"-Xplugin-require:macroparadise"
)
}
},
scalacOptions in (Compile, console) -= "-Ywarn-unused-import",
scalacOptions in (Test, console) -= "-Ywarn-unused-import",
libraryDependencies ++= Seq(
scalaOrganization.value % "scala-compiler" % scalaVersion.value,
"com.chuusai" %%% "shapeless" % shapelessVersion,
"org.scalacheck" %%% "scalacheck" % scalaCheckVersion % Test
),
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
// if scala 2.13+ is used, macro annotations are merged into scala-reflect
// https://github.com/scala/scala/pull/6606
case Some((2, v)) if v >= 13 =>
Seq()
case _ =>
Seq(
compilerPlugin("org.scalamacros" % "paradise" % macroParadiseVersion cross CrossVersion.patch)
)
}
}
)
lazy val scaladocSettings = Def.settings(
scalacOptions in (Compile, doc) ++= Seq(
"-doc-source-url",
scmInfo.value.get.browseUrl + "/tree/master€{FILE_PATH}.scala",
"-sourcepath",
baseDirectory.in(LocalRootProject).value.getAbsolutePath
),
autoAPIMappings := true
)
lazy val miscSettings = Def.settings(
initialCommands += s"""
import $rootPkg.ops._
import $rootPkg.twoface._
"""
)
/// commands
val validateCommands = Seq(
"clean",
"test:compile",
"singleton_opsJS/test",
"coverage",
"singleton_opsJVM/test",
"coverageReport",
"coverageOff",
"doc"
)
addCommandAlias("validate", validateCommands.mkString(";", ";", ""))