-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sbt
138 lines (112 loc) · 5.09 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
import sbt.Keys._
import sbt._
import gov.nasa.jpl.imce.sbt._
import gov.nasa.jpl.imce.sbt.ProjectHelper._
updateOptions := updateOptions.value.withCachedResolution(true)
import scala.io.Source
import scala.util.control.Exception._
val extractArchives
: TaskKey[Unit]
= TaskKey[Unit]("extract-archives", "Extracts ZIP files")
lazy val core = Project("omf-scala-core", file("."))
.enablePlugins(IMCEGitPlugin)
.settings(dynamicScriptsResourceSettings("gov.nasa.jpl.omf.scala.core"))
.settings(IMCEPlugin.strictScalacFatalWarningsSettings)
.settings(
IMCEKeys.licenseYearOrRange := "2015",
IMCEKeys.organizationInfo := IMCEPlugin.Organizations.omf,
buildInfoPackage := "gov.nasa.jpl.omf.scala.core",
buildInfoKeys ++= Seq[BuildInfoKey](BuildInfoKey.action("buildDateUTC") { buildUTCDate.value }),
projectID := {
val previous = projectID.value
previous.extra(
"build.date.utc" -> buildUTCDate.value,
"artifact.kind" -> "generic.library")
},
IMCEKeys.targetJDK := IMCEKeys.jdk18.value,
git.baseVersion := Versions.version,
// include all test artifacts
publishArtifact in Test := true,
scalaVersion := Versions.scala,
scalaSource in Test := baseDirectory.value / "test",
extractArchives := {},
resolvers += Resolver.bintrayRepo("jpl-imce", "gov.nasa.jpl.imce"),
resolvers += "Artima Maven Repository" at "http://repo.artima.com/releases",
scalacOptions in (Compile, compile) += s"-P:artima-supersafe:config-file:${baseDirectory.value}/project/supersafe.cfg",
scalacOptions in (Test, compile) += s"-P:artima-supersafe:config-file:${baseDirectory.value}/project/supersafe.cfg",
scalacOptions in (Compile, doc) += "-Xplugin-disable:artima-supersafe",
scalacOptions in (Test, doc) += "-Xplugin-disable:artima-supersafe",
scalacOptions in (Compile,doc) ++= Seq(
"-diagrams",
"-doc-title", name.value,
"-doc-root-content", baseDirectory.value + "/rootdoc.txt"),
autoAPIMappings := true,
apiURL := Some(url("https://jpl-imce.github.io/gov.nasa.jpl.omf.scala.core/latest/api/")),
// Avoid unresolvable dependencies from old versions of log4j
libraryDependencies ~= {
_ map {
case m if m.organization == "log4j" =>
m
.exclude("javax.jms", "jms")
.exclude("com.sun.jmx", "jmxri")
.exclude("com.sun.jdmk", "jmxtools")
case m => m
}
},
dependencyOverrides += "com.fasterxml.jackson.module" % "jackson-module-paranamer" % Versions.spark_jackson % "compile",
dependencyOverrides += "com.fasterxml.jackson.module" %% "jackson-module-scala" % Versions.spark_jackson % "compile"
)
.dependsOnSourceProjectOrLibraryArtifacts(
"gov.nasa.jpl.imce.oml.resolver",
"gov.nasa.jpl.imce.oml.resolver",
Seq(
"gov.nasa.jpl.imce" %% "gov.nasa.jpl.imce.oml.resolver"
% Versions_oml_resolver.version
% "compile" withSources() artifacts(
Artifact("gov.nasa.jpl.imce.oml.resolver"),
Artifact("gov.nasa.jpl.imce.oml.resolver", "zip", "zip", "resource")
)
)
)
def dynamicScriptsResourceSettings(projectName: String): Seq[Setting[_]] = {
import com.typesafe.sbt.packager.universal.UniversalPlugin.autoImport._
def addIfExists(f: File, name: String): Seq[(File, String)] =
if (!f.exists) Seq()
else Seq((f, name))
val QUALIFIED_NAME = "^[a-zA-Z][\\w_]*(\\.[a-zA-Z][\\w_]*)*$".r
Seq(
// the '*-resource.zip' archive will start from: 'dynamicScripts'
com.typesafe.sbt.packager.Keys.topLevelDirectory in Universal := None,
// name the '*-resource.zip' in the same way as other artifacts
com.typesafe.sbt.packager.Keys.packageName in Universal :=
normalizedName.value + "_" + scalaBinaryVersion.value + "-" + version.value + "-resource",
// contents of the '*-resource.zip' to be produced by 'universal:packageBin'
mappings in Universal ++= {
val dir = baseDirectory.value
val bin = (packageBin in Compile).value
val src = (packageSrc in Compile).value
val doc = (packageDoc in Compile).value
val binT = (packageBin in Test).value
val srcT = (packageSrc in Test).value
val docT = (packageDoc in Test).value
(dir * ".classpath").pair(rebase(dir, projectName)) ++
(dir * "*.md").pair(rebase(dir, projectName)) ++
(dir / "resources" ***).pair(rebase(dir, projectName)) ++
addIfExists(bin, projectName + "/lib/" + bin.name) ++
addIfExists(binT, projectName + "/lib/" + binT.name) ++
addIfExists(src, projectName + "/lib.sources/" + src.name) ++
addIfExists(srcT, projectName + "/lib.sources/" + srcT.name) ++
addIfExists(doc, projectName + "/lib.javadoc/" + doc.name) ++
addIfExists(docT, projectName + "/lib.javadoc/" + docT.name)
},
artifacts += {
val n = (name in Universal).value
Artifact(n, "zip", "zip", Some("resource"), Seq(), None, Map())
},
packagedArtifacts += {
val p = (packageBin in Universal).value
val n = (name in Universal).value
Artifact(n, "zip", "zip", Some("resource"), Seq(), None, Map()) -> p
}
)
}