-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
194 lines (178 loc) · 5.97 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
import de.heikoseeberger.sbtheader.HeaderPattern
val ScalaTestVersion = "3.0.1"
val ScalaJava8CompatVersion = "0.7.0"
val BetterFiles = "2.14.0"
val scalaTest = "org.scalatest" %% "scalatest" % ScalaTestVersion
val scalaJava8Compat = "org.scala-lang.modules" %% "scala-java8-compat" % ScalaJava8CompatVersion
def common: Seq[Setting[_]] = releaseSettings ++ bintraySettings ++ Seq(
organization := "com.dispalt.pop",
// Must be "Apache-2.0", because bintray requires that it is a license that it knows about
licenses := Seq(("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0.html"))),
homepage := Some(url("http://www.github.com/sbt-pop")),
sonatypeProfileName := "com.dispalt",
headers := headers.value ++ Map(
"scala" -> (
HeaderPattern.cStyleBlockComment,
"""|/*
| * Copyright (C) 2017 Dan Di Spaltro
| */
|""".stripMargin
),
"java" -> (
HeaderPattern.cStyleBlockComment,
"""|/*
| * Copyright (C) 2017 Dan Di Spaltro
| */
|""".stripMargin
)
),
pomExtra := {
<scm>
<url>https://github.com/dispalt/sbt-pop</url>
<connection>scm:git:[email protected]:dispalt/sbt-pop.git</connection>
</scm>
<developers>
<developer>
<id>dispalt</id>
<name>Dan Di Spaltro</name>
<url>https://github.com/dispalt</url>
</developer>
</developers>
},
pomIncludeRepository := { _ =>
false
},
concurrentRestrictions in Global += Tags.limit(Tags.Test, 1),
// Setting javac options in common allows IntelliJ IDEA to import them automatically
javacOptions in compile ++= Seq(
"-encoding",
"UTF-8",
"-source",
"1.8",
"-target",
"1.8",
"-parameters",
"-Xlint:unchecked",
"-Xlint:deprecation"
)
)
def bintraySettings: Seq[Setting[_]] = Seq(
bintrayOrganization := Some("dispalt"),
bintrayRepository := "sbt-plugins",
bintrayPackage := "sbt-pop",
bintrayReleaseOnPublish := false
)
def releaseSettings: Seq[Setting[_]] = Seq(
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
releaseTagName := (version in ThisBuild).value,
releaseProcess := {
import ReleaseTransformations._
Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
publishArtifacts,
releaseStepTask(bintrayRelease in thisProjectRef.value),
releaseStepCommand("sonatypeRelease"),
setNextVersion,
commitNextVersion,
pushChanges
)
}
)
def runtimeLibCommon: Seq[Setting[_]] = common ++ Seq(
crossScalaVersions := Seq("2.11.8"),
scalaVersion := crossScalaVersions.value.head,
crossVersion := CrossVersion.binary,
crossPaths := false,
// dependencyOverrides += "com.typesafe.akka" %% "akka-actor" % AkkaVersion,
// dependencyOverrides += "com.typesafe.akka" %% "akka-slf4j" % AkkaVersion,
// compile options
scalacOptions in Compile ++= Seq("-encoding",
"UTF-8",
"-target:jvm-1.8",
"-feature",
"-unchecked",
"-Xlog-reflective-calls",
"-Xlint",
"-deprecation"),
incOptions := incOptions.value.withNameHashing(true),
// show full stack traces and test case durations
testOptions in Test += Tests.Argument("-oDF")
)
// Publisher switching
def RuntimeLibPlugins = AutomateHeaderPlugin && Sonatype && PluginsAccessor.exclude(BintrayPlugin)
def SbtPluginPlugins = AutomateHeaderPlugin && BintrayPlugin && PluginsAccessor.exclude(Sonatype)
val otherProjects = Seq[Project](
`build-link`,
`reloadable-server`,
`sbt-plugin`
)
lazy val root = (project in file("."))
.settings(name := "pop")
.settings(
PgpKeys.publishSigned := {},
publishLocal := {},
publishArtifact in Compile := false,
publish := {}
)
.aggregate(otherProjects.map(Project.projectToRef): _*)
//def SbtPlugins = PluginsAccessor.exclude(Build)
//
lazy val `build-link` = (project in file("build-link"))
.enablePlugins(RuntimeLibPlugins)
.settings(common: _*)
.settings(
crossPaths := false,
autoScalaLibrary := false
)
lazy val `reloadable-server` = (project in file("reloadable-server"))
.settings(name := "pop-reloadable-server")
.settings(runtimeLibCommon: _*)
.enablePlugins(RuntimeLibPlugins)
.dependsOn(`build-link`)
lazy val `sbt-plugin` = (project in file("sbt-plugin"))
.settings(name := "sbt-pop")
.settings(common: _*)
.settings(scriptedSettings: _*)
.enablePlugins(SbtPluginPlugins)
.settings(
sbtPlugin := true,
libraryDependencies ++= Seq(
scalaTest % Test,
"com.github.pathikrit" %% "better-files" % "2.14.0"
),
sourceGenerators in Compile += Def.task {
Generators.version(version.value, (sourceManaged in Compile).value)
}.taskValue,
scriptedDependencies := {
val () = scriptedDependencies.value
val () = publishLocal.value
val () = (publishLocal in `build-link`).value
val () = (publishLocal in `reloadable-server`).value
},
publishTo := {
if (isSnapshot.value) {
// Bintray doesn't support publishing snapshots, publish to Sonatype snapshots instead
Some(Opts.resolver.sonatypeSnapshots)
} else publishTo.value
},
publishMavenStyle := isSnapshot.value
)
.dependsOn(`build-link`)
def scriptedSettings: Seq[Setting[_]] =
ScriptedPlugin.scriptedSettings ++
Seq(scriptedLaunchOpts += s"-Dproject.version=${version.value}") ++
Seq(
scripted := scripted.tag(Tags.Test).evaluated,
scriptedBufferLog := false,
scriptedLaunchOpts ++= Seq(
"-Xmx768m",
"-XX:MaxMetaspaceSize=384m",
"-Dscala.version=" + sys.props
.get("scripted.scala.version")
.getOrElse((scalaVersion in `reloadable-server`).value)
)
)