Skip to content

Commit

Permalink
refactor: Switch to original fork of Bloop
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik committed Jul 11, 2024
1 parent b9412e2 commit dd68843
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 21 deletions.
8 changes: 8 additions & 0 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,14 @@ trait Core extends ScalaCliCrossSbtModule
super.scalacOptions() ++ asyncScalacOptions(crossScalaVersion)
}

import coursier.maven.MavenRepository

def repositoriesTask = T.task {
super.repositoriesTask() ++ Seq(
MavenRepository("https://oss.sonatype.org/content/repositories/snapshots")
)
}

def ivyDeps = super.ivyDeps() ++ Agg(
Deps.bloopRifle.exclude(("org.scala-lang.modules", "scala-collection-compat_2.13")),
Deps.collectionCompat,
Expand Down
2 changes: 1 addition & 1 deletion gcbenchmark/gcbenchmark.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ object Main {

def bloopPid: Option[Int] = {
val processes = os.proc("jps", "-l").call().out.text()
"(\\d+) bloop[.]Bloop".r
"(\\d+) bloop[.]Server".r
.findFirstMatchIn(processes)
.map(_.group(1).toInt)
}
Expand Down
19 changes: 9 additions & 10 deletions modules/build/src/main/scala/scala/build/Bloop.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ object Bloop {
val res = value {
Artifacts.artifacts(
Seq(Positioned.none(dep)),
Nil,
// TODO remove after bloop available on maven central
Seq(coursier.Repositories.sonatype("snapshots")),
Some(params),
logger,
cache.withMessage(s"Downloading compilation server ${dep.version}")
Expand All @@ -85,25 +86,23 @@ object Bloop {
def bloopClassPath(
logger: Logger,
cache: FileCache[Task]
): Either[BuildException, (Seq[File], Boolean)] =
): Either[BuildException, Seq[File]] =
bloopClassPath(logger, cache, BloopRifleConfig.defaultVersion)

def bloopClassPath(
logger: Logger,
cache: FileCache[Task],
bloopVersion: String
): Either[BuildException, (Seq[File], Boolean)] = either {
): Either[BuildException, Seq[File]] = either {
val moduleStr = BloopRifleConfig.defaultModule
val mod = value {
ModuleParser.parse(moduleStr)
.left.map(err => new ModuleFormatError(moduleStr, err, Some("Bloop")))
}
val dep = DependencyLike(mod, bloopVersion)
val sv = BloopRifleConfig.defaultScalaVersion
val sbv = ScalaVersion.binary(sv)
val params = ScalaParameters(sv, sbv)
val cp = value(bloopClassPath(dep, params, logger, cache))
val isScalaCliBloop = moduleStr.startsWith(BloopRifleConfig.scalaCliBloopOrg + ":")
(cp, isScalaCliBloop)
val dep = DependencyLike(mod, bloopVersion)
val sv = BloopRifleConfig.defaultScalaVersion
val sbv = ScalaVersion.binary(sv)
val params = ScalaParameters(sv, sbv)
value(bloopClassPath(dep, params, logger, cache))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class BspServer(
val res = new b.InitializeBuildResult(
"scala-cli",
Constants.version,
bloop.rifle.internal.Constants.bspVersion,
bloop.rifle.internal.BuildInfo.bspVersion,
capabilities
)
val buildComesFromIntelliJ = params.getDisplayName.toLowerCase.contains("intellij")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ case class TestLogger(info: Boolean = true, debug: Boolean = false) extends Logg
def bloopBspStdout: Option[java.io.OutputStream] = Some(System.out)
def bloopCliInheritStderr: Boolean = true
def bloopCliInheritStdout: Boolean = true
def debug(msg: => String): Unit = {
System.err.println(msg)
}
def debug(msg: => String, ex: Throwable): Unit = {
System.err.println(msg)
if (ex != null) ex.printStackTrace(System.err)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package scala.cli.commands.bloop

import bloop.rifle.internal.{Constants, Operations}
import bloop.rifle.internal.Operations
import bloop.rifle.{BloopRifle, BloopRifleConfig, BloopThreads}
import caseapp.core.RemainingArgs

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package scala.cli.commands.bloop

import bloop.rifle.internal.Constants
import bloop.rifle.internal.BuildInfo
import bloop.rifle.{BloopRifle, BloopRifleConfig, BloopThreads}
import caseapp.*

Expand Down Expand Up @@ -64,7 +64,7 @@ object BloopStart extends ScalaCommand[BloopStartOptions] {
bloopRifleConfig,
threads.startServerChecks,
logger.bloopRifleLogger,
Constants.bloopVersion,
BuildInfo.version,
bloopRifleConfig.javaPath
)
Await.result(f, Duration.Inf)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ object SetupIde extends ScalaCommand[SetupIdeOptions] {
bspName,
bspArgs.asJava,
Constants.version,
bloop.rifle.internal.Constants.bspVersion,
bloop.rifle.internal.BuildInfo.bspVersion,
List("scala", "java").asJava
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package scala.cli.commands.shared

import bloop.rifle.internal.Constants
import bloop.rifle.internal.BuildInfo
import bloop.rifle.{BloopRifleConfig, BloopVersion, BspConnectionAddress}
import caseapp.*
import com.github.plokhotnyuk.jsoniter_scala.core.*
Expand Down Expand Up @@ -192,7 +192,7 @@ final case class SharedCompilationServerOptions(
.map(_.trim)
.filter(_.nonEmpty)
.fold[BloopRifleConfig.BloopVersionConstraint](BloopRifleConfig.AtLeast(
BloopVersion(Constants.bloopVersion)
BloopVersion(BuildInfo.version)
))(v => BloopRifleConfig.Strict(BloopVersion(v)))

def bloopDefaultJvmOptions(logger: Logger): Option[List[String]] = {
Expand Down
2 changes: 2 additions & 0 deletions modules/cli/src/main/scala/scala/cli/internal/CliLogger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ class CliLogger(
def bloopRifleLogger =
new BloopRifleLogger {
def info(msg: => String) = logger.message(msg)
def debug(msg: => String) =
if (verbosity >= 3) logger.debug(msg)
def debug(msg: => String, ex: Throwable) =
if (verbosity >= 3) {
logger.debug(msg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class BloopTests extends ScalaCliSuite {
test("bloop exit works") {
def bloopRunning(): Boolean = {
val javaProcesses = os.proc("jps", "-l").call().out.text()
javaProcesses.contains("bloop.Bloop")
javaProcesses.contains("bloop.Server")
}

val inputs = TestInputs.empty
Expand Down
4 changes: 2 additions & 2 deletions project/deps.sc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ object Deps {
def signingCli = "0.2.3"
def signingCliJvmVersion = 17
def javaClassName = "0.1.3"
def bloop = "1.5.17-sc-2"
def bloop = "1.6.0-11-8092d595-SNAPSHOT"
}
// DO NOT hardcode a Scala version in this dependency string
// This dependency is used to ensure that Ammonite is available for Scala versions
Expand All @@ -120,7 +120,7 @@ object Deps {
// Force using of 2.13 - is there a better way?
def bloopConfig = ivy"ch.epfl.scala:bloop-config_2.13:2.0.2"
.exclude(("com.github.plokhotnyuk.jsoniter-scala", "jsoniter-scala-core_2.13"))
def bloopRifle = ivy"io.github.alexarchambault.bleep:bloop-rifle_2.13:${Versions.bloop}"
def bloopRifle = ivy"ch.epfl.scala:bloop-rifle_2.13:${Versions.bloop}"
def bsp4j = ivy"ch.epfl.scala:bsp4j:2.1.1"
def caseApp = ivy"com.github.alexarchambault::case-app:2.1.0-M28"
def collectionCompat = ivy"org.scala-lang.modules::scala-collection-compat:2.12.0"
Expand Down

0 comments on commit dd68843

Please sign in to comment.