diff options
Diffstat (limited to 'src/main')
9 files changed, 23 insertions, 75 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaLiteProtoAspect.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaLiteProtoAspect.java index 13a456e9fa..ac5e751fd0 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaLiteProtoAspect.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaLiteProtoAspect.java @@ -19,14 +19,7 @@ import com.google.devtools.build.lib.rules.java.proto.JavaLiteProtoAspect; /** An Aspect which BazelJavaLiteProtoLibrary injects to build Java Lite protos. */ public class BazelJavaLiteProtoAspect extends JavaLiteProtoAspect { - static final String LITE_PROTO_RUNTIME_ATTR = "$aspect_java_lib"; - static final String LITE_PROTO_RUNTIME_LABEL = "//third_party/protobuf:protobuf"; - public BazelJavaLiteProtoAspect() { - super( - BazelJavaSemantics.INSTANCE, - LITE_PROTO_RUNTIME_ATTR, - LITE_PROTO_RUNTIME_LABEL, - null /* jacocoLabel */); + super(BazelJavaSemantics.INSTANCE, null /* jacocoLabel */); } } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaLiteProtoLibrary.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaLiteProtoLibrary.java index 879bfc0e0b..9930bc41ec 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaLiteProtoLibrary.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaLiteProtoLibrary.java @@ -18,7 +18,4 @@ import com.google.devtools.build.lib.rules.java.proto.JavaLiteProtoLibrary; /** Implementation of the java_lite_proto_library rule. */ public class BazelJavaLiteProtoLibrary extends JavaLiteProtoLibrary { - public BazelJavaLiteProtoLibrary() { - super(BazelJavaLiteProtoAspect.LITE_PROTO_RUNTIME_ATTR); - } } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaLiteProtoLibraryRule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaLiteProtoLibraryRule.java index b92aced757..f04d0e0d4a 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaLiteProtoLibraryRule.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaLiteProtoLibraryRule.java @@ -14,12 +14,12 @@ package com.google.devtools.build.lib.bazel.rules.java.proto; -import static com.google.devtools.build.lib.bazel.rules.java.proto.BazelJavaLiteProtoAspect.LITE_PROTO_RUNTIME_ATTR; -import static com.google.devtools.build.lib.bazel.rules.java.proto.BazelJavaLiteProtoAspect.LITE_PROTO_RUNTIME_LABEL; import static com.google.devtools.build.lib.packages.Aspect.INJECTING_RULE_KIND_PARAMETER_KEY; import static com.google.devtools.build.lib.packages.Attribute.attr; import static com.google.devtools.build.lib.packages.BuildType.LABEL; import static com.google.devtools.build.lib.packages.BuildType.LABEL_LIST; +import static com.google.devtools.build.lib.rules.java.proto.JavaLiteProtoAspect.LITE_PROTO_RUNTIME_ATTR; +import static com.google.devtools.build.lib.rules.java.proto.JavaLiteProtoAspect.LITE_PROTO_RUNTIME_LABEL; import static com.google.devtools.build.lib.syntax.Type.BOOLEAN; import com.google.common.base.Function; @@ -31,6 +31,7 @@ import com.google.devtools.build.lib.packages.AspectParameters; import com.google.devtools.build.lib.packages.Rule; import com.google.devtools.build.lib.packages.RuleClass; import com.google.devtools.build.lib.rules.java.JavaConfiguration; +import com.google.devtools.build.lib.rules.java.proto.JavaLiteProtoLibrary; import javax.annotation.Nullable; /** Declaration of the {@code java_lite_proto_library} rule. */ @@ -84,7 +85,7 @@ public class BazelJavaLiteProtoLibraryRule implements RuleDefinition { public Metadata getMetadata() { return RuleDefinition.Metadata.builder() .name("java_lite_proto_library") - .factoryClass(BazelJavaLiteProtoLibrary.class) + .factoryClass(JavaLiteProtoLibrary.class) .ancestors(BaseRuleClasses.RuleBase.class) .build(); } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaProtoAspect.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaProtoAspect.java index 3392ce1823..c2413e430f 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaProtoAspect.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaProtoAspect.java @@ -28,14 +28,9 @@ import com.google.devtools.build.lib.rules.proto.ProtoCompileActionBuilder; /** An Aspect which BazelJavaProtoLibrary injects to build Java SPEED protos. */ public class BazelJavaProtoAspect extends JavaProtoAspect { - static final String SPEED_PROTO_RUNTIME_ATTR = "$aspect_java_lib"; - static final String SPEED_PROTO_RUNTIME_LABEL = "//third_party/protobuf:protobuf"; - public BazelJavaProtoAspect() { super( BazelJavaSemantics.INSTANCE, - SPEED_PROTO_RUNTIME_ATTR, - SPEED_PROTO_RUNTIME_LABEL, ImmutableList.<String>of(), null, /* jacocoAttr */ ImmutableList.of("shared", "immutable"), diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaProtoLibrary.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaProtoLibrary.java deleted file mode 100644 index a6f2e849e4..0000000000 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaProtoLibrary.java +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 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.bazel.rules.java.proto; - -import com.google.devtools.build.lib.rules.java.proto.JavaProtoLibrary; - -/** Implementation of the java_proto_library rule. */ -public class BazelJavaProtoLibrary extends JavaProtoLibrary {} diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaProtoLibraryRule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaProtoLibraryRule.java index 217db48371..733b540ee5 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaProtoLibraryRule.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaProtoLibraryRule.java @@ -27,6 +27,7 @@ import com.google.devtools.build.lib.packages.AspectParameters; import com.google.devtools.build.lib.packages.Rule; import com.google.devtools.build.lib.packages.RuleClass; import com.google.devtools.build.lib.rules.java.JavaConfiguration; +import com.google.devtools.build.lib.rules.java.proto.JavaProtoLibrary; import javax.annotation.Nullable; /** Declaration of the {@code java_proto_library} rule. */ @@ -72,7 +73,7 @@ public class BazelJavaProtoLibraryRule implements RuleDefinition { public Metadata getMetadata() { return RuleDefinition.Metadata.builder() .name("java_proto_library") - .factoryClass(BazelJavaProtoLibrary.class) + .factoryClass(JavaProtoLibrary.class) .ancestors(BaseRuleClasses.RuleBase.class) .build(); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoAspect.java b/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoAspect.java index e96a49d3e3..f12cfb030b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoAspect.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoAspect.java @@ -64,20 +64,17 @@ import javax.annotation.Nullable; /** An Aspect which JavaLiteProtoLibrary injects to build Java Lite protos. */ public class JavaLiteProtoAspect extends NativeAspectClass implements ConfiguredAspectFactory { + public static final String LITE_PROTO_RUNTIME_ATTR = "$aspect_java_lib"; + public static final String LITE_PROTO_RUNTIME_LABEL = "//external:protobuf/javalite_runtime"; + private final JavaSemantics javaSemantics; - private final String protoRuntimeAttr; - private final String protoRuntimeLabel; @Nullable private final String jacocoLabel; public JavaLiteProtoAspect( JavaSemantics javaSemantics, - String protoRuntimeAttr, - String protoRuntimeLabel, @Nullable String jacocoLabel) { this.javaSemantics = javaSemantics; - this.protoRuntimeAttr = protoRuntimeAttr; - this.protoRuntimeLabel = protoRuntimeLabel; this.jacocoLabel = jacocoLabel; } @@ -92,9 +89,7 @@ public class JavaLiteProtoAspect extends NativeAspectClass implements Configured SupportData supportData = checkNotNull(base.getProvider(ProtoSupportDataProvider.class)).getSupportData(); - aspect.addProviders( - new Impl(ruleContext, supportData, protoRuntimeAttr, javaSemantics) - .createProviders()); + aspect.addProviders(new Impl(ruleContext, supportData, javaSemantics).createProviders()); return aspect.build(); } @@ -107,9 +102,9 @@ public class JavaLiteProtoAspect extends NativeAspectClass implements Configured .requiresConfigurationFragments(JavaConfiguration.class, ProtoConfiguration.class) .requireProvider(ProtoSourcesProvider.class) .add( - attr(protoRuntimeAttr, LABEL) + attr(LITE_PROTO_RUNTIME_ATTR, LABEL) .legacyAllowAnyFileType() - .value(parseAbsoluteUnchecked(protoRuntimeLabel))) + .value(parseAbsoluteUnchecked(LITE_PROTO_RUNTIME_LABEL))) .add(attr(":host_jdk", LABEL).cfg(HOST).value(JavaSemantics.HOST_JDK)) .add( attr(":java_toolchain", LABEL) @@ -140,17 +135,14 @@ public class JavaLiteProtoAspect extends NativeAspectClass implements Configured * Java compilation action. */ private final JavaCompilationArgsProvider dependencyCompilationArgs; - private final String protoRuntimeAttr; private final JavaSemantics javaSemantics; Impl( final RuleContext ruleContext, final SupportData supportData, - String protoRuntimeAttr, JavaSemantics javaSemantics) { this.ruleContext = ruleContext; this.supportData = supportData; - this.protoRuntimeAttr = protoRuntimeAttr; this.javaSemantics = javaSemantics; dependencyCompilationArgs = @@ -236,7 +228,7 @@ public class JavaLiteProtoAspect extends NativeAspectClass implements Configured helper .addDep( ruleContext.getPrerequisite( - protoRuntimeAttr, Mode.TARGET, JavaCompilationArgsProvider.class)) + LITE_PROTO_RUNTIME_ATTR, Mode.TARGET, JavaCompilationArgsProvider.class)) .setCompilationStrictDepsMode(StrictDepsMode.OFF); JavaCompilationArgs artifacts = helper.build(javaSemantics); compileTimeJarToRuntimeJar.put( 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 62ae5595d8..26b6192a25 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 @@ -17,6 +17,7 @@ package com.google.devtools.build.lib.rules.java.proto; import static com.google.common.collect.Iterables.transform; import static com.google.devtools.build.lib.analysis.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.JavaLiteProtoAspect.LITE_PROTO_RUNTIME_ATTR; import com.google.common.collect.ImmutableMultimap; import com.google.devtools.build.lib.actions.Artifact; @@ -42,12 +43,6 @@ import com.google.devtools.build.lib.rules.java.ProguardSpecProvider; /** Implementation of the java_lite_proto_library rule. */ public class JavaLiteProtoLibrary implements RuleConfiguredTargetFactory { - private final String protoRuntimeAttr; - - public JavaLiteProtoLibrary(String protoRuntimeAttr) { - this.protoRuntimeAttr = protoRuntimeAttr; - } - @Override public ConfiguredTarget create(final RuleContext ruleContext) throws InterruptedException, RuleErrorException { @@ -98,7 +93,8 @@ public class JavaLiteProtoLibrary implements RuleConfiguredTargetFactory { ProguardSpecProvider.class, new ProguardSpecProvider( new ProguardLibrary(ruleContext) - .collectProguardSpecs(ImmutableMultimap.of(Mode.TARGET, protoRuntimeAttr)))) + .collectProguardSpecs( + ImmutableMultimap.of(Mode.TARGET, LITE_PROTO_RUNTIME_ATTR)))) .add(JavaRuleOutputJarsProvider.class, JavaRuleOutputJarsProvider.builder().build()) .addSkylarkTransitiveInfo(JavaSkylarkApiProvider.NAME, new JavaSkylarkApiProvider()) .build(); 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 6d683f7794..c27a3f0305 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 @@ -71,6 +71,9 @@ import javax.annotation.Nullable; /** An Aspect which JavaProtoLibrary injects to build Java SPEED protos. */ public class JavaProtoAspect extends NativeAspectClass implements ConfiguredAspectFactory { + private static final String SPEED_PROTO_RUNTIME_ATTR = "$aspect_java_lib"; + private static final String SPEED_PROTO_RUNTIME_LABEL = "//external:protobuf/java_runtime"; + /** * The attribute name for holding a list of protos for which no code should be generated because * the proto-runtime already contains them. @@ -78,8 +81,6 @@ public class JavaProtoAspect extends NativeAspectClass implements ConfiguredAspe private static final String PROTO_SOURCE_FILE_BLACKLIST_ATTR = "$proto_source_file_blacklist"; private final JavaSemantics javaSemantics; - private final String protoRuntimeAttr; - private final String protoRuntimeLabel; private final ImmutableList<String> protoSourceFileBlacklistLabels; @Nullable private final String jacocoLabel; @@ -88,15 +89,11 @@ public class JavaProtoAspect extends NativeAspectClass implements ConfiguredAspe protected JavaProtoAspect( JavaSemantics javaSemantics, - String protoRuntimeAttr, - String protoRuntimeLabel, ImmutableList<String> protoSourceFileBlacklistLabels, @Nullable String jacocoLabel, ImmutableList<String> protoCompilerPluginOptions, RpcSupport rpcSupport) { this.javaSemantics = javaSemantics; - this.protoRuntimeAttr = protoRuntimeAttr; - this.protoRuntimeLabel = protoRuntimeLabel; this.protoSourceFileBlacklistLabels = protoSourceFileBlacklistLabels; this.jacocoLabel = jacocoLabel; this.protoCompilerPluginOptions = protoCompilerPluginOptions; @@ -122,7 +119,6 @@ public class JavaProtoAspect extends NativeAspectClass implements ConfiguredAspe new Impl( ruleContext, supportData, - protoRuntimeAttr, protoCompilerPluginOptions, javaSemantics, rpcSupport) @@ -139,9 +135,9 @@ public class JavaProtoAspect extends NativeAspectClass implements ConfiguredAspe .requiresConfigurationFragments(JavaConfiguration.class, ProtoConfiguration.class) .requireProvider(ProtoSourcesProvider.class) .add( - attr(protoRuntimeAttr, LABEL) + attr(SPEED_PROTO_RUNTIME_ATTR, LABEL) .legacyAllowAnyFileType() - .value(parseAbsoluteUnchecked(protoRuntimeLabel))) + .value(parseAbsoluteUnchecked(SPEED_PROTO_RUNTIME_LABEL))) .add( attr(PROTO_SOURCE_FILE_BLACKLIST_ATTR, LABEL_LIST) .cfg(HOST) @@ -185,7 +181,6 @@ public class JavaProtoAspect extends NativeAspectClass implements ConfiguredAspe private final SupportData supportData; private final RpcSupport rpcSupport; - private final String protoRuntimeAttr; private final JavaSemantics javaSemantics; /** @@ -198,13 +193,11 @@ public class JavaProtoAspect extends NativeAspectClass implements ConfiguredAspe Impl( final RuleContext ruleContext, final SupportData supportData, - String protoRuntimeAttr, ImmutableList<String> protoCompilerPluginOptions, JavaSemantics javaSemantics, RpcSupport rpcSupport) { this.ruleContext = ruleContext; this.supportData = supportData; - this.protoRuntimeAttr = protoRuntimeAttr; this.protoCompilerPluginOptions = protoCompilerPluginOptions; this.javaSemantics = javaSemantics; this.rpcSupport = rpcSupport; @@ -327,7 +320,7 @@ public class JavaProtoAspect extends NativeAspectClass implements ConfiguredAspe .addDep(dependencyCompilationArgs) .addDep( ruleContext.getPrerequisite( - protoRuntimeAttr, Mode.TARGET, JavaCompilationArgsProvider.class)) + SPEED_PROTO_RUNTIME_ATTR, Mode.TARGET, JavaCompilationArgsProvider.class)) .setCompilationStrictDepsMode(StrictDepsMode.OFF); rpcSupport.mutateJavaCompileAction(ruleContext, helper); return helper.buildCompilationArgsProvider( |