11import scala .xml .{Node => XmlNode , NodeSeq => XmlNodeSeq , _ }
22import scala .xml .transform .{RewriteRule , RuleTransformer }
33import java .io .File
4+ import java .nio .file .Files
45import java .util .Properties
56import scala .collection .mutable .ListBuffer
67
78lazy val V =
89 new {
10+ val protobuf = " 3.15.6"
911 val coursier = " 2.0.8"
1012 val bloop = " 1.4.7"
1113 val bsp = " 2.0.0-M13"
@@ -64,22 +66,27 @@ commands +=
6466 " javafmtCheckAll" :: " publishLocal" :: " docs/docusaurusCreateSite" :: s
6567 }
6668
69+ lazy val semanticdb = project
70+ .in(file(" semanticdb-java" ))
71+ .settings(
72+ moduleName := " semanticdb-java" ,
73+ javaOnlySettings,
74+ PB .targets.in(Compile ) :=
75+ Seq (PB .gens.java(V .protobuf) -> (Compile / sourceManaged).value)
76+ )
77+
6778lazy val agent = project
6879 .in(file(" semanticdb-agent" ))
6980 .settings(
7081 fatjarPackageSettings,
71- autoScalaLibrary := false ,
82+ javaOnlySettings ,
7283 moduleName := " semanticdb-agent" ,
7384 libraryDependencies ++=
7485 List (
7586 " org.javassist" % " javassist" % " 3.27.0-GA" ,
7687 " net.bytebuddy" % " byte-buddy" % " 1.10.20" ,
7788 " net.bytebuddy" % " byte-buddy-agent" % " 1.10.20"
7889 ),
79- incOptions ~= { old =>
80- old.withEnabled(false )
81- },
82- crossPaths := false ,
8390 Compile / packageBin / packageOptions +=
8491 Package .ManifestAttributes (
8592 " Agent-Class" -> " com.sourcegraph.semanticdb_javac.SemanticdbAgent" ,
@@ -92,13 +99,10 @@ lazy val agent = project
9299lazy val plugin = project
93100 .in(file(" semanticdb-javac" ))
94101 .settings(
102+ fatjarPackageSettings,
103+ javaOnlySettings,
95104 moduleName := " semanticdb-javac" ,
96105 javaToolchainVersion := " 1.8" ,
97- autoScalaLibrary := false ,
98- incOptions ~= { old =>
99- old.withEnabled(false )
100- },
101- fatjarPackageSettings,
102106 assemblyShadeRules.in(assembly) :=
103107 Seq (
104108 ShadeRule
@@ -108,14 +112,26 @@ lazy val plugin = project
108112 " org.relaxng.**" -> " com.sourcegraph.shaded.relaxng.@1"
109113 )
110114 .inAll
111- ),
112- crossPaths := false ,
115+ )
116+ )
117+ .dependsOn(semanticdb)
118+
119+ lazy val lsif = project
120+ .in(file(" lsif-semanticdb" ))
121+ .settings(
122+ moduleName := " lsif-semanticdb" ,
123+ javaToolchainVersion := " 1.8" ,
124+ javaOnlySettings,
125+ libraryDependencies +=
126+ " com.google.protobuf" % " protobuf-java-util" % V .protobuf,
113127 PB .targets.in(Compile ) :=
114- Seq (PB .gens.java -> (Compile / sourceManaged).value)
128+ Seq (PB .gens.java(V .protobuf) -> (Compile / sourceManaged).value),
129+ Compile / PB .protocOptions := Seq (" --experimental_allow_proto3_optional" )
115130 )
131+ .dependsOn(semanticdb)
116132
117133lazy val cli = project
118- .in(file(" cli " ))
134+ .in(file(" lsif-java " ))
119135 .settings(
120136 moduleName := " lsif-java" ,
121137 mainClass.in(Compile ) := Some (" com.sourcegraph.lsif_java.LsifJava" ),
@@ -128,7 +144,11 @@ lazy val cli = project
128144 " bspVersion" -> V .bsp
129145 ),
130146 buildInfoPackage := " com.sourcegraph.lsif_java" ,
131- libraryDependencies ++= List (" org.scalameta" %% " moped" % V .moped),
147+ libraryDependencies ++=
148+ List (
149+ " org.scalameta" %% " moped" % V .moped,
150+ " org.scalameta" %% " ascii-graphs" % " 0.1.2"
151+ ),
132152 resourceGenerators.in(Compile ) +=
133153 Def
134154 .task[Seq [File ]] {
@@ -161,11 +181,25 @@ lazy val cli = project
161181 propsFile :: copiedJars.toList
162182 }
163183 .taskValue,
164- nativeImageOptions ++= List (" -H:IncludeResources=^semanticdb-.*jar$" ),
184+ nativeImageOptions ++=
185+ List (
186+ " -H:IncludeResources=^semanticdb-.*jar$" ,
187+ s " -H:ReflectionConfigurationFiles= ${target.value / " native-image-configs" / " reflect-config.json" }"
188+ ),
165189 nativeImageOutput := target.in(NativeImage ).value / " lsif-java"
166190 )
167191 .enablePlugins(NativeImagePlugin , BuildInfoPlugin )
168- .dependsOn(plugin)
192+ .dependsOn(lsif)
193+
194+ commands +=
195+ Command .command(" nativeImageProfiled" ) { s =>
196+ val targetroot =
197+ file(" tests/minimized/.j11/target/scala-2.13/meta" ).absolutePath
198+ val output = Files .createTempFile(" lsif-java" , " dump.lsif" )
199+ " minimized/compile" ::
200+ s """ nativeImageRunAgent " index-semanticdb --output= $output $targetroot" """ ::
201+ " nativeImage" :: s
202+ }
169203
170204def minimizedSourceDirectory =
171205 file(" tests/minimized/src/main/java" ).getAbsoluteFile
@@ -264,12 +298,37 @@ lazy val bench = project
264298 .in(file(" tests/benchmarks" ))
265299 .settings(
266300 moduleName := " lsif-java-bench" ,
301+ javaToolchainVersion := " 1.8" ,
267302 fork.in(run) := true ,
268303 skip.in(publish) := true
269304 )
270305 .dependsOn(unit)
271306 .enablePlugins(JmhPlugin )
272307
308+ lazy val docs = project
309+ .in(file(" lsif-java-docs" ))
310+ .settings(
311+ mdocOut :=
312+ baseDirectory.in(ThisBuild ).value / " website" / " target" / " docs" ,
313+ fork := false ,
314+ mdocVariables :=
315+ Map [String , String ](
316+ " VERSION" -> version.value,
317+ " SCALA_VERSION" -> scalaVersion.value,
318+ " STABLE_VERSION" -> version.value.replaceFirst(" \\ -.*" , " " )
319+ )
320+ )
321+ .dependsOn(unit)
322+ .enablePlugins(DocusaurusPlugin )
323+
324+ lazy val javaOnlySettings = List [Def .Setting [_]](
325+ autoScalaLibrary := false ,
326+ incOptions ~= { old =>
327+ old.withEnabled(false )
328+ },
329+ crossPaths := false
330+ )
331+
273332lazy val testSettings = List (
274333 skip.in(publish) := true ,
275334 autoScalaLibrary := true ,
@@ -279,7 +338,6 @@ lazy val testSettings = List(
279338 " org.scalameta" %% " munit" % " 0.7.10" ,
280339 " org.scalameta" %% " moped-testkit" % V .moped,
281340 " org.scalameta" %% " scalameta" % V .scalameta,
282- " org.scala-lang.modules" %% " scala-parallel-collections" % " 1.0.0" ,
283341 " io.get-coursier" %% " coursier" % V .coursier,
284342 " com.lihaoyi" %% " pprint" % " 0.6.1"
285343 )
@@ -334,19 +392,3 @@ lazy val fatjarPackageSettings = List[Def.Setting[_]](
334392 ).transform(node).head
335393 }
336394)
337-
338- lazy val docs = project
339- .in(file(" lsif-java-docs" ))
340- .settings(
341- mdocOut :=
342- baseDirectory.in(ThisBuild ).value / " website" / " target" / " docs" ,
343- fork := false ,
344- mdocVariables :=
345- Map [String , String ](
346- " VERSION" -> version.value,
347- " SCALA_VERSION" -> scalaVersion.value,
348- " STABLE_VERSION" -> version.value.replaceFirst(" \\ -.*" , " " )
349- )
350- )
351- .dependsOn(unit)
352- .enablePlugins(DocusaurusPlugin )
0 commit comments