diff --git a/CHANGELOG.md b/CHANGELOG.md index a3cf7e198..4d0da6d04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ ### Fixes 🛠️ - Collect scalac options from the toolchain | [#433](https://github.com/JetBrains/bazel-bsp/pull/433) +- Add support for Scala SDK provided by rules_jvm_external + | [#403](https://github.com/JetBrains/bazel-bsp/pull/403) ### Performance - Reduce peak memory footprint @@ -42,7 +44,6 @@ - Fixup failed target names from BEP in bazel 6+ in the bloop mode. | [#402](https://github.com/JetBrains/bazel-bsp/pull/402) - ## [2.6.1] ### SECURITY 🚨 diff --git a/server/src/main/java/org/jetbrains/bsp/bazel/server/bep/BepLogger.java b/server/src/main/java/org/jetbrains/bsp/bazel/server/bep/BepLogger.java index 6dc9a06aa..0ed9e5a89 100644 --- a/server/src/main/java/org/jetbrains/bsp/bazel/server/bep/BepLogger.java +++ b/server/src/main/java/org/jetbrains/bsp/bazel/server/bep/BepLogger.java @@ -2,58 +2,58 @@ import ch.epfl.scala.bsp4j.BuildClient; import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos; +import java.time.Duration; +import java.util.Arrays; +import java.util.stream.Collectors; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.bsp.bazel.commons.Format; import org.jetbrains.bsp.bazel.logger.BspClientLogger; -import java.time.Duration; -import java.util.Arrays; -import java.util.stream.Collectors; - public class BepLogger extends BspClientLogger { - private static final Logger LOGGER = LogManager.getLogger(BspClientLogger.class); + private static final Logger LOGGER = LogManager.getLogger(BspClientLogger.class); - private static final String ADDITIONAL_MESSAGE_PREFIX = " "; + private static final String ADDITIONAL_MESSAGE_PREFIX = " "; - private final BspClientLogger bspClientLogger; + private final BspClientLogger bspClientLogger; - public BepLogger(BuildClient client, String originId) { - super(); - bspClientLogger = new BspClientLogger().withOriginId(originId); - bspClientLogger.initialize(client); - } - - private BepLogger(BspClientLogger bspClientLogger) { - super(); - this.bspClientLogger = bspClientLogger; - } + public BepLogger(BuildClient client, String originId) { + super(); + bspClientLogger = new BspClientLogger().withOriginId(originId); + bspClientLogger.initialize(client); + } - @Override - public BepLogger withOriginId(String originId) { - return new BepLogger(super.withOriginId(originId)); - } + private BepLogger(BspClientLogger bspClientLogger) { + super(); + this.bspClientLogger = bspClientLogger; + } - public void onProgress(BuildEventStreamProtos.Progress progress) { - String output = progress.getStderr(); - if (!output.isBlank()) { - logMessage(output); - LOGGER.info(output); - } - } - - public void onBuildMetrics(BuildEventStreamProtos.BuildMetrics metrics) { - // TODO: We potentially might want to obtain more metrics data than just running time - Duration duration = Duration.ofMillis(metrics.getTimingMetrics().getWallTimeInMs()); - logMessage(String.format("Command completed in %s", Format.duration(duration))); - } + @Override + public BepLogger withOriginId(String originId) { + return new BepLogger(super.withOriginId(originId)); + } - private void logMessage(String output) { - bspClientLogger.message(output); - String filteredOutput = Arrays.stream(output.split("\n")) - .filter(element -> !element.startsWith(ADDITIONAL_MESSAGE_PREFIX)) - .collect(Collectors.joining("\n")); - LOGGER.info(filteredOutput); + public void onProgress(BuildEventStreamProtos.Progress progress) { + String output = progress.getStderr(); + if (!output.isBlank()) { + logMessage(output); + LOGGER.info(output); } + } + + public void onBuildMetrics(BuildEventStreamProtos.BuildMetrics metrics) { + // TODO: We potentially might want to obtain more metrics data than just running time + Duration duration = Duration.ofMillis(metrics.getTimingMetrics().getWallTimeInMs()); + logMessage(String.format("Command completed in %s", Format.duration(duration))); + } + + private void logMessage(String output) { + bspClientLogger.message(output); + String filteredOutput = + Arrays.stream(output.split("\n")) + .filter(element -> !element.startsWith(ADDITIONAL_MESSAGE_PREFIX)) + .collect(Collectors.joining("\n")); + LOGGER.info(filteredOutput); + } } diff --git a/server/src/main/java/org/jetbrains/bsp/bazel/server/sync/languages/scala/ScalaSdkResolver.kt b/server/src/main/java/org/jetbrains/bsp/bazel/server/sync/languages/scala/ScalaSdkResolver.kt index ffcc65122..9ea37bea2 100644 --- a/server/src/main/java/org/jetbrains/bsp/bazel/server/sync/languages/scala/ScalaSdkResolver.kt +++ b/server/src/main/java/org/jetbrains/bsp/bazel/server/sync/languages/scala/ScalaSdkResolver.kt @@ -58,6 +58,6 @@ class ScalaSdkResolver(private val bazelPathsResolver: BazelPathsResolver) { 0 } private val VERSION_PATTERN = - Pattern.compile("scala-(?:library|compiler|reflect)-([.\\d]+)\\.jar") + Pattern.compile("(?:processed_)?scala-(?:library|compiler|reflect)-([.\\d]+)\\.jar") } }