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

Commit

Permalink
Add no build flag to aspects
Browse files Browse the repository at this point in the history
  • Loading branch information
SocksDevil committed Apr 15, 2021
1 parent 3364cd1 commit 3fc3f66
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ public enum BazelRunnerFlag {
OUTPUT_PROTO("--output=proto"),
ASPECTS("--aspects"),
NOHOST_DEPS("--nohost_deps"),
NOIMPLICIT_DEPS("--noimplicit_deps");
NOIMPLICIT_DEPS("--noimplicit_deps"),
NOBUILD("--nobuild");

private final String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
import io.grpc.stub.StreamObserver;
import java.io.IOException;
import java.net.URI;
import java.util.Map;
import java.util.Deque;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashMap;
import java.util.Set;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.bsp.bazel.commons.Constants;
Expand Down Expand Up @@ -161,6 +161,7 @@ private void processCompletedEvent(BuildEventStreamProtos.BuildEvent event) {

private void consumeCompletedEvent(BuildEventStreamProtos.TargetComplete targetComplete) {
List<OutputGroup> outputGroups = targetComplete.getOutputGroupList();
LOGGER.info("Consuming target completed event " + targetComplete);
if (outputGroups.size() == 1) {
OutputGroup outputGroup = outputGroups.get(0);
if (outputGroup.getName().equals(Constants.SCALA_COMPILER_CLASSPATH_FILES)) {
Expand All @@ -174,6 +175,7 @@ private void fetchScalaJars(OutputGroup outputGroup) {
.flatMap(fileSetId -> namedSetsOfFiles.get(fileSetId.getId()).getFilesList().stream())
.map(file -> URI.create(file.getUri()))
.flatMap(pathProtoUri -> ClasspathParser.fromAspect(pathProtoUri).stream())
.peek(path -> LOGGER.info("Found path " + path))
.forEach(
path ->
outputGroupPaths
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public Stream<List<String>> fetchLinesFromAspect(String target, String aspect) {
bazelRunner
.commandBuilder()
.build()
.withFlag(BazelRunnerFlag.NOBUILD)
.withFlag(BazelRunnerFlag.ASPECTS, aspect)
.withArgument(target)
.executeBazelCommand()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class BazelBspScalaTargetManager {
private static final Logger LOGGER = LogManager.getLogger(BazelBspScalaTargetManager.class);

public static final String SCALA_LIBRARY =
"@io_bazel_rules_scala_scala_library//:io_bazel_rules_scala_scala_library";
public static final String SCALA_REFLECT =
Expand Down Expand Up @@ -40,6 +44,7 @@ protected Optional<ScalaBuildTarget> getScalaBuildTarget() {
.collect(Collectors.toList());

if (scalaVersions.size() != 1) {
LOGGER.error("Scala versions size different than one: " + scalaVersions.size());
return Optional.empty();
}

Expand Down

0 comments on commit 3fc3f66

Please sign in to comment.