-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.sbt
270 lines (248 loc) · 11 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
/* Copyright 2017-18, Emmanouil Antonios Platanios. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
import ReleaseTransformations._
import sbtrelease.Vcs
import scala.sys.process.Process
scalaVersion in ThisBuild := "2.12.11"
crossScalaVersions in ThisBuild := Seq("2.12.11")
organization in ThisBuild := "org.platanios"
// In order to update the snapshots more frequently, the Coursier "Time-To-Live" (TTL) option can be modified. This can
// be done by modifying the "COURSIER_TTL" environment variable. Its value is parsed using
// 'scala.concurrent.duration.Duration', so that things like "24 hours", "5 min", "10s", or "0s", are fine, and it also
// accepts infinity ("Inf") as a duration. It defaults to 24 hours, meaning that the snapshot artifacts are updated
// every 24 hours.
resolvers in ThisBuild += Resolver.sonatypeRepo("snapshots")
val tensorFlowScalaVersion = "0.5.0-SNAPSHOT"
fork in ThisBuild := true
autoCompilerPlugins in ThisBuild := true
scalacOptions in ThisBuild ++= Seq(
"-deprecation",
"-encoding", "UTF-8",
"-feature",
"-language:existentials",
"-language:higherKinds",
"-language:implicitConversions",
"-unchecked",
"-Yno-adapted-args",
"-Xfuture")
val scalacProfilingEnabled: SettingKey[Boolean] =
settingKey[Boolean]("Flag specifying whether to enable profiling for the Scala compiler.")
scalacProfilingEnabled in ThisBuild := false
lazy val loggingSettings = Seq(
libraryDependencies ++= Seq(
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.0",
"ch.qos.logback" % "logback-classic" % "1.2.3"))
lazy val commonSettings = loggingSettings ++ Seq(
// Plugin that prints better implicit resolution errors.
// addCompilerPlugin("io.tryp" % "splain" % "0.3.3" cross CrossVersion.patch)
)
lazy val testSettings = Seq(
libraryDependencies ++= Seq(
"junit" % "junit" % "4.12",
"org.scalatest" %% "scalatest" % "3.1.1" % "test"),
logBuffered in Test := false,
testForkedParallel in Test := false,
parallelExecution in Test := false,
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oDF"))
lazy val tensorFlowSettings = Seq(
libraryDependencies += "org.platanios" %% "tensorflow" % tensorFlowScalaVersion, // classifier "linux-gpu-x86_64",
)
lazy val all = (project in file("."))
.aggregate(mt, experiments, docs)
.dependsOn(mt, experiments, docs)
.settings(moduleName := "symphony", name := "Symphony")
.settings(commonSettings)
.settings(publishSettings)
.settings(
assemblyJarName in assembly := s"symphony-mt-${version.value}.jar",
mainClass in assembly := Some("org.platanios.symphony.mt.experiments.Experiment"),
test in assembly := {},
sourcesInBase := false,
unmanagedSourceDirectories in Compile := Nil,
unmanagedSourceDirectories in Test := Nil,
unmanagedResourceDirectories in Compile := Nil,
unmanagedResourceDirectories in Test := Nil,
publishArtifact := true)
lazy val mt = (project in file("./mt"))
.settings(moduleName := "symphony-mt", name := "Symphony Machine Translation")
.settings(commonSettings)
.settings(testSettings)
.settings(tensorFlowSettings)
.settings(publishSettings)
.settings(
libraryDependencies ++= Seq(
"com.github.pathikrit" %% "better-files" % "3.4.0",
"org.apache.commons" % "commons-compress" % "1.16.1",
"com.twitter" %% "util-collection" % "18.11.0"),
// Scalac Profiling Settings
libraryDependencies ++= {
if (scalacProfilingEnabled.value)
Seq(compilerPlugin("ch.epfl.scala" %% "scalac-profiling" % "1.0.0"))
else
Seq.empty
},
scalacOptions ++= {
if (scalacProfilingEnabled.value) {
Seq(
"-Ystatistics:typer",
// Scala profiler plugin options
"-P:scalac-profiling:no-profiledb",
"-P:scalac-profiling:show-profiles",
"-P:scalac-profiling:show-concrete-implicit-tparams")
} else {
Seq.empty
}
},
unmanagedResourceDirectories in Compile += baseDirectory.value / "lib",
unmanagedResourceDirectories in Test += baseDirectory.value / "lib",
unmanagedJars in Compile ++= Seq(
baseDirectory.value / "lib" / "meteor-1.5.jar",
baseDirectory.value / "lib" / "tercom-0.10.0.jar"))
lazy val experiments = (project in file("./experiments"))
.dependsOn(mt)
.settings(moduleName := "symphony-mt-experiments", name := "Symphony Machine Translation Experiments")
.settings(commonSettings)
.settings(testSettings)
.settings(publishSettings)
.settings(
mainClass in assembly := Some("org.platanios.symphony.mt.experiments.Experiment"),
libraryDependencies ++= Seq(
"com.github.pathikrit" %% "better-files" % "3.4.0",
"com.github.scopt" %% "scopt" % "3.7.0",
"com.hierynomus" % "sshj" % "0.24.0",
"com.jcraft" % "jzlib" % "1.1.3",
"com.typesafe" % "config" % "1.3.2"))
val MT = config("mt")
val Experiments = config("experiments")
lazy val docs = (project in file("docs"))
.dependsOn(mt, experiments)
.enablePlugins(SiteScaladocPlugin, ParadoxSitePlugin, ParadoxMaterialThemePlugin, GhpagesPlugin)
.settings(moduleName := "symphony-docs", name := "Symphony Documentation")
.settings(ParadoxMaterialThemePlugin.paradoxMaterialThemeSettings(Paradox))
.settings(
ghpagesNoJekyll := true,
sourceDirectory in Paradox := sourceDirectory.value / "main" / "paradox",
paradoxProperties in Paradox ++= Map(
"scaladoc.base_url" -> "http://platanios.org/symphony-mt/api/",
"scaladoc.org.platanios.symphony.mt.base_url" -> "http://platanios.org/symphony-mt/api/mt/",
"github.base_url" -> "https://github.com/eaplatanios/tensorflow_scala",
"snip.github_link" -> "false"),
paradoxNavigationDepth in Paradox := 3,
makeSite := makeSite.dependsOn(paradox in Paradox).value,
mappings in makeSite in Paradox ++= Seq(
file("LICENSE") -> "LICENSE",
file("assets/favicon.ico") -> "favicon.ico"),
scmInfo := Some(ScmInfo(
url("https://github.com/eaplatanios/symphony-mt"),
"git@github.com:eaplatanios/symphony-mt.git")),
git.remoteRepo := scmInfo.value.get.connection,
paradoxMaterialTheme in Paradox ~= {
_.withColor("white", "red")
// .withFavicon("favicon.ico")
.withLogo("assets/images/logo.png")
// .withGoogleAnalytics("UA-107934279-1")
.withRepository(uri("https://github.com/eaplatanios/symphony-mt"))
.withSocial(
uri("https://github.com/eaplatanios"),
uri("https://twitter.com/eaplatanios"))
.withLanguage(java.util.Locale.ENGLISH)
.withCustomStylesheet("assets/custom.css")
},
siteSubdirName in SiteScaladoc := "api",
SiteScaladocPlugin.scaladocSettings(MT, mappings in (Compile, packageDoc) in mt, "api/mt"),
SiteScaladocPlugin.scaladocSettings(Experiments, mappings in (Compile, packageDoc) in experiments, "api/experiments"),
scalacOptions in (SiteScaladoc, packageDoc) ++= Seq(
//"-Xfatal-warnings",
"-doc-source-url", scmInfo.value.get.browseUrl + "/tree/master€{FILE_PATH}.scala",
"-sourcepath", baseDirectory.in(LocalRootProject).value.getAbsolutePath,
// "=diagrams",
"-groups",
"-implicits-show-all"
))
lazy val noPublishSettings = Seq(
publish := Unit,
publishLocal := Unit,
publishArtifact := false,
skip in publish := true,
releaseProcess := Nil)
val deletedPublishedSnapshots = taskKey[Unit]("Delete published snapshots.")
lazy val publishSettings = Seq(
publishArtifact := true,
homepage := Some(url("https://github.com/eaplatanios/symphony-mt")),
licenses := Seq("Apache License 2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.txt")),
scmInfo := Some(ScmInfo(url("https://github.com/eaplatanios/symphony-mt"),
"scm:git:git@github.com:eaplatanios/symphony-mt.git")),
developers := List(
Developer(
id="eaplatanios",
name="Emmanouil Antonios Platanios",
email="e.a.platanios@gmail.com",
url=url("http://platanios.org/"))
),
autoAPIMappings := true,
apiURL := Some(url("http://eaplatanios.github.io/symphony-mt/api/")),
releaseCrossBuild := true,
releaseTagName := {
val buildVersionValue = (version in ThisBuild).value
val versionValue = version.value
s"v${if (releaseUseGlobalVersion.value) buildVersionValue else versionValue}"
},
releaseVersionBump := sbtrelease.Version.Bump.Next,
releaseUseGlobalVersion := true,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
releaseVcs := Vcs.detect(baseDirectory.value),
releaseVcsSign := true,
releaseIgnoreUntrackedFiles := true,
pgpPassphrase := sys.env.get("PGP_PASSWORD").map(_.toArray),
pgpPublicRing := file("~/.gnupg/pubring.gpg"),
pgpSecretRing := file("~/.gnupg/secring.gpg"),
publishMavenStyle := true,
// publishArtifact in Test := false,
pomIncludeRepository := Function.const(false),
publishTo := Some(
if (isSnapshot.value)
Opts.resolver.sonatypeSnapshots
else
Opts.resolver.sonatypeStaging
),
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
releaseStepCommandAndRemaining("+publishSigned"),
setNextVersion,
commitNextVersion,
releaseStepCommand("sonatypeReleaseAll"),
pushChanges
),
// The following 2 lines are needed to get around this: https://github.com/sbt/sbt/issues/4275
publishConfiguration := publishConfiguration.value.withOverwrite(true),
publishLocalConfiguration := publishLocalConfiguration.value.withOverwrite(true),
// For Travis CI - see http://www.cakesolutions.net/teamblogs/publishing-artefacts-to-oss-sonatype-nexus-using-sbt-and-travis-ci
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,
deletedPublishedSnapshots := {
Process(
"curl" :: "--request" :: "DELETE" :: "--write" :: "%{http_code} %{url_effective}\\n" ::
"--user" :: s"${System.getenv().get("SONATYPE_USERNAME")}:${System.getenv().get("SONATYPE_PASSWORD")}" ::
"--output" :: "/dev/null" :: "--silent" ::
s"${Opts.resolver.sonatypeSnapshots.root}/${organization.value.replace(".", "/")}/" :: Nil) ! streams.value.log
})