forked from pathikrit/better-files
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
129 lines (120 loc) · 4.88 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
val username = "pathikrit"
val repo = "better-files"
lazy val commonSettings = Seq(
organization := s"com.github.$username",
scalaVersion := crossScalaVersions.value.find(_.startsWith("2.12")).get,
crossScalaVersions := Seq("2.11.12", "2.12.8", "2.13.0-M5"),
crossVersion := CrossVersion.binary,
scalacOptions := myScalacOptions(scalaVersion.value, scalacOptions.value),
scalacOptions in (Compile, doc) += "-groups",
libraryDependencies += Dependencies.scalatest,
updateImpactOpenBrowser := false,
compile in Compile := (compile in Compile).dependsOn(formatAll).value,
test in Test := (test in Test).dependsOn(checkFormat).value,
formatAll := {
(scalafmt in Compile).value
(scalafmt in Test).value
(scalafmtSbt in Compile).value
},
checkFormat := {
(scalafmtCheck in Compile).value
(scalafmtCheck in Test).value
(scalafmtSbtCheck in Compile).value
}
)
/** We use https://github.com/DavidGregory084/sbt-tpolecat but some of these are broken */
def myScalacOptions(scalaVersion: String, suggestedOptions: Seq[String]): Seq[String] =
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, 10)) => suggestedOptions diff Seq("-Ywarn-numeric-widen") // buggy in 2.10
case Some((2, 11)) => suggestedOptions diff Seq("-Ywarn-value-discard") // This is broken in 2.11 for Unit types
case Some((2, 13)) => Nil // Ignore warnings for 2.13 for now
case _ => Nil
}
lazy val core = (project in file("core"))
.settings(commonSettings: _*)
.settings(publishSettings: _*)
.settings(
name := repo,
description := "Simple, safe and intuitive I/O in Scala",
libraryDependencies ++= Seq(
Dependencies.scalaReflect(scalaVersion.value),
Dependencies.commonsio,
Dependencies.fastjavaio,
Dependencies.shapeless
)
)
lazy val akka = (project in file("akka"))
.settings(commonSettings: _*)
.settings(publishSettings: _*)
.settings(
name := s"$repo-akka",
description := "Reactive file watcher using Akka actors",
libraryDependencies += Dependencies.akka
)
.dependsOn(core % "test->test;compile->compile")
lazy val root = (project in file("."))
.settings(name := s"$repo-root")
.settings(commonSettings: _*)
.settings(docSettings: _*)
.settings(skip in publish := true)
.settings(releaseSettings: _*)
.enablePlugins(ScalaUnidocPlugin)
.enablePlugins(GhpagesPlugin)
.aggregate(core)
//.aggregate(core, akka) //TODO: Don't build akka module until it supports 2.13
lazy val docSettings = Seq(
autoAPIMappings := true,
unidocProjectFilter in (ScalaUnidoc, unidoc) := inProjects(core, akka),
siteSourceDirectory := baseDirectory.value / "site",
siteSubdirName in ScalaUnidoc := "latest/api",
addMappingsToSiteDir(mappings in (ScalaUnidoc, packageDoc), siteSubdirName in ScalaUnidoc),
git.remoteRepo := s"[email protected]:$username/$repo.git",
envVars in ghpagesPushSite += ("SBT_GHPAGES_COMMIT_MESSAGE" -> s"Publishing Scaladoc [CI SKIP]")
)
lazy val formatAll = taskKey[Unit]("Format all the source code which includes src, test, and build files")
lazy val checkFormat = taskKey[Unit]("Check all the source code which includes src, test, and build files")
import ReleaseTransformations._
lazy val releaseSettings = Seq(
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
//runClean,
runTest,
setReleaseVersion,
//commitReleaseVersion,
tagRelease,
releaseStepCommand("publishSigned"),
setNextVersion,
//commitNextVersion,
releaseStepCommand("sonatypeReleaseAll"),
//pushChanges
)
)
lazy val publishSettings = Seq(
homepage := Some(url(s"https://github.com/$username/$repo")),
licenses += "MIT" -> url(s"https://github.com/$username/$repo/blob/master/LICENSE"),
scmInfo := Some(ScmInfo(url(s"https://github.com/$username/$repo"), s"[email protected]:$username/$repo.git")),
apiURL := Some(url(s"https://$username.github.io/$repo/latest/api/")),
releaseCrossBuild := true,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
developers := List(
Developer(
id = username,
name = "Pathikrit Bhowmick",
email = "[email protected]",
url = new URL(s"http://github.com/${username}")
)
),
useGpg := true,
usePgpKeyHex("66AA02EC8AA60DB9"),
publishMavenStyle := true,
publishArtifact in Test := false,
publishTo := Some(if (isSnapshot.value) Opts.resolver.sonatypeSnapshots else Opts.resolver.sonatypeStaging),
credentials ++= (for {
username <- sys.env.get("SONATYPE_USERNAME")
password <- sys.env.get("SONATYPE_PASSWORD")
} yield Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", username, password)).toSeq,
// Following 2 lines need to get around https://github.com/sbt/sbt/issues/4275
publishConfiguration := publishConfiguration.value.withOverwrite(true),
publishLocalConfiguration := publishLocalConfiguration.value.withOverwrite(true)
)