aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java
diff options
context:
space:
mode:
authorGravatar tomlu <tomlu@google.com>2018-05-25 09:39:02 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-05-25 09:40:50 -0700
commit445a633b64d7587c5a21dec5b340c24840a26c67 (patch)
tree64eaf6dc50bfab712ccb647f420d2d0b4a7039c4 /src/main/java
parent780801c87227754fac166ec54d6f5f52c40fee35 (diff)
Remove java support from proto_library.
This is a rollforward of CL/197725926 after depot fix. NEW: Additional deletions of unused providers (no constructor call references). NEW[last rollforward]: Allow java_* rules to depend on proto_libraries via runtime_deps and exports. This should avoid the breakage that caused the original rollback. The edges are no-ops and could be removed. PiperOrigin-RevId: 198060345
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/BUILD5
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java5
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/java/JavaCommon.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/java/JavaInfo.java6
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/java/JavaLibrary.java12
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java3
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/java/ProtoJavaApiInfoAspectProvider.java73
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/java/ProtoJavaApiInfoProvider.java192
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/java/proto/ActionReuser.java123
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoLibrary.java8
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoAspect.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoLibrary.java7
12 files changed, 0 insertions, 440 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/BUILD b/src/main/java/com/google/devtools/build/lib/BUILD
index cd45a4c42a..495f3646e0 100644
--- a/src/main/java/com/google/devtools/build/lib/BUILD
+++ b/src/main/java/com/google/devtools/build/lib/BUILD
@@ -913,9 +913,6 @@ java_library(
"rules/java/ProguardLibrary.java",
"rules/java/ProguardLibraryRule.java",
"rules/java/ProguardSpecProvider.java",
- "rules/java/ProtoJavaApiInfoAspectProvider.java",
- "rules/java/ProtoJavaApiInfoProvider.java",
- "rules/java/proto/ActionReuser.java",
"rules/java/proto/JavaLiteProtoAspect.java",
"rules/java/proto/JavaLiteProtoLibrary.java",
"rules/java/proto/JavaProtoAspect.java",
@@ -1013,8 +1010,6 @@ java_library(
"rules/java/MessageBundleInfo.java",
"rules/java/NativeLibraryNestedSetBuilder.java",
"rules/java/OneVersionCheckActionBuilder.java",
- "rules/java/ProtoJavaApiInfoAspectProvider.java",
- "rules/java/ProtoJavaApiInfoProvider.java",
"rules/java/ResourceJarActionBuilder.java",
"rules/java/SingleJarActionBuilder.java",
"rules/java/WriteBuildInfoPropertiesAction.java",
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java
index 4d95e44430..a634a10eed 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java
@@ -74,7 +74,6 @@ import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.PathFragment;
import java.io.File;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
import javax.annotation.Nullable;
@@ -120,10 +119,6 @@ public class BazelJavaSemantics implements JavaSemantics {
public void checkForProtoLibraryAndJavaProtoLibraryOnSameProto(
RuleContext ruleContext, JavaCommon javaCommon) {}
- @Override
- public void checkProtoDeps(
- RuleContext ruleContext, Collection<? extends TransitiveInfoCollection> deps) {}
-
private static final String JUNIT4_RUNNER = "org.junit.runner.JUnitCore";
@Nullable
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCommon.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCommon.java
index a7d80cc300..66f584428a 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCommon.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCommon.java
@@ -627,8 +627,6 @@ public class JavaCommon {
javaTargetAttributes.addSourceArtifacts(extraSrcs);
processRuntimeDeps(javaTargetAttributes);
- semantics.checkProtoDeps(ruleContext, targetsTreatedAsDeps(ClasspathType.BOTH));
-
if (disallowDepsWithoutSrcs(ruleContext.getRule().getRuleClass())
&& ruleContext.attributes().get("srcs", BuildType.LABEL_LIST).isEmpty()
&& ruleContext.getRule().isAttributeValueExplicitlySpecified("deps")) {
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaInfo.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaInfo.java
index a840c8845c..ee42606122 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaInfo.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaInfo.java
@@ -82,7 +82,6 @@ public final class JavaInfo extends NativeInfo {
ImmutableSet.of(
JavaCompilationArgsProvider.class,
JavaSourceJarsProvider.class,
- ProtoJavaApiInfoAspectProvider.class,
JavaRuleOutputJarsProvider.class,
JavaRunfilesProvider.class,
JavaPluginInfoProvider.class,
@@ -132,8 +131,6 @@ public final class JavaInfo extends NativeInfo {
JavaInfo.fetchProvidersFromList(providers, JavaCompilationArgsProvider.class);
List<JavaSourceJarsProvider> javaSourceJarsProviders =
JavaInfo.fetchProvidersFromList(providers, JavaSourceJarsProvider.class);
- List<ProtoJavaApiInfoAspectProvider> protoJavaApiInfoAspectProviders =
- JavaInfo.fetchProvidersFromList(providers, ProtoJavaApiInfoAspectProvider.class);
List<JavaRunfilesProvider> javaRunfilesProviders =
JavaInfo.fetchProvidersFromList(providers, JavaRunfilesProvider.class);
List<JavaPluginInfoProvider> javaPluginInfoProviders =
@@ -154,9 +151,6 @@ public final class JavaInfo extends NativeInfo {
JavaCompilationArgsProvider.merge(javaCompilationArgsProviders))
.addProvider(
JavaSourceJarsProvider.class, JavaSourceJarsProvider.merge(javaSourceJarsProviders))
- .addProvider(
- ProtoJavaApiInfoAspectProvider.class,
- ProtoJavaApiInfoAspectProvider.merge(protoJavaApiInfoAspectProviders))
// When a rule merges multiple JavaProviders, its purpose is to pass on information, so
// it doesn't have any output jars.
.addProvider(JavaRuleOutputJarsProvider.class, JavaRuleOutputJarsProvider.builder().build())
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibrary.java
index 3a92282782..279a3f71da 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibrary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibrary.java
@@ -22,7 +22,6 @@ import com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder;
import com.google.devtools.build.lib.analysis.RuleConfiguredTargetFactory;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.RunfilesProvider;
-import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.rules.cpp.LinkerInput;
@@ -172,16 +171,6 @@ public class JavaLibrary implements RuleConfiguredTargetFactory {
NestedSet<LinkerInput> transitiveJavaNativeLibraries =
common.collectTransitiveJavaNativeLibraries();
- ProtoJavaApiInfoAspectProvider.Builder protoAspectBuilder =
- ProtoJavaApiInfoAspectProvider.builder();
- for (TransitiveInfoCollection dep : common.getDependencies()) {
- ProtoJavaApiInfoAspectProvider protoProvider =
- JavaInfo.getProvider(ProtoJavaApiInfoAspectProvider.class, dep);
- if (protoProvider != null) {
- protoAspectBuilder.addTransitive(protoProvider);
- }
- }
-
RuleConfiguredTargetBuilder builder =
new RuleConfiguredTargetBuilder(ruleContext);
@@ -215,7 +204,6 @@ public class JavaLibrary implements RuleConfiguredTargetFactory {
JavaInfo javaInfo = javaInfoBuilder
.addProvider(JavaCompilationArgsProvider.class, compilationArgsProvider)
.addProvider(JavaSourceJarsProvider.class, sourceJarsProvider)
- .addProvider(ProtoJavaApiInfoAspectProvider.class, protoAspectBuilder.build())
.addProvider(JavaRuleOutputJarsProvider.class, ruleOutputJarsProvider)
// TODO(bazel-team): this should only happen for java_plugin
.addProvider(JavaPluginInfoProvider.class, pluginInfoProvider)
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java
index a95e338b7c..90972d2315 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java
@@ -47,7 +47,6 @@ import com.google.devtools.build.lib.util.FileType;
import com.google.devtools.build.lib.util.Pair;
import com.google.devtools.build.lib.vfs.PathFragment;
import java.io.File;
-import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
@@ -256,8 +255,6 @@ public interface JavaSemantics {
void checkForProtoLibraryAndJavaProtoLibraryOnSameProto(
RuleContext ruleContext, JavaCommon javaCommon);
- void checkProtoDeps(RuleContext ruleContext, Collection<? extends TransitiveInfoCollection> deps);
-
/**
* Returns the main class of a Java binary.
*/
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/ProtoJavaApiInfoAspectProvider.java b/src/main/java/com/google/devtools/build/lib/rules/java/ProtoJavaApiInfoAspectProvider.java
deleted file mode 100644
index 87e32ad9c2..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/java/ProtoJavaApiInfoAspectProvider.java
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 2014 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-package com.google.devtools.build.lib.rules.java;
-
-import com.google.auto.value.AutoValue;
-import com.google.devtools.build.lib.analysis.TransitiveInfoProvider;
-import com.google.devtools.build.lib.collect.nestedset.NestedSet;
-import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
-import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
-import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.Strategy;
-import javax.annotation.concurrent.Immutable;
-
-/**
- * A {@link TransitiveInfoProvider} that aggregates {@link ProtoJavaApiInfoProvider} for propogation
- * in an aspect.
- */
-@AutoCodec(strategy = Strategy.AUTO_VALUE_BUILDER)
-@Immutable
-@AutoValue
-public abstract class ProtoJavaApiInfoAspectProvider implements TransitiveInfoProvider {
-
- public static Builder builder() {
- return new AutoValue_ProtoJavaApiInfoAspectProvider.Builder();
- }
-
- public static ProtoJavaApiInfoAspectProvider merge(
- Iterable<ProtoJavaApiInfoAspectProvider> providers) {
- ProtoJavaApiInfoAspectProvider.Builder protoBuilder = ProtoJavaApiInfoAspectProvider.builder();
- for (ProtoJavaApiInfoAspectProvider provider : providers) {
- protoBuilder.addTransitive(provider);
- }
- return protoBuilder.build();
- }
-
- public abstract NestedSet<ProtoJavaApiInfoProvider> getProviders();
-
- /** A builder for {@link ProtoJavaApiInfoProvider}. */
- @AutoValue.Builder
- public abstract static class Builder {
-
- private final NestedSetBuilder<ProtoJavaApiInfoProvider> providers =
- NestedSetBuilder.stableOrder();
-
- public Builder add(ProtoJavaApiInfoProvider provider) {
- providers.add(provider);
- return this;
- }
-
- public Builder addTransitive(ProtoJavaApiInfoAspectProvider provider) {
- providers.addTransitive(provider.getProviders());
- return this;
- }
-
- abstract Builder setProviders(NestedSet<ProtoJavaApiInfoProvider> providers);
-
- abstract ProtoJavaApiInfoAspectProvider autoBuild();
-
- public ProtoJavaApiInfoAspectProvider build() {
- return setProviders(providers.build()).autoBuild();
- }
- }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/ProtoJavaApiInfoProvider.java b/src/main/java/com/google/devtools/build/lib/rules/java/ProtoJavaApiInfoProvider.java
deleted file mode 100644
index e823f4bb3b..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/java/ProtoJavaApiInfoProvider.java
+++ /dev/null
@@ -1,192 +0,0 @@
-// Copyright 2014 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-package com.google.devtools.build.lib.rules.java;
-
-import com.google.auto.value.AutoValue;
-import com.google.common.collect.ImmutableList;
-import com.google.devtools.build.lib.actions.Artifact;
-import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
-import com.google.devtools.build.lib.analysis.TransitiveInfoProvider;
-import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
-import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
-import javax.annotation.Nullable;
-
-/** An object that provides information about API versions used by a proto library. */
-@AutoCodec
-@Immutable
-@AutoValue
-public abstract class ProtoJavaApiInfoProvider implements TransitiveInfoProvider {
- @AutoCodec.Instantiator
- public static ProtoJavaApiInfoProvider create(
- JavaCompilationArgs javaCompilationContext,
- JavaCompilationArgs transitiveJavaCompilationArgs,
- JavaCompilationArgs transitiveJavaRpcLibs,
- JavaCompilationArgs transitiveJavaCompilationArgs1,
- JavaCompilationArgs transitiveJavaCompilationArgsMutable,
- JavaCompilationArgs transitiveJavaCompilationArgsImmutable,
- JavaCompilationArtifacts javaCompilationArtifacts1,
- JavaCompilationArtifacts javaCompilationArtifactsMutable,
- JavaCompilationArtifacts javaCompilationArtifactsImmutable,
- Artifact sourceJar1,
- Artifact sourceJarMutable,
- Artifact sourceJarImmutable,
- @Nullable ImmutableList<TransitiveInfoCollection> protoRuntime1,
- @Nullable ImmutableList<TransitiveInfoCollection> protoRuntimeMutable,
- @Nullable ImmutableList<TransitiveInfoCollection> protoRuntimeImmutable,
- JavaCompilationArgs transitiveProtoRuntime1,
- JavaCompilationArgs transitiveProtoRuntimeMutable,
- JavaCompilationArgs transitiveProtoRuntimeImmutable,
- boolean hasMixedApiVersions,
- int apiVersion,
- boolean supportsProto1,
- boolean supportsProto2Mutable,
- boolean hasProto1OnlyDependency) {
- return new AutoValue_ProtoJavaApiInfoProvider(
- javaCompilationContext,
- transitiveJavaCompilationArgs,
- transitiveJavaRpcLibs,
- transitiveJavaCompilationArgs1,
- transitiveJavaCompilationArgsMutable,
- transitiveJavaCompilationArgsImmutable,
- javaCompilationArtifacts1,
- javaCompilationArtifactsMutable,
- javaCompilationArtifactsImmutable,
- sourceJar1,
- sourceJarMutable,
- sourceJarImmutable,
- protoRuntime1,
- protoRuntimeMutable,
- protoRuntimeImmutable,
- transitiveProtoRuntime1,
- transitiveProtoRuntimeMutable,
- transitiveProtoRuntimeImmutable,
- hasMixedApiVersions,
- apiVersion,
- supportsProto1,
- supportsProto2Mutable,
- hasProto1OnlyDependency);
- }
-
- /**
- * Returns the Java artifacts created for this target. This method should only be called on
- * recursive visitations if {@code hasProtoLibraryShellInDeps()} returns {@code false}.
- */
- // TODO(bazel-team): this is mostly used by the tests
- public abstract JavaCompilationArgs getJavaCompilationContext();
-
- /**
- * Returns the the transitive Java artifacts created for this target.
- */
- // TODO(bazel-team): this is mostly used by the tests
- public abstract JavaCompilationArgs getTransitiveJavaCompilationArgs();
-
- /**
- * Returns the Java RPC library if any dependencies need it, null otherwise.
- */
- public abstract JavaCompilationArgs getTransitiveJavaRpcLibs();
-
- /**
- * Returns the artifacts for java compilation (API version 1) from the transitive
- * closure (excluding this target).
- */
- public abstract JavaCompilationArgs getTransitiveJavaCompilationArgs1();
-
- /**
- * Returns the artifacts for java compilation (API version 2, code for mutable API)
- * from the transitive closure (excluding this target).
- */
- public abstract JavaCompilationArgs getTransitiveJavaCompilationArgsMutable();
-
- /**
- * Returns the artifacts for java compilation (API version 2, code for immutable API)
- * from the transitive closure (excluding this target).
- */
- public abstract JavaCompilationArgs getTransitiveJavaCompilationArgsImmutable();
-
- /** Returns the artifacts for java compilation (API version 1) for only this target. */
- public abstract JavaCompilationArtifacts getJavaCompilationArtifacts1();
-
- /**
- * Returns the artifacts for java compilation (API version 2, code for mutable API) for only this
- * target.
- */
- public abstract JavaCompilationArtifacts getJavaCompilationArtifactsMutable();
-
- /**
- * Returns the artifacts for java compilation (API version 2, code for immutable API) for only
- * this target.
- */
- public abstract JavaCompilationArtifacts getJavaCompilationArtifactsImmutable();
-
- // The following 3 fields are the -src.jar artifact created by proto_library. If a certain
- // proto_library does not produce some artifact, it'll be null. This can happen for example when
- // there are no srcs, or when a certain combination of attributes results in "mutable" not being
- // produced.
- @Nullable
- public abstract Artifact sourceJar1();
-
- @Nullable
- public abstract Artifact sourceJarMutable();
-
- @Nullable
- public abstract Artifact sourceJarImmutable();
-
- // The following 3 fields are the targets that proto_library got from the proto runtime, including
- // Stubby. Different flavors can have different runtimes. If a certain proto_library does not
- // produce some artifact, it'll be null. This can happen for example when a certain combination of
- // attributes results in "mutable" not being produced.
- @Nullable
- public abstract ImmutableList<TransitiveInfoCollection> getProtoRuntime1();
-
- @Nullable
- public abstract ImmutableList<TransitiveInfoCollection> getProtoRuntimeMutable();
-
- @Nullable
- public abstract ImmutableList<TransitiveInfoCollection> getProtoRuntimeImmutable();
-
- // The following 3 fields are the jars that proto_library got from the proto runtime, and their
- // transitive dependencies.
- public abstract JavaCompilationArgs getTransitiveProtoRuntime1();
-
- public abstract JavaCompilationArgs getTransitiveProtoRuntimeMutable();
-
- public abstract JavaCompilationArgs getTransitiveProtoRuntimeImmutable();
-
- /**
- * Returns true if the transitive closure contains libraries with API versions other than the one
- * specified in this target. Building in mixed mode will add implicit deps for all the api_version
- * and might generate adapter code that has some runtime overhead.
- */
- public abstract boolean hasMixedApiVersions();
-
- /** Returns the API version. */
- public abstract int getApiVersion();
-
- /**
- * Returns true if this target support proto1 API.
- */
- public abstract boolean supportsProto1();
-
- /**
- * Returns true if this target support proto2 mutable API.
- */
- public abstract boolean supportsProto2Mutable();
-
- /**
- * Returns true if this target has a dependency (can be recursively) that only
- * supports proto1 API but not proto2 mutable API.
- */
- public abstract boolean hasProto1OnlyDependency();
-
-}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/proto/ActionReuser.java b/src/main/java/com/google/devtools/build/lib/rules/java/proto/ActionReuser.java
deleted file mode 100644
index 8f4479eecb..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/java/proto/ActionReuser.java
+++ /dev/null
@@ -1,123 +0,0 @@
-// Copyright 2017 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.build.lib.rules.java.proto;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.getOnlyElement;
-import static com.google.common.collect.Iterables.isEmpty;
-import static com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget.Mode.TARGET;
-import static com.google.devtools.build.lib.rules.java.JavaCompilationArgs.ClasspathType.BOTH;
-import static com.google.devtools.build.lib.rules.java.proto.JplCcLinkParams.createCcLinkParamsStore;
-import static com.google.devtools.build.lib.rules.java.proto.StrictDepsUtils.createNonStrictCompilationArgsProvider;
-
-import com.google.common.collect.ImmutableList;
-import com.google.devtools.build.lib.actions.Artifact;
-import com.google.devtools.build.lib.analysis.ConfiguredAspect;
-import com.google.devtools.build.lib.analysis.ConfiguredTarget;
-import com.google.devtools.build.lib.analysis.RuleContext;
-import com.google.devtools.build.lib.analysis.TransitiveInfoProviderMap;
-import com.google.devtools.build.lib.analysis.TransitiveInfoProviderMapBuilder;
-import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
-import com.google.devtools.build.lib.collect.nestedset.Order;
-import com.google.devtools.build.lib.rules.java.JavaCompilationArgs;
-import com.google.devtools.build.lib.rules.java.JavaCompilationArgsProvider;
-import com.google.devtools.build.lib.rules.java.JavaCompilationArtifacts;
-import com.google.devtools.build.lib.rules.java.JavaRuleOutputJarsProvider;
-import com.google.devtools.build.lib.rules.java.JavaSkylarkApiProvider;
-import com.google.devtools.build.lib.rules.java.JavaSourceJarsProvider;
-import com.google.devtools.build.lib.rules.java.ProtoJavaApiInfoProvider;
-
-public class ActionReuser {
-
- /**
- * If the underlying proto_library rule already registers the compile actions we need, just reuse
- * them. This will preserve memory.
- *
- * <p>TODO(b/36191931): Delete when it's time.
- */
- public static boolean reuseExistingActions(
- ConfiguredTarget base, RuleContext ruleContext, ConfiguredAspect.Builder aspect) {
- ProtoJavaApiInfoProvider javaApi = base.getProvider(ProtoJavaApiInfoProvider.class);
- if (javaApi == null) {
- return false;
- }
-
- JavaCompilationArtifacts directJars = javaApi.getJavaCompilationArtifactsImmutable();
- if (isEmpty(directJars.getCompileTimeJars()) || javaApi.sourceJarImmutable() == null) {
- return false;
- }
-
- JavaCompilationArgs.Builder transitiveJars =
- JavaCompilationArgs.builder()
- .addTransitiveArgs(javaApi.getTransitiveJavaCompilationArgsImmutable(), BOTH)
- .addTransitiveArgs(javaApi.getTransitiveProtoRuntimeImmutable(), BOTH)
- .merge(directJars);
-
- Artifact outputJar = getOnlyElement(directJars.getRuntimeJars());
- Artifact compileTimeJar = getOnlyElement(directJars.getCompileTimeJars());
- Artifact sourceJar = checkNotNull(javaApi.sourceJarImmutable());
-
- JavaCompilationArgsProvider compilationArgsProvider =
- JavaCompilationArgsProvider.create(
- JavaCompilationArgs.builder().merge(directJars).build(),
- transitiveJars.build(),
- NestedSetBuilder.create(
- Order.STABLE_ORDER, directJars.getCompileTimeDependencyArtifact()));
-
- TransitiveInfoProviderMapBuilder javaProvidersBuilder =
- new TransitiveInfoProviderMapBuilder()
- .add(createOutputJarProvider(outputJar, compileTimeJar, sourceJar))
- .add(createSrcJarProvider(sourceJar))
- .add(compilationArgsProvider)
- .add(createCcLinkParamsStore(ruleContext, javaApi.getProtoRuntimeImmutable()));
-
- Iterable<JavaProtoLibraryAspectProvider> javaProtoLibraryAspectProviders =
- ruleContext.getPrerequisites("deps", TARGET, JavaProtoLibraryAspectProvider.class);
-
- NestedSetBuilder<Artifact> transitiveOutputJars = NestedSetBuilder.stableOrder();
- for (JavaProtoLibraryAspectProvider provider : javaProtoLibraryAspectProviders) {
- transitiveOutputJars.addTransitive(provider.getJars());
- }
- transitiveOutputJars.add(outputJar);
-
- TransitiveInfoProviderMap javaProviders = javaProvidersBuilder.build();
- aspect
- .addSkylarkTransitiveInfo(
- JavaSkylarkApiProvider.PROTO_NAME.getLegacyId(),
- JavaSkylarkApiProvider.fromProviderMap(javaProviders))
- .addProviders(
- new JavaProtoLibraryAspectProvider(
- javaProviders,
- transitiveOutputJars.build(),
- createNonStrictCompilationArgsProvider(
- javaProtoLibraryAspectProviders,
- compilationArgsProvider,
- javaApi.getProtoRuntimeImmutable())));
- return true;
- }
-
- private static JavaRuleOutputJarsProvider createOutputJarProvider(
- Artifact outputJar, Artifact compileTimeJar, Artifact sourceJar) {
- return JavaRuleOutputJarsProvider.builder()
- .addOutputJar(outputJar, compileTimeJar, ImmutableList.of(sourceJar))
- .build();
- }
-
- private static JavaSourceJarsProvider createSrcJarProvider(Artifact sourceJar) {
- return JavaSourceJarsProvider.create(
- NestedSetBuilder.emptySet(Order.STABLE_ORDER),
- NestedSetBuilder.<Artifact>stableOrder().add(sourceJar).build());
- }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoLibrary.java
index b85858f744..6e38294284 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoLibrary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoLibrary.java
@@ -14,7 +14,6 @@
package com.google.devtools.build.lib.rules.java.proto;
-import static com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget.Mode.TARGET;
import static com.google.devtools.build.lib.collect.nestedset.Order.STABLE_ORDER;
import static com.google.devtools.build.lib.rules.java.proto.JplCcLinkParams.createCcLinkParamsStore;
import static com.google.devtools.build.lib.rules.java.proto.StrictDepsUtils.constructJcapFromAspectDeps;
@@ -43,7 +42,6 @@ import com.google.devtools.build.lib.rules.java.JavaSkylarkApiProvider;
import com.google.devtools.build.lib.rules.java.JavaSourceJarsProvider;
import com.google.devtools.build.lib.rules.java.ProguardLibrary;
import com.google.devtools.build.lib.rules.java.ProguardSpecProvider;
-import com.google.devtools.build.lib.rules.java.ProtoJavaApiInfoAspectProvider;
/** Implementation of the java_lite_proto_library rule. */
public class JavaLiteProtoLibrary implements RuleConfiguredTargetFactory {
@@ -84,12 +82,6 @@ public class JavaLiteProtoLibrary implements RuleConfiguredTargetFactory {
JavaInfo.Builder.create()
.addProvider(JavaCompilationArgsProvider.class, dependencyArgsProviders)
.addProvider(JavaSourceJarsProvider.class, sourceJarsProvider)
- .addProvider(
- ProtoJavaApiInfoAspectProvider.class,
- ProtoJavaApiInfoAspectProvider.merge(
- JavaInfo.getProvidersFromListOfTargets(
- ProtoJavaApiInfoAspectProvider.class,
- ruleContext.getPrerequisites("deps", TARGET))))
.addProvider(JavaRuleOutputJarsProvider.class, JavaRuleOutputJarsProvider.EMPTY)
.addProvider(JavaRunfilesProvider.class, javaRunfilesProvider)
.setJavaConstraints(ImmutableList.of("android"))
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoAspect.java b/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoAspect.java
index 4a4eab01e0..0e59ce8367 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoAspect.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoAspect.java
@@ -106,10 +106,6 @@ public class JavaProtoAspect extends NativeAspectClass implements ConfiguredAspe
JavaProtoAspectCommon aspectCommon =
JavaProtoAspectCommon.getSpeedInstance(ruleContext, javaSemantics, rpcSupport);
Impl impl = new Impl(ruleContext, supportData, aspectCommon, rpcSupport);
- if (impl.shouldGenerateCode()
- && ActionReuser.reuseExistingActions(ctadBase.getConfiguredTarget(), ruleContext, aspect)) {
- return aspect.build();
- }
impl.addProviders(aspect);
return aspect.build();
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoLibrary.java
index 6296aca835..2a0a4ec0d5 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoLibrary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoLibrary.java
@@ -38,7 +38,6 @@ import com.google.devtools.build.lib.rules.java.JavaRuleOutputJarsProvider;
import com.google.devtools.build.lib.rules.java.JavaRunfilesProvider;
import com.google.devtools.build.lib.rules.java.JavaSkylarkApiProvider;
import com.google.devtools.build.lib.rules.java.JavaSourceJarsProvider;
-import com.google.devtools.build.lib.rules.java.ProtoJavaApiInfoAspectProvider;
/** Implementation of the java_proto_library rule. */
public class JavaProtoLibrary implements RuleConfiguredTargetFactory {
@@ -79,12 +78,6 @@ public class JavaProtoLibrary implements RuleConfiguredTargetFactory {
JavaInfo.Builder.create()
.addProvider(JavaCompilationArgsProvider.class, dependencyArgsProviders)
.addProvider(JavaSourceJarsProvider.class, sourceJarsProvider)
- .addProvider(
- ProtoJavaApiInfoAspectProvider.class,
- ProtoJavaApiInfoAspectProvider.merge(
- JavaInfo.getProvidersFromListOfTargets(
- ProtoJavaApiInfoAspectProvider.class,
- ruleContext.getPrerequisites("deps", TARGET))))
.addProvider(JavaRuleOutputJarsProvider.class, JavaRuleOutputJarsProvider.EMPTY)
.addProvider(JavaRunfilesProvider.class, javaRunfilesProvider)
.build();