forked from Privado-Inc/privado-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
230 lines (193 loc) · 10.5 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
import sbt.Credentials
name := "privado-core"
ThisBuild / organization := "ai.privado"
ThisBuild / scalaVersion := "3.3.1"
ThisBuild / version := sys.env.getOrElse("BUILD_VERSION", "dev-SNAPSHOT")
// parsed by project/Versions.scala, updated by updateDependencies.sh
val cpgVersion = "1.6.6"
val joernVersion = "2.0.283"
val overflowdbVersion = "1.187"
val requests = "0.8.0"
val upickle = "3.1.2"
//External dependency versions
val circeVersion = "0.14.2"
val jacksonVersion = "2.15.2"
val mockitoVersion = "1.17.14"
val goAstGenVersion = "0.12.0"
val dotnetAstGenVersion = "0.18.0"
lazy val schema = Projects.schema
lazy val domainClasses = Projects.domainClasses
lazy val schemaExtender = Projects.schemaExtender
dependsOn(domainClasses)
libraryDependencies ++= Seq(
"com.github.pathikrit" %% "better-files" % "3.9.2",
"com.github.scopt" %% "scopt" % "4.1.0",
"io.joern" %% "x2cpg" % Versions.joern,
"io.joern" %% "x2cpg" % Versions.joern % Test classifier "tests",
"io.joern" %% "javasrc2cpg" % Versions.joern,
"io.joern" %% "pysrc2cpg" % Versions.joern,
"io.joern" %% "pysrc2cpg" % Versions.joern % Test classifier "tests",
"io.joern" %% "rubysrc2cpg" % Versions.joern,
"io.joern" %% "kotlin2cpg" % Versions.joern,
"io.joern" %% "gosrc2cpg" % Versions.joern,
"io.joern" %% "csharpsrc2cpg" % Versions.joern,
"io.joern" %% "joern-cli" % Versions.joern,
"io.joern" %% "semanticcpg" % Versions.joern,
"io.joern" %% "semanticcpg" % Versions.joern % Test classifier "tests",
"org.scalatest" %% "scalatest" % "3.2.16" % Test,
"io.circe" %% "circe-core" % circeVersion,
"io.circe" %% "circe-generic" % circeVersion,
"io.circe" %% "circe-parser" % circeVersion,
// NOTE: circe-yaml currently only goes until 0.14.2 (Last checked 06/07/2023)
"io.circe" %% "circe-yaml" % circeVersion exclude ("org.yaml", "snakeyaml"),
"com.lihaoyi" %% "upickle" % Versions.upickle,
"com.lihaoyi" %% "requests" % Versions.requests,
"org.scala-lang.modules" %% "scala-xml" % "2.1.0",
"org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.4",
"commons-io" % "commons-io" % "2.11.0",
"com.networknt" % "json-schema-validator" % "1.0.72",
"com.fasterxml.jackson.module" %% "jackson-module-scala" % jacksonVersion,
"com.fasterxml.jackson.dataformat" % "jackson-dataformat-yaml" % jacksonVersion exclude ("org.yaml", "snakeyaml"),
"com.github.wnameless.json" % "json-flattener" % "0.14.0",
"org.apache.logging.log4j" % "log4j-core" % "2.19.0",
"org.apache.logging.log4j" % "log4j-slf4j2-impl" % "2.19.0",
"org.apache.poi" % "poi-ooxml" % "5.2.2",
"com.github.jsqlparser" % "jsqlparser" % "4.6",
"org.apache.maven" % "maven-model" % "3.9.0",
"net.sourceforge.htmlunit" % "htmlunit" % "2.70.0",
"org.yaml" % "snakeyaml" % "1.33",
"org.scala-lang" % "scala-reflect" % "2.13.8",
"org.scala-lang" % "scala-compiler" % "2.13.8",
"com.iheart" %% "ficus" % "1.5.2" exclude ("com.typesafe", "config"),
"org.jruby" % "jruby-base" % "9.4.3.0",
"org.zeromq" % "jeromq" % "0.5.4",
"org.sangria-graphql" %% "sangria" % "4.0.0",
"com.michaelpollmeier" % "versionsort" % "1.0.11",
"io.joern" %% "dataflowengineoss" % Versions.joern % Test classifier "tests",
scalaOrganization.value %% "scala3-compiler" % scalaVersion.value
)
ThisBuild / Compile / scalacOptions ++= Seq("-feature", "-deprecation", "-language:implicitConversions")
enablePlugins(JavaAppPackaging)
ThisBuild / licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0"))
Global / onChangedBuildSource := ReloadOnSourceChanges
ThisBuild / resolvers ++= Seq(
Resolver.mavenLocal,
"Sonatype OSS" at "https://oss.sonatype.org/content/repositories/public",
"Gradle Releases" at "https://repo.gradle.org/gradle/libs-releases"
) ++ Resolver.sonatypeOssRepos("snapshots")
lazy val astGenDlUrl = "https://github.com/joernio/astgen/releases/download/v3.1.0/"
lazy val astGenBinaryNames = Seq("astgen-linux", "astgen-macos", "astgen-win.exe", "astgen-macos-arm")
lazy val astGenDlTask = taskKey[Unit](s"Download astgen binaries")
astGenDlTask := {
val astGenDir = baseDirectory.value / "bin" / "astgen"
astGenDir.mkdirs()
astGenBinaryNames.foreach { fileName =>
val dest = astGenDir / fileName
if (!dest.exists) {
val url = s"$astGenDlUrl$fileName"
val downloadedFile = SimpleCache.downloadMaybe(url)
IO.copyFile(downloadedFile, dest)
}
}
val distDir = (Universal / stagingDirectory).value / "bin" / "astgen"
distDir.mkdirs()
IO.copyDirectory(astGenDir, distDir)
// permissions are lost during the download; need to set them manually
astGenDir.listFiles().foreach(_.setExecutable(true, false))
distDir.listFiles().foreach(_.setExecutable(true, false))
}
Compile / compile := ((Compile / compile) dependsOn astGenDlTask).value
// download goastgen: start
lazy val GoAstgenWin = "goastgen-windows.exe"
lazy val GoAstgenLinux = "goastgen-linux"
lazy val GoAstgenLinuxArm = "goastgen-linux-arm64"
lazy val GoAstgenMac = "goastgen-macos"
lazy val GoAstgenMacArm = "goastgen-macos-arm64"
lazy val goAstGenDlUrl = settingKey[String]("goastgen download url")
goAstGenDlUrl := s"https://github.com/Privado-Inc/goastgen/releases/download/v${goAstGenVersion}/"
lazy val goAstGenBinaryNames = taskKey[Seq[String]]("goastgen binary names")
goAstGenBinaryNames := { Seq(GoAstgenWin, GoAstgenLinux, GoAstgenLinuxArm, GoAstgenMac, GoAstgenMacArm) }
lazy val goAstGenDlTask = taskKey[Unit](s"Download goastgen binaries")
goAstGenDlTask := {
val goAstGenDir = baseDirectory.value / "bin" / "astgen"
goAstGenDir.mkdirs()
goAstGenBinaryNames.value.foreach { fileName =>
val dest = goAstGenDir / fileName
if (!dest.exists) {
val url = s"${goAstGenDlUrl.value}$fileName"
val downloadedFile = SimpleCache.downloadMaybe(url)
IO.copyFile(downloadedFile, dest)
}
}
val distDir = (Universal / stagingDirectory).value / "bin" / "astgen"
distDir.mkdirs()
IO.copyDirectory(goAstGenDir, distDir)
// permissions are lost during the download; need to set them manually
goAstGenDir.listFiles().foreach(_.setExecutable(true, false))
distDir.listFiles().foreach(_.setExecutable(true, false))
}
lazy val goAstGenSetAllPlatforms = taskKey[Unit](s"Set ALL_PLATFORMS")
goAstGenSetAllPlatforms := { System.setProperty("ALL_PLATFORMS", "TRUE") }
stage := Def
.sequential(goAstGenSetAllPlatforms, Universal / stage)
.andFinally(System.setProperty("ALL_PLATFORMS", "FALSE"))
.value
// download goastgen: end
// download dotnetastgen: start
lazy val DotNetAstgenWin = "dotnetastgen-win.exe"
lazy val DotNetAstgenWinArm = "dotnetastgen-win-arm.exe"
lazy val DotNetAstgenLinux = "dotnetastgen-linux"
lazy val DotNetAstgenLinuxArm = "dotnetastgen-linux-arm"
lazy val DotNetAstgenMac = "dotnetastgen-macos"
lazy val dotnetAstGenDownloadUrl = settingKey[String]("dotnetastgen download url")
dotnetAstGenDownloadUrl := s"https://github.com/joernio/DotNetAstGen/releases/download/v${dotnetAstGenVersion}/"
lazy val dotnetAstGenBinaryNames = taskKey[Seq[String]]("dotnetastgen binary names")
dotnetAstGenBinaryNames := {
Seq(DotNetAstgenWin, DotNetAstgenWinArm, DotNetAstgenLinux, DotNetAstgenLinuxArm, DotNetAstgenMac)
}
lazy val dotnetAstGenDlTask = taskKey[Unit](s"Download dotnetastgen binaries")
dotnetAstGenDlTask := {
val dotnetAstGenDir = baseDirectory.value / "bin" / "astgen"
dotnetAstGenDir.mkdirs()
dotnetAstGenBinaryNames.value.foreach { fileName =>
val dest = dotnetAstGenDir / fileName
if (!dest.exists) {
val url = s"${dotnetAstGenDownloadUrl.value}$fileName"
val downloadedFile = SimpleCache.downloadMaybe(url)
IO.copyFile(downloadedFile, dest)
}
}
val distDir = (Universal / stagingDirectory).value / "bin" / "astgen"
distDir.mkdirs()
IO.copyDirectory(dotnetAstGenDir, distDir)
// permissions are lost during the download; need to set them manually
dotnetAstGenDir.listFiles().foreach(_.setExecutable(true, false))
distDir.listFiles().foreach(_.setExecutable(true, false))
}
Compile / compile := ((Compile / compile).dependsOn(goAstGenDlTask, dotnetAstGenDlTask)).value
lazy val dotnetAstGenSetAllPlatforms = taskKey[Unit](s"Set ALL_PLATFORMS")
dotnetAstGenSetAllPlatforms := { System.setProperty("ALL_PLATFORMS", "TRUE") }
stage := Def
.sequential(dotnetAstGenSetAllPlatforms, Universal / stage)
.andFinally(System.setProperty("ALL_PLATFORMS", "FALSE"))
.value
// download dotnetastgen: end
// Also remove astgen binaries with clean, e.g., to allow for updating them.
// Sadly, we can't define the bin/ folders globally,
// as .value can only be used within a task or setting macro
cleanFiles ++= Seq(
baseDirectory.value / "bin" / "astgen",
(Universal / stagingDirectory).value / "bin" / "astgen"
) ++ astGenBinaryNames.map(fileName => SimpleCache.encodeFile(s"$astGenDlUrl$fileName"))
Compile / doc / sources := Seq.empty
Compile / packageDoc / publishArtifact := false
val repoPass = sys.env.getOrElse("CODEARTIFACT_AUTH_TOKEN", "")
credentials += Credentials("privado/core", sys.env.getOrElse("CODE_ARTIFACT_URL", ""), "aws", repoPass)
publishMavenStyle := true
resolvers += "privado--core" at "https://" + sys.env.getOrElse("CODE_ARTIFACT_URL", "") + "/maven/core"
ThisBuild / publishTo := Some(
"privado--core" at "https://" + sys.env.getOrElse("CODE_ARTIFACT_URL", "") + "/maven/core"
)
lazy val root = (project in file("."))
.enablePlugins(BuildInfoPlugin)
.settings(buildInfoKeys := Seq[BuildInfoKey]("joernVersion" -> joernVersion), buildInfoPackage := "privado_core")