forked from openequella/openEQUELLA-autotests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
100 lines (79 loc) · 3.59 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
import com.typesafe.config.{Config, ConfigFactory}
import scala.collection.JavaConversions._
name := "equella-autotests"
version := "1.0"
scalaVersion := "2.12.2"
libraryDependencies += "org.jacoco" % "org.jacoco.agent" % "0.7.9" classifier "runtime"
lazy val installerDir = "equella-installer-6.4"
lazy val common = Seq(
resolvers += "Local EQUELLA deps" at IO.toURI(file(Path.userHome.absolutePath) / "/equella-deps").toString
)
lazy val platform = (project in file("Platform/Plugins/com.tle.platform.common")).settings(common).settings(
javaSource in Compile := baseDirectory.value / "src",
javaSource in Test := baseDirectory.value / "test",
libraryDependencies ++= Seq(
"org.apache.commons" % "commons-compress" % "1.1",
"jpf" % "jpf" % "1.0.7",
"com.google.guava" % "guava" % "18.0",
"commons-beanutils" % "commons-beanutils-equella" % "1.8.2.1",
"org.slf4j" % "slf4j-api" % "1.7.5",
"commons-codec" % "commons-codec" % "1.7",
"junit" % "junit" % "4.12" % Test
)
)
lazy val config = (project in file("config")).settings(resourceDirectory in Compile := baseDirectory.value / "resources")
lazy val Tests = (project in file("Tests")).settings(common).dependsOn(platform, config)
lazy val OldTests = (project in file("OldTests")).settings(common).dependsOn(platform, Tests, config)
val IntegTester = project in file("IntegTester")
buildConfig in ThisBuild := {
val defaultConfig = ConfigFactory.parseFile(file("project/build-defaults.conf"))
val configFile = sys.props.get("config.file").getOrElse("config/resources/application.conf")
ConfigFactory.load(ConfigFactory.parseFile(file(configFile)).withFallback(defaultConfig))
}
installDir := baseDirectory.value / "equella-install"
installOptions := {
val jacocoJar = update.value.select(module = moduleFilter("org.jacoco", "org.jacoco.agent"),
artifact = artifactFilter(classifier = "runtime")).head
val ic = buildConfig.value.getConfig("install")
InstallOptions(target.value / installerDir,
installDir.value, file(sys.props("java.home")),
url = ic.getString("url"), hostname = ic.getString("hostname"), port = ic.getInt("port"),
jacoco = Some(JacocoAgent(jacocoJar, target.value / "jacoco.exec")))
}
installerZip := {
if (buildConfig.value.hasPath("install.zip")) Some(file(buildConfig.value.getString("install.zip"))) else None
}
coverageReport := {
val io = installOptions.value
val allClasses = target.value / "all_classes"
(io.installDir / "plugins" ** "*.jar").get.foreach { jar =>
IO.unzip(jar, allClasses, filter = "classes/*")
}
CoverageReporter.createReport(io.jacoco.map(_.outFile).get, allClasses,
"Coverage", target.value / "coverage-report", target.value)
}
installEquella := {
val opts = installOptions.value
val zipFile = installerZip.value
val installSettings = target.value / "installsettings.xml"
zipFile.fold(sys.error("Must have install.zip set")) { z =>
IO.delete(target.value / installerDir)
IO.unzip(z, target.value)
val baseInstaller = opts.baseInstall
val installerJar = baseInstaller / "enterprise-install.jar"
opts.writeXML(installSettings)
val o = ForkOptions(runJVMOptions = Seq(
"-jar", installerJar.absolutePath
))
val args = Seq("--unsupported", installSettings.absolutePath)
Fork.java(o, args)
baseInstaller
}
}
def serviceCommand(opts: InstallOptions, cmd: String): Unit = {
val serverScript = opts.installDir / "manager/equellaserver"
List(serverScript.absolutePath, cmd).!
}
startEquella := serviceCommand(installOptions.value, "start")
stopEquella := serviceCommand(installOptions.value, "stop")
aggregate in test := false