Skip to content

Commit

Permalink
Merge pull request #2199 from tgodzik/avoid-fullclasspath
Browse files Browse the repository at this point in the history
bugfix: Don't use fullclasspath in sbt plugin
  • Loading branch information
tgodzik authored Nov 23, 2023
2 parents fa87d42 + 78e85cd commit a4d4a27
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,8 @@ object BloopDefaults {
val isForkedExecution = (Keys.fork in configuration in forkScopedTask).value
val workingDir = if (isForkedExecution) Keys.baseDirectory.value else rootBaseDirectory
val extraJavaOptions = List(s"-Duser.dir=${workingDir.getAbsolutePath}")
lazy val runtimeClasspath = (Runtime / Keys.fullClasspath).value.map(_.data.toPath()).toList
lazy val runtimeClasspath = BloopKeys.bloopProductDirectories.value.head.toPath() +:
(emulateRuntimeDependencyClasspath).value.map(_.toPath.toAbsolutePath).toList
lazy val javaRuntimeHome = (Runtime / Keys.javaHome).value.map(_.toPath())
lazy val javaRuntimeOptions = (Runtime / Keys.javaOptions).value
val config = Config.JvmConfig(Some(javaHome.toPath), (extraJavaOptions ++ javaOptions).toList)
Expand Down Expand Up @@ -1209,6 +1210,12 @@ object BloopDefaults {
internalClasspath ++ externalClasspath
}

def emulateRuntimeDependencyClasspath: Def.Initialize[Task[Seq[File]]] = Def.task {
val internalClasspath = (Runtime / BloopKeys.bloopInternalClasspath).value.map(_._2)
val externalClasspath = (Runtime / Keys.externalDependencyClasspath).value.map(_.data)
internalClasspath ++ externalClasspath
}

/**
* This task is triggered by `bloopGenerate` and does stuff which is
* sometimes dangerous because it can incur on cyclic dependencies, such as:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import bloop.integrations.sbt.BloopDefaults

name := "non-compiling"

val bloopConfigFile = settingKey[File]("Config file to test")
ThisBuild / bloopConfigFile := {
val bloopDir = Keys.baseDirectory.value./(".bloop")
val config = bloopDir./("non-compiling.json")
config
}

val bloopTestConfigFile = settingKey[File]("Test config file to test")
ThisBuild / bloopTestConfigFile := {
val bloopDir = Keys.baseDirectory.value./(".bloop")
val config = bloopDir./("non-compiling-test.json")
config
}

val checkBloopFiles = taskKey[Unit]("Check bloop file contents")
ThisBuild / checkBloopFiles := {
val configContents = BloopDefaults.unsafeParseConfig(bloopConfigFile.value.toPath)
assert(configContents.project.platform.isDefined)

val configTestContents = BloopDefaults.unsafeParseConfig(bloopTestConfigFile.value.toPath)
assert(configTestContents.project.platform.isDefined)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % sys.props.apply("plugin.version"))
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object Obj {
val a: Int = ""
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
> bloopGenerate
> test:bloopGenerate
> checkBloopFiles

0 comments on commit a4d4a27

Please sign in to comment.