-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sc
321 lines (259 loc) · 10.1 KB
/
build.sc
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
//import $ivy.`com.lihaoyi::mill-contrib-bloop:$MILL_VERSION`
import mill._
import mill.scalalib._
import ammonite.ops.Path
import coursier.Repository
import coursier.maven.MavenRepository
import coursier.core.Authentication
import mill.define.{Sources, Target}
import mill.modules.Jvm
import mill.scalalib.publish._
import mill.util.PrintLogger
import os.RelPath
import scala.util.Success
/** The versions of the blended mill plugin, the core and the mgmt ui */
val coreVersion : String = "3.2-RC2"
val blendedUiVersion : String = "0.6"
val akkaBundleRevision : String = "1"
/** Project directory. */
val projectDir: os.Path = build.millSourcePath
import $ivy.`de.wayofquality.blended::blended-mill:0.4.1`
import de.wayofquality.blended.mill.modules._
import de.wayofquality.blended.mill.feature._
import de.wayofquality.blended.mill.utils.{FilterUtil, ZipUtil}
import de.wayofquality.blended.mill.versioning.GitModule
import de.wayofquality.blended.mill.publish.BlendedPublishModule
import de.wayofquality.blended.mill.container.BlendedContainerModule
object GitSupport extends GitModule {
override def millSourcePath: Path = projectDir
}
def projectVersion = T { GitSupport.publishVersion() }
def imageVersion = T {
val tag : String = T.env.get("GIT_TAG").getOrElse("").trim()
if (tag.isEmpty()) {
os.read(projectDir / "version.txt").trim()
} else {
tag
}
}
/** Configure additional repositories. */
trait BlendedCoursierModule extends CoursierModule {
private def zincWorker: ZincWorkerModule = mill.scalalib.ZincWorkerModule
override def repositories: Seq[Repository] = zincWorker.repositories ++ Seq(
MavenRepository("https://repo.spring.io/libs-release"),
MavenRepository("http://repository.springsource.com/maven/bundles/release"),
MavenRepository("http://repository.springsource.com/maven/bundles/external"),
MavenRepository(
s"https://u233308-sub2.your-storagebox.de/blended/$coreVersion",
Some(Authentication("u233308-sub2", "px8Kumv98zIzSF7k"))
),
MavenRepository(
s"https://u233308-sub2.your-storagebox.de/mgmt-ui/$blendedUiVersion",
Some(Authentication("u233308-sub2", "px8Kumv98zIzSF7k"))
),
MavenRepository(
s"https://u233308-sub2.your-storagebox.de/akka-osgi/$akkaBundleRevision",
Some(Authentication("u233308-sub2", "px8Kumv98zIzSF7k"))
)
)
}
trait ContainerModule extends BlendedContainerModule with BlendedPublishModule with BlendedCoursierModule {
override def scalaVersion : T[String] = T{ deps.scalaVersion }
override def baseDir : Path = projectDir
override def profileVersion : T[String] = T { projectVersion() }
override def blendedCoreVersion : String = coreVersion
override type ProjectDeps = BlendedDependencies
override def deps : ProjectDeps = BlendedDependencies.Deps_2_13
def blendedDep : String => Dep = deps.blendedDep(coreVersion)
override def githubRepo = "blended.container"
override def publishVersion : T[String] = T { projectVersion() }
override def extraPublish : T[Seq[PublishInfo]] = T { super.extraPublish() ++ ctArtifacts() }
}
trait CtIntegrationTest extends BlendedBaseModule with BlendedCoursierModule {
override type ProjectDeps = BlendedDependencies
override def deps : ProjectDeps = BlendedDependencies.Deps_2_13
override def baseDir : os.Path = projectDir
override def scalaVersion : T[String] = T { deps.scalaVersion }
def blendedDep : String => Dep = deps.blendedDep(coreVersion)
trait CtTest extends super.BlendedTests {
def dockerhost = T.input { T.env.getOrElse("DOCKERHOST", "unix:///var/run/docker.sock") }
def dockerport = T.input { T.env.getOrElse("DOCKERPORT", "2375") }
def logResources = T {
val moduleSpec = toString()
val dest = T.ctx().dest
val logConfig =
s"""<configuration>
|
| <appender name="FILE" class="ch.qos.logback.core.FileAppender">
| <file>${projectDir.toString()}/out/testlog/test-${moduleSpec}.log</file>
|
| <encoder>
| <pattern>%d{yyyy-MM-dd-HH:mm.ss.SSS} | %8.8r | %-5level [%t] %logger : %msg%n</pattern>
| </encoder>
| </appender>
|
| <logger name="blended" level="debug" />
| <logger name="domino" level="debug" />
| <logger name="App" level="debug" />
|
| <root level="INFO">
| <appender-ref ref="FILE" />
| </root>
|
|</configuration>
|""".stripMargin
os.write(dest / "logback-test.xml", logConfig)
PathRef(dest)
}
override def runClasspath = T { super.runClasspath() ++ Seq(logResources()) }
override def sources: Sources = T.sources (
millSourcePath / "src" / "test" / "scala",
millSourcePath / "src" / "test" / "java"
)
override def resources = T.sources(
millSourcePath / "src" / "test" / "resources"
)
override def forkArgs = T { super.forkArgs() ++ Seq(
s"-DprojectTestOutput=${(millSourcePath / "src" / "test" / "resources").toIO.getAbsolutePath()}",
s"-DlogDir=${(baseDir / "out" / s"testlog-${System.getProperty("java.version")}-${scalaVersion()}" / "ctLogs"/ blendedModule).toIO.getAbsolutePath()}",
s"-Ddocker.host=${dockerhost()}",
s"-Ddocker.port=${dockerport()}",
s"-Dimage.version=${imageVersion()}"
)}
override def ivyDeps : T[Agg[Dep]] = T { super.ivyDeps() ++ Agg(
deps.activeMqClient,
deps.scalatest,
deps.slf4j,
deps.akkaActor(akkaBundleRevision),
deps.akkaStream(akkaBundleRevision),
deps.akkaSlf4j(akkaBundleRevision),
deps.logbackClassic,
deps.logbackCore,
deps.geronimoJ2eeMgmtSpec,
deps.geronimoJms11Spec,
deps.dockerJava,
deps.akkaTestkit,
blendedDep("util.logging"),
blendedDep("jms.utils"),
blendedDep("util"),
blendedDep("akka"),
blendedDep("security.ssl"),
blendedDep("streams"),
blendedDep("testsupport"),
blendedDep("streams.testsupport"),
blendedDep("itestsupport")
)}
/* This is just a workaround to see if it actually works */
def itest() = T.command {
val dir = T.dest
Jvm.runSubprocess(
mainClass = "org.scalatest.tools.Runner",
classPath = runClasspath().map(_.path),
mainArgs = Seq(
"-R", compile().classes.path.toIO.getAbsolutePath(),
"-o"
),
jvmArgs = forkArgs()
)
PathRef(dir)
}
}
}
object blended extends Module {
object demo extends Module {
object node extends ContainerModule {
override def description = "A simple blended demo container"
//override def debugTool : Boolean = true
override def millSourcePath : os.Path = projectDir / "container" / "blended.demo.node"
override def features : T[Seq[FeatureRef]] = T { Seq(
FeatureRef(
dependency = blendedDep("features"),
names = List(
"blended.features.base.felix",
//"blended.features.base.equinox",
"blended.features.base.common",
"blended.features.commons",
"blended.features.spring",
"blended.features.ssl",
"blended.features.jetty",
"blended.features.jolokia",
"blended.features.hawtio",
"blended.features.activemq",
"blended.features.security",
"blended.features.login",
"blended.features.mgmt.client",
"blended.features.akka.http.base",
"blended.features.persistence",
"blended.features.streams",
"blended.features.samples"
)
)
)}
object docker extends Docker {
override def dockerImage = T { s"blended/blended-node:${imageVersion()}"}
override def exposedPorts = Seq(1099, 1883, 1884, 1885, 1886, 8181, 8849, 9191, 9995, 9996)
}
}
object mgmt extends ContainerModule {
override def description = "A simple blended management container"
override def millSourcePath : os.Path = projectDir / "container" / "blended.demo.mgmt"
//override def debugTool = true
override def features : T[Seq[FeatureRef]] = T { Seq(
FeatureRef(
dependency = blendedDep("features"),
names = List(
"blended.features.base.felix",
//"blended.features.base.equinox",
"blended.features.base.common",
"blended.features.commons",
"blended.features.jetty",
"blended.features.hawtio",
"blended.features.spring",
"blended.features.ssl",
"blended.features.security",
"blended.features.login",
"blended.features.mgmt.client",
"blended.features.mgmt.server",
"blended.features.akka.http.base",
"blended.features.streams",
"blended.features.persistence"
)
)
)}
object docker extends Docker {
override def dockerImage = T { s"blended/blended-mgmt:${imageVersion()}"}
override def exposedPorts = Seq(1099, 1883, 9191, 8849, 9995, 9996)
}
}
}
object itest extends Module {
object node extends CtIntegrationTest {
object test extends super.CtTest {
override def ivyDeps : T[Agg[Dep]] = T {
super.ivyDeps()
}
override def forkArgs: Target[Seq[String]] = T { super.forkArgs() ++ Seq(
s"-DappFolder=${blended.demo.node.docker.appFolder()}"
)}
override def millSourcePath: Path = projectDir / "itest" / "blended.itest.node"
}
}
object mgmt extends CtIntegrationTest {
object test extends super.CtTest {
override def ivyDeps : T[Agg[Dep]] = T {
super.ivyDeps() ++ Agg(
deps.sttp,
deps.sttpAkka,
deps.microjson,
deps.prickle,
deps.lihaoyiPprint
)
}
override def forkArgs = T { super.forkArgs() ++ Seq(
s"-Ddeploymentpack=${blended.demo.node.deploymentpack().path.toIO.getAbsolutePath()}"
)}
override def millSourcePath: Path = projectDir / "itest" / "blended.itest.mgmt"
}
}
}
}