TransitiveJavaRuleOutputJarsProvider and JavaRuleOutputJarsProvider.
@@ -22,6 +22,7 @@ import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.actions.Artifact;
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 com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
import com.google.devtools.build.lib.skylarkinterface.SkylarkModule;
import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory;
@@ -36,6 +37,7 @@ import javax.annotation.Nullable;
category = SkylarkModuleCategory.NONE,
doc = "Information about outputs of a Java rule."
)
+@AutoCodec
public final class JavaRuleOutputJarsProvider implements TransitiveInfoProvider {
public static final JavaRuleOutputJarsProvider EMPTY =
@@ -49,6 +51,7 @@ public final class JavaRuleOutputJarsProvider implements TransitiveInfoProvider
doc = "Java classes jar, together with their associated source and interface archives."
)
@Immutable
+ @AutoCodec
public static class OutputJar {
@Nullable private final Artifact classJar;
@Nullable private final Artifact iJar;
@@ -128,6 +131,18 @@ public final class JavaRuleOutputJarsProvider implements TransitiveInfoProvider
this.nativeHeaders = nativeHeaders;
}
+ @AutoCodec.VisibleForSerialization
+ @AutoCodec.Instantiator
+ static JavaRuleOutputJarsProvider create(
+ ImmutableList<OutputJar> outputJars,
+ @Nullable Artifact jdeps,
+ @Nullable Artifact nativeHeaders) {
+ if (outputJars.isEmpty() && jdeps == null && nativeHeaders == null) {
+ return EMPTY;
+ }
+ return new JavaRuleOutputJarsProvider(outputJars, jdeps, nativeHeaders);
+ }
+
@SkylarkCallable(name = "jars", doc = "A list of jars the rule outputs.", structField = true)
public ImmutableList<OutputJar> getOutputJars() {
return outputJars;
