Skip to content

Commit

Permalink
Automated rollback of commit d54b741.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

Breaks guitar, b/125764428

*** Original change description ***

Stop creating a merged jar in an action in java binary.

The merged jar was used by JacocoCoverageRunner to collect coverage. Since unknown commit JacocoCoverageRunner gets the runtime classpath from the system classloader, so there is no more need for the merged jar.

Progress on #7124.

RELNOTES: None.
PiperOrigin-RevId: 235207828
  • Loading branch information
brandjon authored and copybara-github committed Feb 22, 2019
1 parent 2a1d990 commit 12a11cb
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
import com.google.devtools.build.lib.analysis.actions.LauncherFileWriteAction;
import com.google.devtools.build.lib.analysis.actions.LauncherFileWriteAction.LaunchInfo;
import com.google.devtools.build.lib.analysis.actions.LazyWritePathsFileAction;
import com.google.devtools.build.lib.analysis.actions.Substitution;
import com.google.devtools.build.lib.analysis.actions.Substitution.ComputedSubstitution;
import com.google.devtools.build.lib.analysis.actions.Template;
Expand Down Expand Up @@ -273,7 +274,8 @@ public Artifact createStubAction(
javaStartClass,
"",
NestedSetBuilder.<Artifact>stableOrder(),
javaExecutable);
javaExecutable,
/* createCoverageMetadataJar= */ true);
}

@Override
Expand All @@ -285,7 +287,8 @@ public Artifact createStubAction(
String javaStartClass,
String coverageStartClass,
NestedSetBuilder<Artifact> filesBuilder,
String javaExecutable) {
String javaExecutable,
boolean createCoverageMetadataJar) {
Preconditions.checkState(ruleContext.getConfiguration().hasFragment(JavaConfiguration.class));

Preconditions.checkNotNull(jvmFlags);
Expand Down Expand Up @@ -348,8 +351,30 @@ public Artifact createStubAction(

if (ruleContext.getConfiguration().isCodeCoverageEnabled()
&& ruleContext.getConfiguration().isExperimentalJavaCoverage()) {
// Remove the placeholder in the stub otherwise bazel coverage fails.
arguments.add(Substitution.of(JavaSemantics.JACOCO_METADATA_PLACEHOLDER, ""));
if (createCoverageMetadataJar) {
Artifact runtimeClassPathArtifact =
ruleContext.getUniqueDirectoryArtifact(
"coverage_runtime_classpath",
"runtime-classpath.txt",
ruleContext.getBinOrGenfilesDirectory());
ruleContext.registerAction(
new LazyWritePathsFileAction(
ruleContext.getActionOwner(),
runtimeClassPathArtifact,
javaCommon.getRuntimeClasspath(),
true));
filesBuilder.add(runtimeClassPathArtifact);
arguments.add(
Substitution.of(
JavaSemantics.JACOCO_METADATA_PLACEHOLDER,
"export JACOCO_METADATA_JAR=${JAVA_RUNFILES}/"
+ workspacePrefix
+ "/"
+ runtimeClassPathArtifact.getRootRelativePathString()));
} else {
// Remove the placeholder in the stub otherwise bazel coverage fails.
arguments.add(Substitution.of(JavaSemantics.JACOCO_METADATA_PLACEHOLDER, ""));
}
arguments.add(Substitution.of(
JavaSemantics.JACOCO_MAIN_CLASS_PLACEHOLDER,
"export JACOCO_MAIN_CLASS=" + coverageStartClass));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ public ConfiguredTarget create(RuleContext ruleContext)
mainClass,
originalMainClass,
filesToBuildBuilder,
javaExecutable);
javaExecutable,
/* createCoverageMetadataJar= */ true);

Artifact oneVersionOutputArtifact = null;
JavaConfiguration javaConfig = ruleContext.getFragment(JavaConfiguration.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ public ConfiguredTarget create(RuleContext ruleContext)
mainClass,
originalMainClass,
filesBuilder,
javaExecutable);
javaExecutable,
/* createCoverageMetadataJar= */ false);
if (!executableToRun.equals(executableForRunfiles)) {
filesBuilder.add(executableToRun);
runfilesBuilder.addArtifact(executableToRun);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ public Artifact createStubAction(
String javaStartClass,
String coverageStartClass,
NestedSetBuilder<Artifact> filesBuilder,
String javaExecutable)
String javaExecutable,
boolean createCoverageMetadataJar)
throws InterruptedException;

/**
Expand Down

0 comments on commit 12a11cb

Please sign in to comment.