-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.sbt
More file actions
109 lines (99 loc) · 4.4 KB
/
build.sbt
File metadata and controls
109 lines (99 loc) · 4.4 KB
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
ThisBuild / semanticdbEnabled := true
lazy val scalaV = "3.8.2"
ThisBuild / scalaVersion := scalaV
resolvers +=
"Sonatype OSS Snapshots" at "https://s01.oss.sonatype.org/content/repositories/snapshots"
lazy val jenaV = "5.3.0"
lazy val jellyV = "3.7.1"
lazy val graalvmV = "25.0.2"
addCommandAlias("fixAll", "scalafixAll; scalafmtAll")
lazy val wErrorIfCI = if (sys.env.contains("CI")) Seq("-Werror") else Seq()
def isDevBuild: Boolean =
sys.env.get("DEV_BUILD").exists(s => s != "0" && s != "false")
lazy val graalOptions = Seq(
// Do a fast build if it's a dev build
// For the release build, optimize for speed and make a build report
if (isDevBuild) Seq("-Ob") else Seq("-O3", "--emit build-report"),
).flatten ++ Seq(
// If using dependencies on Scala <3.8 and JDK >=24, we need to allow unsafe memory access.
// Otherwise, we get annoying warnings on startup.
// https://github.com/scala/scala3/issues/9013
// Remove this after dependency upgrades to Scala 3.8+
// See this thread for an explanation of why this requires also updates in dependencies:
// https://github.com/scala/scala3/pull/24109#issuecomment-3786629196
"-J--sun-misc-unsafe-memory-access=allow",
// Custom Graal features
"--features=eu.neverblink.jelly.cli.graal.ProtobufFeature," +
"eu.neverblink.jelly.cli.graal.JenaInternalsFeature," +
"eu.neverblink.jelly.cli.graal.LargeXmlFeature",
"-H:ReflectionConfigurationFiles=" + file("graal.json").getAbsolutePath,
// Needed to skip initializing all charsets.
// See: https://github.com/Jelly-RDF/cli/issues/154
"--initialize-at-build-time=org.glassfish.json.UnicodeDetectingInputStream",
"-H:+TrackPrimitiveValues", // SkipFlow optimization
"-H:+UsePredicates", // SkipFlow optimization
"-H:+MLCallCountProfileInference", // ML inference for hot/cold method detection
// Make sure we don't include stuff that should be unreachable in the native image
"-H:AbortOnMethodReachable=*UUID.randomUUID*",
// Include XML error messages
// Issue: https://github.com/Jelly-RDF/cli/issues/217
"-H:IncludeResourceBundles=com.sun.org.apache.xerces.internal.impl.msg.XMLMessages",
)
lazy val TestSerial = config("test-serial") extend Test
lazy val root = (project in file("."))
.enablePlugins(
BuildInfoPlugin,
GraalVMNativeImagePlugin,
)
.configs(TestSerial)
.settings(
name := "jelly-cli",
libraryDependencies ++= Seq(
"org.slf4j" % "slf4j-simple" % "2.0.17",
"org.apache.jena" % "jena-core" % jenaV,
"org.apache.jena" % "jena-arq" % jenaV,
// Jelly-JVM >= 3.4.1 includes Jena 5.5.x as a dependency, we must exclude it, because
// we use Jena 5.3.0.
("eu.neverblink.jelly" % "jelly-jena" % jellyV).excludeAll(ExclusionRule("org.apache.jena")),
"eu.neverblink.jelly" % "jelly-core-protos-google" % jellyV,
"com.github.alexarchambault" %% "case-app" % "2.1.0",
"org.scalatest" %% "scalatest" % "3.2.19" % "test,test-serial",
"org.yaml" % "snakeyaml" % "2.6" % Test,
// For native-image reflection compatibility
"org.graalvm.sdk" % "graal-sdk" % graalvmV % "provided",
"org.reflections" % "reflections" % "0.10.2",
),
scalacOptions ++= Seq(
"-Wunused:imports",
"-feature",
"-deprecation",
"-unchecked",
"-explain",
) ++ wErrorIfCI,
buildInfoKeys := Seq[BuildInfoKey](
version,
scalaVersion,
libraryDependencies,
BuildInfoKey.action("buildTime") {
System.currentTimeMillis
},
),
buildInfoPackage := "eu.neverblink.jelly.cli",
assembly / assemblyMergeStrategy := {
case PathList("module-info.class") => MergeStrategy.discard
// https://jena.apache.org/documentation/notes/jena-repack.html
case PathList("META-INF", "services", xs @ _*) => MergeStrategy.concat
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
case PathList("reference.conf") => MergeStrategy.concat
case _ => MergeStrategy.first
},
// Serial tests should not run in parallel.
// They are used for tests that manipulate global state, like system properties.
inConfig(TestSerial)(Defaults.testSettings),
TestSerial / parallelExecution := false,
// GraalVM settings
Compile / mainClass := Some("eu.neverblink.jelly.cli.App"),
// Do a fast build if it's a dev build
// For the release build, optimize for speed and make a build report
graalVMNativeImageOptions := graalOptions,
)