Merge pull request #403 from alexarchambault/fix-lmcoursier-jni

Ensure lmcoursier can load jniutils stuff fine on Windows
This commit is contained in:
Alexandre Archambault 2022-08-15 19:27:09 +02:00 committed by GitHub
commit 4d7c64febe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 3 deletions

View File

@ -28,7 +28,7 @@ jobs:
fetch-depth: 0
submodules: true
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1
- uses: coursier/setup-action@v1.2.1
with:
jvm: 8
apps: sbt
@ -48,7 +48,7 @@ jobs:
fetch-depth: 0
submodules: true
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1
- uses: coursier/setup-action@v1.2.1
with:
jvm: 8
apps: sbt

View File

@ -66,6 +66,10 @@ lazy val definitions = project
dontPublish,
)
// FIXME Ideally, we should depend on the same version of io.get-coursier.jniutils:windows-jni-utils that
// io.get-coursier::coursier depends on.
val jniUtilsVersion = "0.3.3"
lazy val `lm-coursier` = project
.in(file("modules/lm-coursier"))
.settings(
@ -75,6 +79,7 @@ lazy val `lm-coursier` = project
Mima.lmCoursierFilters,
libraryDependencies ++= Seq(
"io.get-coursier" %% "coursier" % coursierVersion0,
"io.get-coursier.jniutils" % "windows-jni-utils-lmcoursier" % jniUtilsVersion,
"net.hamnaberg" %% "dataclass-annotation" % dataclassScalafixV % Provided,
// We depend on librarymanagement-ivy rather than just
// librarymanagement-core to handle the ModuleDescriptor passed
@ -106,7 +111,10 @@ lazy val `lm-coursier-shaded` = project
Mima.lmCoursierFilters,
Mima.lmCoursierShadedFilters,
Compile / sources := (`lm-coursier` / Compile / sources).value,
shadedModules += "io.get-coursier" %% "coursier",
shadedModules ++= Set(
"io.get-coursier" %% "coursier",
"io.get-coursier.jniutils" % "windows-jni-utils-lmcoursier"
),
validNamespaces += "lmcoursier",
validEntries ++= Set(
// FIXME Ideally, we should just strip those from the resulting JAR…
@ -139,6 +147,7 @@ lazy val `lm-coursier-shaded` = project
},
libraryDependencies ++= Seq(
"io.get-coursier" %% "coursier" % coursierVersion0,
"io.get-coursier.jniutils" % "windows-jni-utils-lmcoursier" % jniUtilsVersion,
"net.hamnaberg" %% "dataclass-annotation" % dataclassScalafixV % Provided,
"org.scala-lang.modules" %% "scala-collection-compat" % "2.8.1",
"org.scala-lang.modules" %% "scala-xml" % "1.3.0", // depending on that one so that it doesn't get shaded

View File

@ -1,6 +1,15 @@
#!/usr/bin/env bash
set -euvx
# Force the use of coursier JNI stuff on Windows, which ought to work fine.
# JNI stuff is used to compute the default cache location on Windows (to get the AppData local
# dir, or something like this, via native Windows APIs).
# Without this, if ever coursier fails to load its JNI library on Windows, it falls back
# to using some powershell scripts (via dirs-dev/directories-jvm), which are often a problem,
# see sbt/sbt#5206.
# Enable this once sbt uses the upcoming lm-coursier-shaded version (> 2.0.10-1)
# export COURSIER_JNI="force"
if [ "$(expr substr $(uname -s) 1 5 2>/dev/null)" == "Linux" ]; then
SBT="sbt"
elif [ "$(uname)" == "Darwin" ]; then