forked from FRosner/spawncamping-dds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
124 lines (94 loc) · 4.05 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
/////////////
// Imports //
/////////////
import uk.gov.hmrc.GitStampPlugin._
import S3._
import Dependencies._
////////////////////////////////////////////////
// Common Settings Shared Across Sub-Projects //
////////////////////////////////////////////////
lazy val rootProjectName = settingKey[String]("Name of the root project")
lazy val commonMetaInformationSettings = Seq(
organization := "de.frosner",
version := "5.0.0-gamma-SNAPSHOT",
scalaVersion := "2.11.8",
rootProjectName := "spawncamping-dds"
)
lazy val commonCompileSettings = Seq(
fork in Compile := true,
scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8"),
resolvers += "jitpack" at "https://jitpack.io"
)
lazy val commonSettings = commonMetaInformationSettings ++ commonCompileSettings
commonSettings
////////////////////////////////
// Root Project Only Settings //
////////////////////////////////
lazy val shortScalaVersion = settingKey[String]("Scala major and minor version.")
lazy val finalArtifactName = settingKey[String]("Name of the final artifact.")
lazy val rootMetaInformationSettings = Seq(
name := rootProjectName.value
)
lazy val rootAssemblySettings = Seq(gitStampSettings:_*) ++ Seq(
shortScalaVersion := scalaVersion.value.split("\\.").take(2).mkString("."),
finalArtifactName := s"${name.value}-${version.value}_${shortScalaVersion.value}.jar",
test in assembly := {},
assemblyOption in assembly := (assemblyOption in assembly).value.copy(includeScala = false),
assemblyJarName in assembly := finalArtifactName.value
)
lazy val rootSettings = rootMetaInformationSettings ++ rootAssemblySettings
rootSettings // TODO check where we need these settings and if it makes sense to include them into common settings?
///////////////////////
// Custom Build Task //
///////////////////////
lazy val build = taskKey[Unit]("Jarjar link the assembly jar!")
build <<= assembly map { (asm) => s"./build.sh ${asm.getAbsolutePath()}" ! }
/////////////////////////////////
// Custom Artficat Upload Task //
/////////////////////////////////
lazy val currentBranch = System.getenv("TRAVIS_BRANCH")
val isSnapshotBranch = settingKey[Boolean]("Snapshot branch is active")
isSnapshotBranch := (currentBranch != null) && (currentBranch == "master" || currentBranch.startsWith("release/"))
val dontPublishTask = TaskKey[Unit]("dont-publish-to-s3", "Don't publish branch SNAPSHOT to S3.")
dontPublishTask <<= (streams) map { (s) => {
s.log.info(s"""Not publishing artifact to S3 (on branch $currentBranch)""")
}
}
val publishOrDontPublishTask = TaskKey[Unit]("publish-snapshot", "Publish depending on the current branch.")
publishOrDontPublishTask := Def.taskDyn({
if(isSnapshotBranch.value) S3.upload.toTask
else dontPublishTask.toTask
}).value
s3Settings
mappings in upload := Seq((new java.io.File(s"${System.getProperty("user.dir")}/target/scala-${shortScalaVersion.value}/${finalArtifactName.value}"),finalArtifactName.value))
host in upload := "spawncamping-dds-snapshots.s3.amazonaws.com"
credentials += Credentials("Amazon S3", "spawncamping-dds-snapshots.s3.amazonaws.com", System.getenv("ARTIFACTS_KEY"), System.getenv("ARTIFACTS_SECRET"))
///////////////////////
// Project Structure //
///////////////////////
lazy val root = (project in file(".")).
settings((commonSettings ++ rootSettings): _*).
settings(
name := rootProjectName.value
).
aggregate(core, datasets, webUi).
dependsOn(core, datasets, webUi)
lazy val core = (project in file("core")).
settings((commonSettings ++ rootSettings): _*).
settings(
name := rootProjectName.value + "-core",
libraryDependencies ++= coreDependencies
)
lazy val datasets = (project in file("datasets")).
settings((commonSettings ++ rootSettings): _*).
settings(
name := rootProjectName.value + "-datasets",
libraryDependencies ++= datasetsDependencies
)
lazy val webUi = (project in file("web-ui")).
dependsOn(core).
settings((commonSettings ++ rootSettings): _*).
settings(
name := rootProjectName.value + "-web-ui",
libraryDependencies ++= webUiDependencies
)