This repository has been archived by the owner on Nov 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
127 lines (104 loc) · 4.24 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
// ============================================================
val appVersion = "0.5.2"
lazy val common = Seq(
scalaVersion := "2.11.12",
crossScalaVersions := Seq("2.11.12", "2.12.6"),
organization := "xyz.sigmalab.xtool",
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.4" % Test,
libraryDependencies ++= Seq(
"circe-core", "circe-generic", "circe-parser"
).map { m => "io.circe" %% m % "0.9.3" % Test },
scalacOptions ++= Seq(
"-deprecation",
"-feature"
)
)
def define(moduleName : String, artifact : String, dirName : String) = {
Project(moduleName, file(s"module/${dirName}"))
.settings(
name := artifact
).settings(common : _*)
}
def flink(moduleName : String, flinkVersion : String, v: String) = {
define(
moduleName,
s"elasticreporter-flink${flinkVersion}",
moduleName
).settings(
sbt.Keys.version := v,
crossScalaVersions := Seq("2.11.12"),
libraryDependencies += "org.apache.flink" % "flink-metrics-core" % flinkVersion % Provided,
libraryDependencies += "org.apache.flink" % "flink-core" % flinkVersion % Provided,
libraryDependencies += "org.apache.flink" %% "flink-runtime" % flinkVersion % Provided,
// libraryDependencies += "xmlenc" % "xmlenc" % "0.52" % Provided,
assemblyOption in assembly := (assemblyOption in assembly).value.copy(includeScala = false)
)
}
def flinkClone(moduleName: String, flinkVersion: String, v: String, origin: Project) = {
flink(
moduleName, flinkVersion, v
).dependsOn(cmn).settings(
sourceDirectory := (sourceDirectory in origin).value
)
}
// ============================================================
lazy val cmn = define(
"common",
"elasticreporter-common",
"common"
).settings(
libraryDependencies += "org.slf4j" % "slf4j-api" % "1.7.25" % Provided,
sbt.Keys.version := appVersion
)
lazy val flink16 = flink("flink16", "1.6.0", appVersion).dependsOn(cmn)
lazy val flink15 = flinkClone("flink15", "1.5.3", appVersion, flink16)
lazy val flink14 = flinkClone("flink14", "1.4.2", appVersion, flink15)
lazy val flink12 = flinkClone("flink12", "1.2.1", appVersion, flink14)
lazy val kamon = define("kamon", "elasticreporter-kamon", "kamon")
.settings(
libraryDependencies += "io.kamon" %% "kamon-core" % "1.1.0" % Provided,
sbt.Keys.version := appVersion
).dependsOn(cmn)
lazy val examplejob = {
val flinkDependencies = Seq(
"flink-scala",
"flink-streaming-scala"
) map { m =>
"org.apache.flink" %% m % "1.6.0" % Provided
}
val flinkJob = taskKey[File]("Source of jar")
val flinkMain = taskKey[String]("Job Main Class")
val flinkHome = taskKey[String]("Path to flink-home directory")
val flinkMaster = taskKey[String]("Host & Port to Flink JobManager")
val flinkRun = taskKey[Unit]("Run by flink")
define("examplejob", "examplejob", "examplejob")
.settings(
assembly / mainClass := Some("org.example.Job"),
libraryDependencies ++= flinkDependencies,
libraryDependencies += "org.apache.flink" % "flink-metrics-dropwizard" % "1.4.2" % Provided,
Compile / run := Defaults.runTask(Compile / fullClasspath,
Compile / run / mainClass,
Compile / run / runner
).evaluated,
Compile / run / fork := true,
Global / cancelable := true,
assembly / assemblyOption := (assembly / assemblyOption).value.copy(includeScala = false),
flinkJob := assembly.value,
flinkHome := "/home/reza/mine/opt-hdd/flink-1.4.2/",
flinkMaster := "jobmanager:6123",
flinkMain := "org.example.StreamTest",
flinkRun := {
val jar = flinkJob.value
val home = flinkHome.value
val master = flinkMaster.value
val main = flinkMain.value
val logger = streams.value.log("FlinkRemote")
logger.info(s"${home}/bin/flink run -c ${main} -m ${master} ${jar}")
}
)
}
lazy val root = (project in file(".")).aggregate(
cmn, kamon,
flink16, flink15, flink14, flink12,
examplejob
)