Skip to content

Commit

Permalink
Register JavaCompileActionContext in Bazel.
Browse files Browse the repository at this point in the history
This makes --experimental_java_classpath=bazel work.

This CL is similar to #16636 but applies the code review feedback. (Though, I put the context registration in BazelRulesModule rather than BazelStrategyModule as JavaCompileActionContext isn't really a strategy.)

Fixes #16635.

Closes #16921.

PiperOrigin-RevId: 494950719
Change-Id: Ia32e2d0e67ddacaf18ba52591f7b67b3c6c7b792
  • Loading branch information
benjaminp authored and copybara-github committed Dec 13, 2022
1 parent 990c282 commit ac504cb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@
import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider;
import com.google.devtools.build.lib.bazel.rules.cpp.BazelCppRuleClasses;
import com.google.devtools.build.lib.bazel.rules.sh.BazelShRuleClasses;
import com.google.devtools.build.lib.buildtool.BuildRequest;
import com.google.devtools.build.lib.exec.ModuleActionContextRegistry;
import com.google.devtools.build.lib.remote.options.RemoteOptions;
import com.google.devtools.build.lib.rules.cpp.CcSkyframeFdoSupportFunction;
import com.google.devtools.build.lib.rules.cpp.CcSkyframeFdoSupportValue;
import com.google.devtools.build.lib.rules.cpp.CppOptions;
import com.google.devtools.build.lib.rules.java.JavaCompileActionContext;
import com.google.devtools.build.lib.rules.java.JavaOptions;
import com.google.devtools.build.lib.runtime.BlazeModule;
import com.google.devtools.build.lib.runtime.BlazeRuntime;
Expand Down Expand Up @@ -523,6 +526,14 @@ public Iterable<Class<? extends OptionsBase>> getCommandOptions(Command command)
: ImmutableList.of(AllCommandGraveyardOptions.class);
}

@Override
public void registerActionContexts(
ModuleActionContextRegistry.Builder registryBuilder,
CommandEnvironment env,
BuildRequest buildRequest) {
registryBuilder.register(JavaCompileActionContext.class, new JavaCompileActionContext());
}

private static void validateRemoteOutputsMode(CommandEnvironment env) throws AbruptExitException {
RemoteOptions remoteOptions = env.getOptions().getOptions(RemoteOptions.class);
if (remoteOptions == null) {
Expand Down
6 changes: 6 additions & 0 deletions src/test/shell/bazel/bazel_java_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,12 @@ function test_build_hello_world() {
bazel build //java/main:main &> $TEST_log || fail "build failed"
}

function test_build_hello_world_reduced_classpath() {
write_hello_library_files

bazel build --experimental_java_classpath=bazel //java/main:main &> $TEST_log || fail "build failed"
}

function test_worker_strategy_is_default() {
write_hello_library_files

Expand Down

0 comments on commit ac504cb

Please sign in to comment.