-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
173 lines (152 loc) · 5.64 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
import sbt.*
import scala.sys.process.*
ThisBuild / scalaVersion := "3.6.2"
ThisBuild / version := "0.1.0"
ThisBuild / organization := "io.github.kory33"
ThisBuild / javacOptions ++= Seq("-encoding", "UTF-8")
ThisBuild / scalacOptions ++= Seq(
"-Ykind-projector:underscores",
"-deprecation",
"-feature",
"-unchecked"
)
ThisBuild / resolvers += "Maven Central" at "https://repo1.maven.org/maven2/"
// for Scalafix
ThisBuild / semanticdbEnabled := true
ThisBuild / scalacOptions += "-Wunused:all"
val findMavenCommand = taskKey[String]("Determine the available Maven command")
val installPdqJar = taskKey[Unit]("Download and install pdq-common to local Maven repository")
val installKaon2 = taskKey[Unit]("Install kaon2 jar to local Maven repository")
val mavenPackage = taskKey[File]("Package submodule using Maven")
lazy val root = (project in file("."))
.aggregate(guardedSaturationWrapper, core, formulaParsers, coreIntegrationTests, app)
lazy val guardedSaturationWrapper = project
.in(file("guarded-saturation-wrapper"))
.settings(
findMavenCommand := {
def testMvnCommand(mvnExecutableName: String): Boolean = {
try {
Process(mvnExecutableName, Seq("-version")).!!
true
} catch {
case e: Exception => false
}
}
List("mvn", "mvn.cmd").find(testMvnCommand) match {
case Some(mvnExecutableName) => mvnExecutableName
case None => throw new Exception("Could not find Maven executable")
}
},
installPdqJar := {
val pdqCommonVersion = "2.0.0"
val localTemporaryJarPath =
s"guarded-saturation-wrapper/external_maven_dependencies/pdq-common-$pdqCommonVersion.jar"
val pdqCommonJarUrl =
s"https://github.com/ProofDrivenQuerying/pdq/releases/download/v$pdqCommonVersion/pdq-common-$pdqCommonVersion.jar"
// download the jar if it's not already present
val outputFile = file(localTemporaryJarPath)
if (!outputFile.exists()) {
outputFile.getParentFile.mkdirs()
(new java.net.URL(pdqCommonJarUrl) #> outputFile).!!
}
// install the jar to the local Maven repository unless we previously saw the JAR file
val foundMavenCommand = findMavenCommand.value
FileFunction.cached(
streams.value.cacheDirectory / "install-pdq-jar",
inStyle = FilesInfo.lastModified
) { _ =>
Process(
Seq(
foundMavenCommand,
"org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file",
// relative to the Guarded-saturation directory
s"-Dfile=../../$localTemporaryJarPath"
),
file("guarded-saturation-wrapper/Guarded-saturation")
).!
Set.empty
}(Set(file(localTemporaryJarPath)))
},
installKaon2 := {
val foundMavenCommand = findMavenCommand.value
FileFunction.cached(
streams.value.cacheDirectory / "install-kaon2",
inStyle = FilesInfo.lastModified
) { _ =>
Process(
Seq(
foundMavenCommand,
"install:install-file",
// relative to the Guarded-saturation directory
"-Dfile=src/main/resources/kaon2.jar",
"-DgroupId=org.semanticweb.kaon2",
"-DartifactId=kaon2",
"-Dversion=2008-06-29",
"-Dpackaging=jar",
"-DgeneratePom=true"
),
file("guarded-saturation-wrapper/Guarded-saturation")
).!
Set.empty
}(Set(file("guarded-saturation-wrapper/Guarded-saturation/src/main/resources/kaon2.jar")))
},
mavenPackage := {
// task dependencies
installPdqJar.value
installKaon2.value
val foundMavenCommand = findMavenCommand.value
val cachedMvnPackage =
FileFunction.cached(
streams.value.cacheDirectory / "maven-package",
inStyle = FilesInfo.lastModified,
outStyle = FilesInfo.exists
) { _ =>
Process(
// some tests in GSat just fail right now, so ignore tests
Seq(foundMavenCommand, "package", "-DskipTests"),
file("guarded-saturation-wrapper/Guarded-saturation")
).!
Set(file(
"guarded-saturation-wrapper/Guarded-saturation/target/guarded-saturation-1.0.0-jar-with-dependencies.jar"
))
}
val inputFiles =
(file("guarded-saturation-wrapper/Guarded-saturation") ** "*") ---
(file("guarded-saturation-wrapper/Guarded-saturation/target") ** "*")
cachedMvnPackage(inputFiles.get.toSet).head
}
)
lazy val core = project
.in(file("core"))
.settings(
Compile / unmanagedJars += (guardedSaturationWrapper / mavenPackage).value,
libraryDependencies ++= Seq(
"org.scalatestplus" %% "scalacheck-1-17" % "3.2.18.0" % Test,
"org.scalatest" %% "scalatest-flatspec" % "3.2.19" % Test
)
)
lazy val formulaParsers = project
.in(file("formula-parsers"))
.dependsOn(core)
.settings(
libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-parser-combinators" % "2.4.0"
)
)
lazy val coreIntegrationTests = project
.in(file("core-integration-tests"))
.dependsOn(core, formulaParsers)
.settings(
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest-flatspec" % "3.2.19" % Test
),
Test / logBuffered := true,
Test / baseDirectory := (ThisBuild / baseDirectory).value
)
lazy val app = project
.in(file("app"))
.dependsOn(core, formulaParsers)
.settings(
Compile / mainClass := Some("io.github.kory33.guardedqueries.app.App"),
assembly / assemblyOutputPath := baseDirectory.value / "target" / "guarded-saturation-app-0.1.0.jar"
)