-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
107 lines (79 loc) · 3.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
import sbt.Keys._
import sbt._
import gov.nasa.jpl.imce.sbt._
import scala.xml.{Node => XNode}
import scala.xml.transform._
useGpg := true
lazy val artifactZipFile = taskKey[File]("Location of the zip artifact file")
lazy val root = Project("gov-nasa-jpl-imce-ontologies-tools", file("."))
.enablePlugins(IMCEGitPlugin)
.enablePlugins(IMCEReleasePlugin)
.settings(IMCEReleasePlugin.packageReleaseProcessSettings: _*)
.settings(
IMCEKeys.licenseYearOrRange := "2009-2016",
IMCEKeys.organizationInfo := IMCEPlugin.Organizations.omf,
IMCEKeys.targetJDK := IMCEKeys.jdk18.value,
projectID := {
val previous = projectID.value
previous.extra(
"build.date.utc" -> buildUTCDate.value,
"artifact.kind" -> "omf.ontologies")
},
// disable using the Scala version in output paths and artifacts
crossPaths := false,
extractArchives := {},
artifactZipFile := {
import com.typesafe.sbt.packager.universal._
val top=baseDirectory.value
val subDirs = Seq("data", "documents", "exports", "launchers", "lib", "tools")
val fileMappings: Seq[(File, String)] =
subDirs.foldLeft(Seq.empty[(File,String)]) { (acc, dir) =>
val inc: Seq[(File,String)] = (top / dir ***).pair(relativeTo(top)).sortBy(_._2)
acc ++ inc
}
val zipFile: File = baseDirectory.value / "target" / s"imce.ontologies.tools-${version.value}.zip"
ZipHelper.zipNative(fileMappings, zipFile)
zipFile
},
addArtifact(Artifact("imce-omf_ontologies", "zip", "zip", Some("resource"), Seq(), None, Map()), artifactZipFile),
makePom := { artifactZipFile; makePom.value },
sourceGenerators in Compile := Seq(),
managedSources in Compile := Seq(),
// disable publishing the main jar produced by `package`
publishArtifact in(Compile, packageBin) := false,
// disable publishing the main API jar
publishArtifact in(Compile, packageDoc) := false,
// disable publishing the main sources jar
publishArtifact in(Compile, packageSrc) := false,
// disable publishing the jar produced by `test:package`
publishArtifact in(Test, packageBin) := false,
// disable publishing the test API jar
publishArtifact in(Test, packageDoc) := false,
// disable publishing the test sources jar
publishArtifact in(Test, packageSrc) := false
)
def UpdateProperties(base: File): RewriteRule = {
val targetDir = base / "target"
val oDir= targetDir / "ontologies"
val fileMappings = (oDir.*** pair relativeTo(targetDir)).sortBy(_._2)
val oFiles = fileMappings flatMap {
case (file, path) if ! file.isDirectory =>
Some(MD5File(name=path, md5=MD5.hashFile(file)))
case _ =>
None
}
val all = MD5SubDirectory(
name = "ontologies",
files = oFiles)
new RewriteRule {
import spray.json._
import MD5JsonProtocol._
override def transform(n: XNode): Seq[XNode]
= n match {
case <properties>{props@_*}</properties> =>
<properties>{props}<md5>{all.toJson}</md5></properties>
case _ =>
n
}
}
}