From 887746ff19559bb2ee093fdbe9a73bfad6dcdb81 Mon Sep 17 00:00:00 2001 From: cushon Date: Mon, 26 Jun 2017 10:32:55 +0200 Subject: [PATCH] Automated rollback of commit 68b9a7e2dc17e32b194238d287e79bee1ba035b9. *** Reason for rollback *** The depot is fixed RELNOTES: None. PiperOrigin-RevId: 160115070 --- .../lib/rules/java/JavaLibraryHelper.java | 18 ++++++++------ .../lib/rules/java/JavaSkylarkCommon.java | 2 +- .../rules/java/ProtoJavaApiInfoProvider.java | 24 +++++++++---------- .../lib/rules/java/proto/ActionReuser.java | 10 ++++---- .../rules/java/proto/JavaLiteProtoAspect.java | 4 ++-- 5 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibraryHelper.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibraryHelper.java index 7a58f46c6e0e78..ca960a950f2ae6 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibraryHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibraryHelper.java @@ -24,6 +24,8 @@ import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.analysis.config.BuildConfiguration.StrictDepsMode; import com.google.devtools.build.lib.collect.nestedset.NestedSet; +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.JavaConfiguration.JavaClasspathMode; import com.google.devtools.build.lib.util.Preconditions; import java.util.ArrayList; @@ -140,10 +142,8 @@ public JavaLibraryHelper setCompilationStrictDepsMode(StrictDepsMode strictDepsM return this; } - /** - * Creates the compile actions. - */ - public JavaCompilationArgs build( + /** Creates the compile actions. */ + public JavaCompilationArtifacts build( JavaSemantics semantics, JavaToolchainProvider javaToolchainProvider, NestedSet hostJavabase, @@ -184,7 +184,7 @@ public JavaCompilationArgs build( helper.createCompileTimeJarAction(output, artifactsBuilder); artifactsBuilder.addRuntimeJar(output); - return JavaCompilationArgs.builder().merge(artifactsBuilder.build()).build(); + return artifactsBuilder.build(); } /** @@ -199,7 +199,8 @@ public JavaCompilationArgs build( * compilation. Contrast this with {@link #setCompilationStrictDepsMode}. */ public JavaCompilationArgsProvider buildCompilationArgsProvider( - JavaCompilationArgs directArgs, boolean isReportedAsStrict) { + JavaCompilationArtifacts artifacts, boolean isReportedAsStrict) { + JavaCompilationArgs directArgs = JavaCompilationArgs.builder().merge(artifacts).build(); JavaCompilationArgs transitiveArgs = JavaCompilationArgs.builder() .addTransitiveArgs(directArgs, BOTH) @@ -207,7 +208,10 @@ public JavaCompilationArgsProvider buildCompilationArgsProvider( .build(); return JavaCompilationArgsProvider.create( - isReportedAsStrict ? directArgs : transitiveArgs, transitiveArgs); + isReportedAsStrict ? directArgs : transitiveArgs, + transitiveArgs, + NestedSetBuilder.create(Order.STABLE_ORDER, artifacts.getCompileTimeDependencyArtifact()), + NestedSetBuilder.emptySet(Order.STABLE_ORDER)); } private void addDepsToAttributes(JavaTargetAttributes.Builder attributes) { diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaSkylarkCommon.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaSkylarkCommon.java index 4f975a1c76b0a0..60e38a852826d2 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaSkylarkCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaSkylarkCommon.java @@ -222,7 +222,7 @@ public JavaProvider createJavaCompileAction( : hostJavabaseProvider.getMiddlemanArtifact(); JavaToolchainProvider javaToolchainProvider = checkNotNull(javaToolchain.getProvider(JavaToolchainProvider.class)); - JavaCompilationArgs artifacts = + JavaCompilationArtifacts artifacts = helper.build( javaSemantics, javaToolchainProvider, 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 index e76072a523f134..a6d05f99e8a296 100644 --- 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 @@ -36,9 +36,9 @@ public static ProtoJavaApiInfoProvider create( JavaCompilationArgs transitiveJavaCompilationArgss1, JavaCompilationArgs transitiveJavaCompilationArgssMutable, JavaCompilationArgs transitiveJavaCompilationArgssImmutable, - JavaCompilationArgs javaCompilationArgs1, - JavaCompilationArgs javaCompilationArgsMutable, - JavaCompilationArgs javaCompilationArgsImmutable, + JavaCompilationArtifacts javaCompilationArgs1, + JavaCompilationArtifacts javaCompilationArgsMutable, + JavaCompilationArtifacts javaCompilationArgsImmutable, Artifact sourceJar1, Artifact sourceJarMutable, Artifact sourceJarImmutable, @@ -111,22 +111,20 @@ public static ProtoJavaApiInfoProvider create( */ public abstract JavaCompilationArgs getTransitiveJavaCompilationArgsImmutable(); - /** - * Returns the artifacts for java compilation (API version 1) for only this target. - */ - public abstract JavaCompilationArgs getJavaCompilationArgs1(); + /** 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. + * Returns the artifacts for java compilation (API version 2, code for mutable API) for only this + * target. */ - public abstract JavaCompilationArgs getJavaCompilationArgsMutable(); + public abstract JavaCompilationArtifacts getJavaCompilationArtifactsMutable(); /** - * Returns the artifacts for java compilation (API version 2, code for immutable API) - * for only this target. + * Returns the artifacts for java compilation (API version 2, code for immutable API) for only + * this target. */ - public abstract JavaCompilationArgs getJavaCompilationArgsImmutable(); + 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 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 index b58923fb65721e..5d8e296a7c9b15 100644 --- 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 @@ -31,6 +31,7 @@ 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; @@ -51,7 +52,7 @@ public static boolean reuseExistingActions( return false; } - JavaCompilationArgs directJars = javaApi.getJavaCompilationArgsImmutable(); + JavaCompilationArtifacts directJars = javaApi.getJavaCompilationArtifactsImmutable(); if (isEmpty(directJars.getCompileTimeJars()) || javaApi.sourceJarImmutable() == null) { return false; } @@ -60,7 +61,7 @@ public static boolean reuseExistingActions( JavaCompilationArgs.builder() .addTransitiveArgs(javaApi.getTransitiveJavaCompilationArgsImmutable(), BOTH) .addTransitiveDependencies(javaApi.getProtoRuntimeImmutable(), true /* recursive */) - .addTransitiveArgs(directJars, BOTH) + .merge(directJars) .build(); Artifact outputJar = getOnlyElement(directJars.getRuntimeJars()); @@ -69,9 +70,10 @@ public static boolean reuseExistingActions( JavaCompilationArgsProvider compilationArgsProvider = JavaCompilationArgsProvider.create( - directJars, + JavaCompilationArgs.builder().merge(directJars).build(), transitiveJars, - NestedSetBuilder.emptySet(Order.STABLE_ORDER), + NestedSetBuilder.create( + Order.STABLE_ORDER, directJars.getCompileTimeDependencyArtifact()), NestedSetBuilder.emptySet(Order.STABLE_ORDER)); TransitiveInfoProviderMapBuilder javaProvidersBuilder = 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 21382cafec6f51..4fdcce662b7b4d 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 @@ -46,8 +46,8 @@ import com.google.devtools.build.lib.packages.AttributeMap; import com.google.devtools.build.lib.packages.NativeAspectClass; import com.google.devtools.build.lib.packages.Rule; -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.JavaCompilationHelper; import com.google.devtools.build.lib.rules.java.JavaConfiguration; import com.google.devtools.build.lib.rules.java.JavaHelper; @@ -254,7 +254,7 @@ private JavaCompilationArgsProvider createJavaCompileAction( helper.addDep(runtime.getProvider(JavaCompilationArgsProvider.class)); } helper.setCompilationStrictDepsMode(StrictDepsMode.OFF); - JavaCompilationArgs artifacts = + JavaCompilationArtifacts artifacts = helper.build( javaSemantics, JavaCompilationHelper.getJavaToolchainProvider(ruleContext),