Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bin/coursier
Binary file not shown.
16 changes: 4 additions & 12 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import scala.util.control.NoStackTrace

lazy val V =
new {
val protobuf = "3.15.6"
val protobuf = "3.21.4"
val coursier = "2.0.8"
val bloop = "1.4.7"
val bsp = "2.0.0-M13"
Expand Down Expand Up @@ -37,6 +37,7 @@ inThisBuild(
organization := "com.sourcegraph",
homepage := Some(url("https://github.com/sourcegraph/scip-java")),
dynverSeparator := "-",
PB.protocVersion := V.protobuf,
licenses :=
List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
developers :=
Expand Down Expand Up @@ -239,14 +240,7 @@ lazy val cli = project
// Pre-download Java 8, 11 and 17.
run("coursier", "java-home", "--jvm", "8")
run("coursier", "java-home", "--jvm", "11")
run(
"coursier",
"java-home",
"--jvm",
"temurin:17",
"--jvm-index",
"https://github.com/coursier/jvm-index/blob/master/index.json"
)
run("coursier", "java-home", "--jvm", "17")

// Install `scip-java` binary.
add(script, "/usr/local/bin/scip-java")
Expand Down Expand Up @@ -332,9 +326,7 @@ lazy val minimized17 = project
.in(file("tests/minimized/.j17"))
.settings(
minimizedSettings,
javaToolchainJvmIndex :=
Some("https://github.com/coursier/jvm-index/blob/master/index.json"),
javaToolchainVersion := "temurin:17",
javaToolchainVersion := "17",
javacOptions ++= javacModuleOptions
)
.dependsOn(agent, plugin)
Expand Down
27 changes: 24 additions & 3 deletions project/JavaToolchainPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ object JavaToolchainPlugin extends AutoPlugin {
// The tools.jar file includes the bytecode for the Java compiler in the com.sun.source package.
// The Java compiler is available by default in Java 9+, so we only need to add tools.jar to the
// bootclasspath for Java 8.
if (home.toString.contains("1.8") && toolsJar.isFile) {
if (version == "8" && toolsJar.isFile) {
List(s"-Xbootclasspath/p:$toolsJar")
} else {
List()
Expand All @@ -92,10 +92,31 @@ object JavaToolchainPlugin extends AutoPlugin {
.toList
.flatMap(index => "--jvm-index" :: index :: Nil)
val arguments =
List("java", "-jar", coursier.toString, "java-home", "--jvm", v) ++
index
List(
"java",
"-jar",
coursier.toString,
"java-home",
"--jvm",
v,
"--architecture",
jvmArchitecture(v)
) ++ index
new File(Process(arguments).!!.trim)
}
)
}

private def jvmArchitecture(jvmVersion: String): String =
if (scala.util.Properties.isMac && sys.props("os.arch") == "aarch64")
"amd64"
else
defaultCoursierJVMArchitecture
def defaultCoursierJVMArchitecture: String =
sys.props("os.arch") match {
case "x86_64" =>
"amd64"
case x =>
x
}
}
Binary file modified scip-java/src/main/resources/scip-java/coursier
100644 → 100755
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,8 @@ class ScipBuildTool(index: IndexCommand) extends BuildTool("SCIP", index) {
"java-home",
"--jvm",
config.jvm,
"--jvm-index",
"https://github.com/coursier/jvm-index/blob/master/index.json"
"--architecture",
jvmArchitecture
)
.call()
.out
Expand Down Expand Up @@ -532,6 +532,19 @@ class ScipBuildTool(index: IndexCommand) extends BuildTool("SCIP", index) {
Failure(SubprocessException(result))
}

private def jvmArchitecture: String =
if (scala.util.Properties.isMac && sys.props("os.arch") == "aarch64")
"amd64"
else
defaultCoursierJVMArchitecture
def defaultCoursierJVMArchitecture: String =
sys.props("os.arch") match {
case "x86_64" =>
"amd64"
case x =>
x
}

private def clean(): Unit = {
Files.walkFileTree(targetroot, new DeleteVisitor)
}
Expand Down