Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

[fix] add support for Scala SDK provided by rules_jvm_external #403

Merged
merged 4 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 🚨
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}