Skip to content

Commit 915412d

Browse files
Merge pull request #48 from scala-cli/merge-upstream
Merge upstream changes
2 parents a4ddcf9 + 65a60ec commit 915412d

File tree

16 files changed

+169
-33
lines changed

16 files changed

+169
-33
lines changed

backend/src/main/scala/bloop/Compiler.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,11 @@ object Compiler {
336336
val start = System.nanoTime()
337337
val scalaInstance = compileInputs.scalaInstance
338338
val classpathOptions = compileInputs.classpathOptions
339-
val compilers = compileInputs.compilerCache.get(scalaInstance, compileInputs.javacBin)
339+
val compilers = compileInputs.compilerCache.get(
340+
scalaInstance,
341+
compileInputs.javacBin,
342+
compileInputs.javacOptions.toList
343+
)
340344
val inputs = tracer.traceVerbose("creating zinc inputs")(_ => getInputs(compilers))
341345

342346
// We don't need nanosecond granularity, we're happy with milliseconds

backend/src/main/scala/bloop/CompilerCache.scala

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,18 @@ final class CompilerCache(
5757
private val javaCompilerCache =
5858
userJavacCache.getOrElse(new ConcurrentHashMap[Option[AbsolutePath], JavaCompiler]())
5959

60-
def get(scalaInstance: ScalaInstance, javacBin: Option[AbsolutePath]): Compilers = {
60+
def get(
61+
scalaInstance: ScalaInstance,
62+
javacBin: Option[AbsolutePath],
63+
javacOptions: List[String]
64+
): Compilers = {
6165
val scalaCompiler = scalaCompilerCache.computeIfAbsent(
6266
scalaInstance,
6367
getScalaCompiler(_, componentProvider)
6468
)
6569

66-
val javaCompiler = javaCompilerCache.computeIfAbsent(javacBin, getJavaCompiler(logger, _))
70+
val javaCompiler =
71+
javaCompilerCache.computeIfAbsent(javacBin, getJavaCompiler(logger, _, javacOptions))
6772

6873
val javaDoc = Javadoc.local.getOrElse(Javadoc.fork())
6974
val javaTools = JavaTools(javaCompiler, javaDoc)
@@ -82,19 +87,25 @@ final class CompilerCache(
8287
)
8388
}
8489

85-
def getJavaCompiler(logger: Logger, javacBin: Option[AbsolutePath]): JavaCompiler = {
90+
def getJavaCompiler(
91+
logger: Logger,
92+
javacBin: Option[AbsolutePath],
93+
javacOptions: List[String]
94+
): JavaCompiler = {
95+
val allowLocal = !javacOptions.exists(_.startsWith("-J"))
8696
javacBin match {
8797
case Some(bin) if JavaRuntime.javac.exists(isSameCompiler(logger, _, bin)) =>
8898
// Same bin as the one derived from this VM? Prefer built-in compiler if JDK
8999
JavaRuntime.javaCompiler match {
90-
case Some(compiler) => new BloopMaybeForkedJavaCompiler(compiler, Some(bin.toFile))
91-
case None => new BloopForkedJavaCompiler(Some(bin.toFile))
100+
case Some(compiler) if allowLocal =>
101+
new BloopMaybeForkedJavaCompiler(compiler, Some(bin.toFile))
102+
case _ => new BloopForkedJavaCompiler(Some(bin.toFile))
92103
}
93104
case Some(bin) => new BloopForkedJavaCompiler(Some(bin.toFile))
94105
case None =>
95106
JavaRuntime.javaCompiler match {
96-
case Some(compiler) => new BloopMaybeForkedJavaCompiler(compiler, None)
97-
case None => new BloopForkedJavaCompiler(None)
107+
case Some(compiler) if allowLocal => new BloopMaybeForkedJavaCompiler(compiler, None)
108+
case _ => new BloopForkedJavaCompiler(None)
98109
}
99110
}
100111
}

build.sbt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ lazy val `bloopgun-core` = project
224224
buildInfoPackage := "bloopgun.internal.build",
225225
buildInfoKeys := List(version),
226226
buildInfoObject := "BloopgunInfo",
227+
crossScalaVersions := Seq(Dependencies.Scala212Version, Dependencies.Scala213Version),
227228
libraryDependencies ++= List(
228229
Dependencies.snailgun,
229230
// Use zt-exec instead of nuprocess because it doesn't require JNA (good for graalvm)
@@ -277,11 +278,20 @@ lazy val bloopgun = project
277278
)
278279

279280
lazy val launcher = project
280-
.dependsOn(`bloopgun-core`, frontend % "test->test")
281-
.settings(testSuiteSettings)
281+
.dependsOn(`bloopgun-core`)
282282
.settings(
283283
sonatypeSetting,
284284
name := "bloop-launcher",
285+
crossScalaVersions := Seq(Dependencies.Scala212Version, Dependencies.Scala213Version)
286+
)
287+
288+
lazy val launcherTest: Project = project
289+
.in(file("launcher-test"))
290+
.disablePlugins(ScriptedPlugin)
291+
.dependsOn(`bloopgun-core`, frontend % "test->test", launcher)
292+
.settings(testSuiteSettings)
293+
.settings(
294+
name := "bloop-launcher-test",
285295
fork in Test := true,
286296
parallelExecution in Test := false,
287297
libraryDependencies ++= List(
@@ -350,6 +360,7 @@ lazy val stuff = project
350360
frontend,
351361
backend,
352362
launcher,
363+
launcherTest,
353364
bloopgun,
354365
`bloopgun-core`,
355366
shared,

docs/build-tools/sbt.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ Here's a list of bloop commands you can run next to start playing with bloop:
8888

8989
## Next steps after installation
9090

91-
Use an IDE such as [Metals](docs/ides/metals) or
92-
[IntelliJ](docs/ides/intellij) to write code or play with the
93-
[CLI](docs/cli/tutorial) if you want to explore what CLI options are
91+
Use an IDE such as [Metals](/bloop/docs/ides/metals) or
92+
[IntelliJ](/bloop/docs/ides/intellij) to write code or play with the
93+
[CLI](/bloop/docs/cli/tutorial) if you want to explore what CLI options are
9494
available.
9595

9696
If you need help, you can always come over to our [Discord

frontend/src/main/scala/bloop/data/Project.scala

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,15 @@ final case class Project(
251251
getJavaVersionFromJavaHome(f.javaHome)
252252
)
253253
.getOrElse(Properties.javaVersion)
254-
255-
compareVersions(compileVersion, version) >= 0
254+
.split("-")
255+
.head // needed for versions like 17-ea
256+
try {
257+
compareVersions(compileVersion, version) >= 0
258+
} catch {
259+
case NonFatal(_) =>
260+
logger.error(s"Invalid Java number $compileVersion")
261+
false
262+
}
256263
}
257264
}
258265

frontend/src/main/scala/bloop/engine/tasks/Tasks.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ object Tasks {
6464
val javacBin = project.runtimeJdkConfig.flatMap(_.javacBin)
6565
val loader = ClasspathUtilities.makeLoader(entries, instance)
6666
val compiler =
67-
state.compilerCache.get(instance, javacBin).scalac.asInstanceOf[AnalyzingCompiler]
67+
state.compilerCache
68+
.get(instance, javacBin, project.javacOptions)
69+
.scalac
70+
.asInstanceOf[AnalyzingCompiler]
6871
val opts = ClasspathOptionsUtil.repl
6972
val options = project.scalacOptions :+ "-Xnojline"
7073
// We should by all means add better error handling here!

frontend/src/test/scala/bloop/ScalaVersionsSpec.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ object ScalaVersionsSpec extends bloop.testing.BaseSuite {
7373
val `2.13` = compileProjectFor("2.13.2")
7474
val `2.13.3` = compileProjectFor("2.13.3")
7575
val `2.13.7` = compileProjectFor("2.13.7")
76+
val `2.13.8` = compileProjectFor("2.13.8")
7677
val LatestDotty = compileProjectFor("3.0.0-M3")
7778
val all = List(`2.12`, `2.13`, `2.13.3`, `2.13.7`)
7879

frontend/src/test/scala/bloop/dap/DebugAdapterConnection.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ private[dap] final class DebugAdapterConnection(
152152
object DebugAdapterConnection {
153153
def connectTo(uri: URI)(scheduler: Scheduler): DebugAdapterConnection = {
154154
val socket = new Socket()
155-
socket.connect(new InetSocketAddress(uri.getHost, uri.getPort), 500)
155+
socket.connect(new InetSocketAddress(uri.getHost, uri.getPort), 10000)
156156

157157
val proxy = DebugAdapterProxy(socket)
158158
proxy.startBackgroundListening(scheduler)

frontend/src/test/scala/bloop/dap/DebugServerSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ object DebugServerSpec extends DebugBspBaseSuite {
478478
assert(debuggeeCanceled, serverClosed)
479479
}
480480

481-
TestUtil.await(FiniteDuration(5, SECONDS), ExecutionContext.ioScheduler)(test)
481+
TestUtil.await(FiniteDuration(20, SECONDS), ExecutionContext.ioScheduler)(test)
482482
}
483483
}
484484

0 commit comments

Comments
 (0)