forked from openequella/openEQUELLA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
179 lines (143 loc) · 6.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
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
import java.util.Properties
import com.typesafe.sbt.license.LicenseReport
import sbt.io.Using
import Path.rebase
import scala.collection.JavaConverters._
lazy val learningedge_config = project in file("Dev/learningedge-config")
lazy val allPlugins = LocalProject("allPlugins")
val legacyPaths = Seq(
javaSource in Compile := baseDirectory.value / "src",
javaSource in Test := baseDirectory.value / "test",
unmanagedResourceDirectories in Compile := (baseDirectory.value / "resources") :: Nil,
unmanagedSourceDirectories in Compile := (javaSource in Compile).value :: Nil,
unmanagedSourceDirectories in Test := (javaSource in Test).value :: Nil
)
lazy val equellaserver = (project in file("Source/Server/equellaserver")).enablePlugins(JPFRunnerPlugin)
lazy val adminTool = (project in file("Source/Server/adminTool")).settings(legacyPaths).dependsOn(
platformSwing,
platformEquella,
LocalProject("com_tle_webstart_admin"),
LocalProject("adminConsoleJar")
)
lazy val conversion = (project in file("Source/Server/conversion")).settings(legacyPaths).dependsOn(
platformCommon
)
lazy val UpgradeInstallation = (project in file("Source/Tools/UpgradeInstallation")).settings(legacyPaths).dependsOn(
platformCommon,
platformEquella,
log4jCustom
)
lazy val UpgradeManager = (project in file("Source/Tools/UpgradeManager")).settings(legacyPaths).dependsOn(platformCommon, platformEquella, log4jCustom)
lazy val Installer = (project in file("Installer")).settings(legacyPaths).dependsOn(platformCommon, platformSwing, platformEquella, UpgradeManager)
lazy val equella = (project in file(".")).enablePlugins(JPFScanPlugin, JarSignerPlugin, GitVersioning)
.aggregate(equellaserver, allPlugins, adminTool, Installer,
UpgradeManager, conversion, UpgradeInstallation, learningedge_config)
buildConfig in ThisBuild := Common.buildConfig
oracleDriverJar in ThisBuild := {
val c = buildConfig.value
if (c.hasPath("build.oraclejar")) {
Some(file(c.getString("build.oraclejar")))
} else None
}
name := "Equella"
equellaMajorMinor in ThisBuild := "6.7"
equellaStream in ThisBuild := "Beta"
equellaBuild in ThisBuild := buildConfig.value.getString("build.buildname")
git.useGitDescribe := true
val TagRegex = """(.*)-(.*)-(\d*)-(.*)""".r
git.gitTagToVersionNumber := {
val streamName = equellaStream.value
val majorMinor = equellaMajorMinor.value
val buildName = equellaBuild.value
{
case TagRegex(_, _, v, sha) => Some(EquellaVersion(majorMinor, s"$streamName.$buildName", v.toInt, sha).fullVersion)
case _ => None
}
}
equellaVersion in ThisBuild := EquellaVersion(version.value)
versionProperties in ThisBuild := {
val eqVersion = equellaVersion.value
val props = new Properties
props.putAll(
Map("version.mm" -> eqVersion.majorMinor,
"version.mmr" -> s"${eqVersion.majorMinor}.r${eqVersion.commits}",
"version.display" -> s"${eqVersion.majorMinor}-${eqVersion.releaseType}",
"version.commit" -> eqVersion.sha).asJava)
val f = target.value / "version.properties"
IO.write(props, "version", f)
f
}
updateLicenses := {
val ourOrg = organization.value
val serverReport = (updateLicenses in equellaserver).value
val plugsinReports = updateLicenses.all(ScopeFilter(inAggregates(allPlugins))).value
val allLicenses = (plugsinReports.flatMap(_.licenses) ++ serverReport.licenses)
.groupBy(_.module).values.map(_.head).filterNot(_.module.organization == ourOrg)
LicenseReport(allLicenses.toSeq, serverReport.orig)
}
writeLanguagePack := {
IO.withTemporaryDirectory { dir =>
val allProps = langStrings.all(ScopeFilter(inAggregates(allPlugins, includeRoot = false))).value
.flatten.groupBy(ls => (ls.group, ls.xml))
.map { case ((g, xml), lss) =>
val fname = g + (if (xml) ".xml" else ".properties")
val f = dir / fname
val p = new SortedProperties()
lss.foreach(ls => p.putAll(ls.strings.asJava))
Using.fileOutputStream()(f) { os =>
if (xml) p.storeToXML(os, "") else p.store(os, "")
}
(f, fname)
}
val outZip = target.value / "reference-language-pack.zip"
sLog.value.info(s"Writing ${outZip.absolutePath}")
IO.zip(allProps, outZip)
outZip
}
}
aggregate in dumpLicenseReport := false
cancelable in Global := true
val pluginAndLibs = Def.task {
val bd = baseDirectory.value
val jpfLibs = jpfLibraryJars.value
(bd, jpfLibs)
}
mergeJPF := {
import complete.DefaultParsers._
val adminConsole = false
val args = spaceDelimited("<arg>").parsed
val _allPluginDirs = pluginAndLibs.all(ScopeFilter(inAggregates(allPlugins, includeRoot = false))).value
val extensionsOnly = (baseDirectory.value / "Source/Plugins/Extensions" * "*" / "plugin-jpf.xml").get
val allPluginDirs = _allPluginDirs ++ (extensionsOnly.map(f => (f.getParentFile, Seq.empty)))
if (args.isEmpty)
{
val plugins = PluginRefactor.findPluginsToMerge(allPluginDirs, adminConsole = adminConsole)
println(s"mergeJPF <ID> ${plugins.mkString(" ")}")
} else {
val newPlugin = args.head
val basePlugin = baseDirectory.value / "Source/Plugins"
PluginRefactor.mergePlugins(allPluginDirs, basePlugin, newPlugin, args.tail, adminConsole = adminConsole)
}
}
writeScriptingJavadoc := {
val javadocDir = (doc in Compile).value
val ver = version.value
val outZip = target.value / s"scriptingapi-javadoc-$ver.zip"
sLog.value.info(s"Writing ${outZip.absolutePath}")
IO.zip((javadocDir ** "*").pair(rebase(javadocDir, "")), outZip)
outZip
}
val userBeans : FileFilter = ("GroupBean.java" || "UserBean.java" || "RoleBean.java") &&
new SimpleFileFilter(_.getParentFile.getName == "valuebean")
// Globs came from the original ant scripts
def javadocSources(base: File): PathFinder = {
(base / "src") ** ("package-info.java" || "*ScriptType.java"
|| "*ScriptObject.java" || userBeans)
}
aggregate in (Compile, doc) := false
sources in (Compile, doc) := {
(javadocSources((baseDirectory in LocalProject("com_equella_base")).value)
+++ javadocSources((baseDirectory in LocalProject("com_equella_core")).value))
.get
}
javacOptions in (Compile, doc) := Seq()