diff --git a/build.sbt b/build.sbt index d71af8232..3fd188145 100644 --- a/build.sbt +++ b/build.sbt @@ -217,6 +217,7 @@ lazy val cliSettings = Seq( Dependencies.coursier, Dependencies.coursierJvm, Dependencies.dependency, + Dependencies.directoriesJni, Dependencies.jsoniterCore, Dependencies.svm % Provided, Dependencies.jsoniterMacros % Provided diff --git a/cli/src/main/scala/bloop/cli/Directories.scala b/cli/src/main/scala/bloop/cli/Directories.scala index 715397ea3..5b652455f 100644 --- a/cli/src/main/scala/bloop/cli/Directories.scala +++ b/cli/src/main/scala/bloop/cli/Directories.scala @@ -1,7 +1,8 @@ package bloop.cli -import bloop.cli.util.JniGetWinDirs -import coursier.cache.shaded.dirs.{GetWinDirs, ProjectDirectories} +import dev.dirs.ProjectDirectories +import dev.dirs.impl.Windows; +import dev.dirs.jni.WindowsJni; import scala.util.Properties @@ -31,11 +32,11 @@ object Directories { } def default(): Directories = { - val getWinDirs: GetWinDirs = + val getWinDirs = if (coursier.paths.Util.useJni()) - new JniGetWinDirs + WindowsJni.getJdkAwareSupplier(); else - GetWinDirs.powerShellBased + Windows.getDefaultSupplier(); OsLocations(ProjectDirectories.from(null, null, "ScalaCli", getWinDirs)) } diff --git a/cli/src/main/scala/bloop/cli/util/JniGetWinDirs.java b/cli/src/main/scala/bloop/cli/util/JniGetWinDirs.java deleted file mode 100644 index 3924de721..000000000 --- a/cli/src/main/scala/bloop/cli/util/JniGetWinDirs.java +++ /dev/null @@ -1,18 +0,0 @@ -package bloop.cli.util; - -import java.util.ArrayList; - -import coursier.cache.shaded.dirs.GetWinDirs; -import coursier.jniutils.WindowsKnownFolders; - -// has to be written in Java, in order to override a Java var-args method... -public class JniGetWinDirs implements GetWinDirs { - @Override - public String[] getWinDirs(String... guids) { - ArrayList list = new ArrayList<>(); - for (int i = 0; i < guids.length; i++) { - list.add(WindowsKnownFolders.knownFolderPath("{" + guids[i] + "}")); - } - return list.toArray(new String[list.size()]); - } -} diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 184b33d01..08299342f 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -20,7 +20,7 @@ object Dependencies { val lmVersion = "1.10.3" val configDirsVersion = "26" val caseAppVersion = "2.0.6" - val coursierVersion = "2.1.23" + val coursierVersion = "2.1.24" val sourcecodeVersion = "0.4.2" val sbtTestInterfaceVersion = "1.0" val sbtTestAgentVersion = "1.10.7" @@ -63,6 +63,7 @@ object Dependencies { val coursier = "io.get-coursier" %% "coursier" % coursierVersion val coursierJvm = "io.get-coursier" %% "coursier-jvm" % coursierVersion val dependency = "io.get-coursier" %% "dependency" % "0.3.2" + val directoriesJni = "io.get-coursier.util" % "directories-jni" % "0.1.3" val scalaCollectionCompat = "org.scala-lang.modules" %% "scala-collection-compat" % "2.12.0" val shapeless = "com.chuusai" %% "shapeless" % shapelessVersion val caseApp = "com.github.alexarchambault" %% "case-app" % caseAppVersion