forked from typelevel/scalacheck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
149 lines (117 loc) · 4.65 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
sourceDirectory := file("dummy source directory")
val scalaMajorVersion = SettingKey[Int]("scalaMajorVersion")
scalaVersionSettings
lazy val versionNumber = "1.14.1"
lazy val isRelease = false
lazy val travisCommit = Option(System.getenv().get("TRAVIS_COMMIT"))
lazy val scalaVersionSettings = Seq(
scalaVersion := "2.12.6",
crossScalaVersions := Seq("2.10.7", "2.11.12", "2.13.0-RC1", scalaVersion.value),
scalaMajorVersion := {
val v = scalaVersion.value
CrossVersion.partialVersion(v).map(_._2.toInt).getOrElse {
throw new RuntimeException(s"could not get Scala major version from $v")
}
}
)
lazy val sharedSettings = MimaSettings.settings ++ scalaVersionSettings ++ Seq(
name := "scalacheck",
version := {
val suffix =
if (isRelease) ""
else travisCommit.map("-" + _.take(7)).getOrElse("") + "-SNAPSHOT"
versionNumber + suffix
},
isSnapshot := !isRelease,
organization := "org.scalacheck",
licenses := Seq("BSD-style" -> url("http://www.opensource.org/licenses/bsd-license.php")),
homepage := Some(url("http://www.scalacheck.org")),
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,
unmanagedSourceDirectories in Compile += (baseDirectory in LocalRootProject).value / "src" / "main" / "scala",
unmanagedSourceDirectories in Compile += {
val s = if (scalaMajorVersion.value >= 13) "+" else "-"
(baseDirectory in LocalRootProject).value / "src" / "main" / s"scala-2.13$s"
},
unmanagedSourceDirectories in Test += (baseDirectory in LocalRootProject).value / "src" / "test" / "scala",
resolvers += "sonatype" at "https://oss.sonatype.org/content/repositories/releases",
javacOptions += "-Xmx1024M",
scalacOptions ++= Seq(
"-deprecation",
"-encoding", "UTF-8",
"-feature",
"-unchecked",
"-Xfuture",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen") ++ {
val modern = Seq("-Xlint:-unused", "-Ywarn-unused:-patvars,-implicits,-locals,-privates,-explicits")
val removed = Seq("-Ywarn-inaccessible", "-Ywarn-nullary-override", "-Ywarn-nullary-unit")
val removedModern = Seq("-Ywarn-infer-any", "-Ywarn-unused-import")
scalaMajorVersion.value match {
case 10 => Seq("-Xfatal-warnings", "-Xlint") ++ removed
case 11 => Seq("-Xfatal-warnings", "-Xlint", "-Ywarn-infer-any", "-Ywarn-unused-import") ++ removed
case 12 => "-Xfatal-warnings" +: (modern ++ removed ++ removedModern)
case 13 => modern
}
},
// HACK: without these lines, the console is basically unusable,
// since all imports are reported as being unused (and then become
// fatal errors).
scalacOptions in (Compile, console) ~= {_.filterNot("-Ywarn-unused-import" == _)},
scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value,
// don't use fatal warnings in tests
scalacOptions in Test ~= (_ filterNot (_ == "-Xfatal-warnings")),
mimaPreviousArtifacts := Set("org.scalacheck" %% "scalacheck" % "1.14.0"),
publishTo := {
val nexus = "https://oss.sonatype.org/"
val (name, path) = if (isSnapshot.value) ("snapshots", "content/repositories/snapshots")
else ("releases", "service/local/staging/deploy/maven2")
Some(name at nexus + path)
},
publishMavenStyle := true,
// Travis should only publish snapshots
publishArtifact := !(isRelease && travisCommit.isDefined),
publishArtifact in Test := false,
pomIncludeRepository := { _ => false },
pomExtra := {
<scm>
<url>https://github.com/rickynils/scalacheck</url>
<connection>scm:git:[email protected]:rickynils/scalacheck.git</connection>
</scm>
<developers>
<developer>
<id>rickynils</id>
<name>Rickard Nilsson</name>
</developer>
</developers>
}
)
lazy val js = project.in(file("js"))
.settings(sharedSettings: _*)
.settings(
scalaJSStage in Global := FastOptStage,
libraryDependencies += "org.scala-js" %% "scalajs-test-interface" % scalaJSVersion
)
.enablePlugins(ScalaJSPlugin)
lazy val jvm = project.in(file("jvm"))
.settings(sharedSettings: _*)
.settings(
fork in Test := true,
libraryDependencies += "org.scala-sbt" % "test-interface" % "1.0"
)
lazy val native = project.in(file("native"))
.settings(sharedSettings: _*)
.settings(
doc in Compile := (doc in Compile in jvm).value,
scalaVersion := "2.11.12",
libraryDependencies ++= Seq(
"org.scala-native" %% "test-interface_native0.3" % nativeVersion
)
)
.enablePlugins(ScalaNativePlugin)