diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build')
9 files changed, 236 insertions, 156 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AarImport.java b/src/main/java/com/google/devtools/build/lib/rules/android/AarImport.java index b20e645c17..05e85d2467 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AarImport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AarImport.java @@ -161,9 +161,7 @@ public class AarImport implements RuleConfiguredTargetFactory { .addSkylarkTransitiveInfo( JavaSkylarkApiProvider.NAME, JavaSkylarkApiProvider.fromRuleContext()) .addProvider(RunfilesProvider.class, RunfilesProvider.EMPTY) - .addProvider( - AndroidResourcesProvider.class, - resourceApk.toResourceProvider(ruleContext.getLabel())) + .addNativeDeclaredProvider(resourceApk.toResourceInfo(ruleContext.getLabel())) .addProvider( NativeLibsZipsProvider.class, new NativeLibsZipsProvider( diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidCommon.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidCommon.java index e9064e9400..f6357eaee3 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidCommon.java @@ -743,6 +743,8 @@ public class AndroidCommon { .setNeverlink(isNeverlink) .build(); + AndroidResourcesInfo resourceInfo = resourceApk.toResourceInfo(ruleContext.getLabel()); + return builder .setFilesToBuild(filesToBuild) .addSkylarkTransitiveInfo( @@ -752,9 +754,7 @@ public class AndroidCommon { JavaRuntimeJarProvider.class, new JavaRuntimeJarProvider(javaCommon.getJavaCompilationArtifacts().getRuntimeJars())) .addProvider(RunfilesProvider.class, RunfilesProvider.simple(getRunfiles())) - .addProvider( - AndroidResourcesProvider.class, - resourceApk.toResourceProvider(ruleContext.getLabel())) + .addNativeDeclaredProvider(resourceInfo) .addProvider( AndroidIdeInfoProvider.class, createAndroidIdeInfoProvider( @@ -766,7 +766,8 @@ public class AndroidCommon { zipAlignedApk, apksUnderTest, nativeLibs)) - .addSkylarkTransitiveInfo(AndroidSkylarkApiProvider.NAME, new AndroidSkylarkApiProvider()) + .addSkylarkTransitiveInfo( + AndroidSkylarkApiProvider.NAME, new AndroidSkylarkApiProvider(resourceInfo)) .addOutputGroup( OutputGroupInfo.HIDDEN_TOP_LEVEL, collectHiddenTopLevelArtifacts(ruleContext)) .addOutputGroup( diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesInfo.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesInfo.java new file mode 100644 index 0000000000..1963fa7ad9 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesInfo.java @@ -0,0 +1,134 @@ +// Copyright 2015 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.android; + +import com.google.devtools.build.lib.actions.Artifact; +import com.google.devtools.build.lib.cmdline.Label; +import com.google.devtools.build.lib.collect.nestedset.NestedSet; +import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; +import com.google.devtools.build.lib.packages.NativeInfo; +import com.google.devtools.build.lib.packages.NativeProvider; +import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable; +import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; +import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; + +/** A provider that supplies ResourceContainers from its transitive closure. */ +@SkylarkModule( + name = "AndroidResourcesInfo", + doc = "Android resources provided by a rule", + category = SkylarkModuleCategory.PROVIDER +) +@Immutable +public class AndroidResourcesInfo extends NativeInfo { + + private static final String SKYLARK_NAME = "AndroidResourcesInfo"; + public static final NativeProvider<AndroidResourcesInfo> PROVIDER = + new NativeProvider<AndroidResourcesInfo>(AndroidResourcesInfo.class, SKYLARK_NAME) {}; + + private final Label label; + private final NestedSet<ResourceContainer> transitiveAndroidResources; + private final NestedSet<ResourceContainer> directAndroidResources; + private final NestedSet<Artifact> transitiveResources; + private final NestedSet<Artifact> transitiveAssets; + private final NestedSet<Artifact> transitiveManifests; + private final NestedSet<Artifact> transitiveAapt2RTxt; + private final NestedSet<Artifact> transitiveSymbolsBin; + private final NestedSet<Artifact> transitiveCompiledSymbols; + private final NestedSet<Artifact> transitiveStaticLib; + private final NestedSet<Artifact> transitiveRTxt; + + AndroidResourcesInfo( + Label label, + NestedSet<ResourceContainer> transitiveAndroidResources, + NestedSet<ResourceContainer> directAndroidResources, + NestedSet<Artifact> transitiveResources, + NestedSet<Artifact> transitiveAssets, + NestedSet<Artifact> transitiveManifests, + NestedSet<Artifact> transitiveAapt2RTxt, + NestedSet<Artifact> transitiveSymbolsBin, + NestedSet<Artifact> transitiveCompiledSymbols, + NestedSet<Artifact> transitiveStaticLib, + NestedSet<Artifact> transitiveRTxt) { + super(PROVIDER); + this.label = label; + this.transitiveAndroidResources = transitiveAndroidResources; + this.directAndroidResources = directAndroidResources; + this.transitiveResources = transitiveResources; + this.transitiveAssets = transitiveAssets; + this.transitiveManifests = transitiveManifests; + this.transitiveAapt2RTxt = transitiveAapt2RTxt; + this.transitiveSymbolsBin = transitiveSymbolsBin; + this.transitiveCompiledSymbols = transitiveCompiledSymbols; + this.transitiveStaticLib = transitiveStaticLib; + this.transitiveRTxt = transitiveRTxt; + } + + /** Returns the label that is associated with this piece of information. */ + @SkylarkCallable(name = "label", doc = "Returns the label for this target.", structField = true) + public Label getLabel() { + return label; + } + + /** Returns the transitive ResourceContainers for the label. */ + @SkylarkCallable( + name = "transitive_android_resources", + doc = "Returns the transitive android resources for the label.", + structField = true + ) + public NestedSet<ResourceContainer> getTransitiveAndroidResources() { + return transitiveAndroidResources; + } + + /** Returns the immediate ResourceContainers for the label. */ + @SkylarkCallable( + name = "direct_android_resources", + doc = "Returns the immediate android resources for the label.", + structField = true + ) + public NestedSet<ResourceContainer> getDirectAndroidResources() { + return directAndroidResources; + } + + public NestedSet<Artifact> getTransitiveResources() { + return transitiveResources; + } + + public NestedSet<Artifact> getTransitiveAssets() { + return transitiveAssets; + } + + public NestedSet<Artifact> getTransitiveManifests() { + return transitiveManifests; + } + + public NestedSet<Artifact> getTransitiveAapt2RTxt() { + return transitiveAapt2RTxt; + } + + public NestedSet<Artifact> getTransitiveSymbolsBin() { + return transitiveSymbolsBin; + } + + public NestedSet<Artifact> getTransitiveCompiledSymbols() { + return transitiveCompiledSymbols; + } + + public NestedSet<Artifact> getTransitiveStaticLib() { + return transitiveStaticLib; + } + + public NestedSet<Artifact> getTransitiveRTxt() { + return transitiveRTxt; + } +} diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProvider.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProvider.java deleted file mode 100644 index 09e48159a5..0000000000 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProvider.java +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2015 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.android; - -import com.google.auto.value.AutoValue; -import com.google.devtools.build.lib.actions.Artifact; -import com.google.devtools.build.lib.analysis.TransitiveInfoProvider; -import com.google.devtools.build.lib.cmdline.Label; -import com.google.devtools.build.lib.collect.nestedset.NestedSet; -import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; - -/** A provider that supplies ResourceContainers from its transitive closure. */ -@AutoValue -@Immutable -public abstract class AndroidResourcesProvider implements TransitiveInfoProvider { - - public static AndroidResourcesProvider create( - Label label, - NestedSet<ResourceContainer> transitiveAndroidResources, - NestedSet<ResourceContainer> directAndroidResources, - NestedSet<Artifact> transitiveResources, - NestedSet<Artifact> transitiveAssets, - NestedSet<Artifact> transitiveManifests, - NestedSet<Artifact> transitiveAapt2RTxt, - NestedSet<Artifact> transitiveSymbolsBin, - NestedSet<Artifact> transitiveCompiledSymbols, - NestedSet<Artifact> transitiveStaticLib, - NestedSet<Artifact> transitiveRTxt) { - return new AutoValue_AndroidResourcesProvider( - label, - transitiveAndroidResources, - directAndroidResources, - transitiveResources, - transitiveAssets, - transitiveManifests, - transitiveAapt2RTxt, - transitiveSymbolsBin, - transitiveCompiledSymbols, - transitiveStaticLib, - transitiveRTxt); - } - - /** Returns the label that is associated with this piece of information. */ - public abstract Label getLabel(); - - /** Returns the transitive ResourceContainers for the label. */ - public abstract NestedSet<ResourceContainer> getTransitiveAndroidResources(); - - /** Returns the immediate ResourceContainers for the label. */ - public abstract NestedSet<ResourceContainer> getDirectAndroidResources(); - - public abstract NestedSet<Artifact> getTransitiveResources(); - - public abstract NestedSet<Artifact> getTransitiveAssets(); - - public abstract NestedSet<Artifact> getTransitiveManifests(); - - public abstract NestedSet<Artifact> getTransitiveAapt2RTxt(); - - public abstract NestedSet<Artifact> getTransitiveSymbolsBin(); - - public abstract NestedSet<Artifact> getTransitiveCompiledSymbols(); - - public abstract NestedSet<Artifact> getTransitiveStaticLib(); - - public abstract NestedSet<Artifact> getTransitiveRTxt(); - - AndroidResourcesProvider() {} -} diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkApiProvider.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkApiProvider.java index b9e9d70968..23c500825e 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkApiProvider.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkApiProvider.java @@ -50,6 +50,11 @@ public class AndroidSkylarkApiProvider extends SkylarkApiProvider { public static final String NAME = "android"; private final IdlInfo idlInfo = new IdlInfo(); + private final AndroidResourcesInfo resourceInfo; + + public AndroidSkylarkApiProvider(AndroidResourcesInfo resourceInfo) { + this.resourceInfo = resourceInfo; + } @SkylarkCallable( name = "apk", @@ -175,8 +180,7 @@ public class AndroidSkylarkApiProvider extends SkylarkApiProvider { } private NestedSet<Artifact> collectDirectArtifacts(final ResourceType resources) { - AndroidResourcesProvider provider = getInfo().getProvider(AndroidResourcesProvider.class); - if (provider == null) { + if (resourceInfo == null) { return NestedSetBuilder.emptySet(Order.STABLE_ORDER); } // This will iterate over all (direct) resources. If this turns out to be a performance @@ -185,7 +189,7 @@ public class AndroidSkylarkApiProvider extends SkylarkApiProvider { Order.STABLE_ORDER, Iterables.concat( Iterables.transform( - provider.getDirectAndroidResources(), + resourceInfo.getDirectAndroidResources(), (ResourceContainer resourceContainer) -> resourceContainer.getArtifacts(resources)))); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/LocalResourceContainer.java b/src/main/java/com/google/devtools/build/lib/rules/android/LocalResourceContainer.java index c754d9e337..e1c0a4b1e4 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/LocalResourceContainer.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/LocalResourceContainer.java @@ -105,12 +105,12 @@ public final class LocalResourceContainer { */ private static void validateNoAndroidResourcesInSources(RuleContext ruleContext) throws RuleErrorException { - Iterable<AndroidResourcesProvider> resources = - ruleContext.getPrerequisites("srcs", Mode.TARGET, AndroidResourcesProvider.class); - for (AndroidResourcesProvider provider : resources) { + Iterable<AndroidResourcesInfo> resources = + ruleContext.getPrerequisites("srcs", Mode.TARGET, AndroidResourcesInfo.PROVIDER); + for (AndroidResourcesInfo info : resources) { ruleContext.throwWithAttributeError( "srcs", - String.format("srcs should not contain label with resources %s", provider.getLabel())); + String.format("srcs should not contain label with resources %s", info.getLabel())); } } @@ -189,40 +189,6 @@ public final class LocalResourceContainer { ImmutableList.of(assetsDir.getExecPath().getChild("assets"))); } - private static ImmutableList<Artifact> getResources(Iterable<FileProvider> targets) { - ImmutableList.Builder<Artifact> builder = ImmutableList.builder(); - for (FileProvider target : targets) { - builder.addAll(target.getFilesToBuild()); - } - - return builder.build(); - } - - /** - * Gets the roots of some resources. - * - * @return a list of roots, or an empty list of the passed resources cannot all be contained in a - * single {@link LocalResourceContainer}. If that's the case, it will be reported to the - * {@link RuleErrorConsumer}. - */ - @VisibleForTesting - static ImmutableList<PathFragment> getResourceRoots( - RuleErrorConsumer ruleErrorConsumer, Iterable<Artifact> files, String resourcesAttr) - throws RuleErrorException { - Artifact lastFile = null; - PathFragment lastResourceDir = null; - Set<PathFragment> resourceRoots = new LinkedHashSet<>(); - for (Artifact file : files) { - PathFragment resourceDir = - addResourceDir( - file, lastFile, lastResourceDir, resourceRoots, resourcesAttr, ruleErrorConsumer); - lastFile = file; - lastResourceDir = resourceDir; - } - - return ImmutableList.copyOf(resourceRoots); - } - /** * Inner method for adding resource roots to a collection. May fail and report to the {@link * RuleErrorConsumer} if the input is invalid. @@ -358,6 +324,15 @@ public final class LocalResourceContainer { this.assetRoots = assetRoots; } + private static ImmutableList<Artifact> getResources(Iterable<FileProvider> targets) { + ImmutableList.Builder<Artifact> builder = ImmutableList.builder(); + for (FileProvider target : targets) { + builder.addAll(target.getFilesToBuild()); + } + + return builder.build(); + } + public ImmutableList<Artifact> getResources() { return resources; } @@ -370,6 +345,31 @@ public final class LocalResourceContainer { return assetRoots; } + /** + * Gets the roots of some resources. + * + * @return a list of roots, or an empty list of the passed resources cannot all be contained in a + * single {@link LocalResourceContainer}. If that's the case, it will be reported to the + * {@link RuleErrorConsumer}. + */ + @VisibleForTesting + static ImmutableList<PathFragment> getResourceRoots( + RuleErrorConsumer ruleErrorConsumer, Iterable<Artifact> files, String resourcesAttr) + throws RuleErrorException { + Artifact lastFile = null; + PathFragment lastResourceDir = null; + Set<PathFragment> resourceRoots = new LinkedHashSet<>(); + for (Artifact file : files) { + PathFragment resourceDir = + addResourceDir( + file, lastFile, lastResourceDir, resourceRoots, resourcesAttr, ruleErrorConsumer); + lastFile = file; + lastResourceDir = resourceDir; + } + + return ImmutableList.copyOf(resourceRoots); + } + public ImmutableList<PathFragment> getResourceRoots() { return resourceRoots; } diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/ResourceApk.java b/src/main/java/com/google/devtools/build/lib/rules/android/ResourceApk.java index 504649d403..24943b7950 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/ResourceApk.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/ResourceApk.java @@ -101,10 +101,10 @@ public final class ResourceApk { * <p>If the ResourceApk was generated from local resources, that will be the direct dependencies * and the rest will be transitive. */ - public AndroidResourcesProvider toResourceProvider(Label label) { + public AndroidResourcesInfo toResourceInfo(Label label) { if (primaryResource == null) { - return resourceDeps.toProvider(label); + return resourceDeps.toInfo(label); } - return resourceDeps.toProvider(label, primaryResource); + return resourceDeps.toInfo(label, primaryResource); } } diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/ResourceContainer.java b/src/main/java/com/google/devtools/build/lib/rules/android/ResourceContainer.java index 845be8ba85..55d40ac048 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/ResourceContainer.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/ResourceContainer.java @@ -24,6 +24,9 @@ import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.rules.java.JavaUtil; +import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable; +import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; +import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; import com.google.devtools.build.lib.syntax.Type; import com.google.devtools.build.lib.vfs.PathFragment; import java.util.Objects; @@ -33,6 +36,11 @@ import javax.annotation.Nullable; /** The resources contributed by a single target. */ @AutoValue @Immutable +@SkylarkModule( + name = "resource_container", + category = SkylarkModuleCategory.NONE, + doc = "The Android resources contributed by a single target." +) public abstract class ResourceContainer { /** The type of resource in question: either asset or a resource. */ public enum ResourceType { @@ -50,6 +58,7 @@ public abstract class ResourceContainer { } } + @SkylarkCallable(name = "label", doc = "Returns the label for this target.", structField = true) public abstract Label getLabel(); @Nullable @@ -129,12 +138,27 @@ public abstract class ResourceContainer { public abstract Artifact getSymbols(); @Nullable + @SkylarkCallable( + name = "compiled_symbols", + doc = "Returns the compiled symbols generated by aapt2.", + structField = true + ) public abstract Artifact getCompiledSymbols(); @Nullable + @SkylarkCallable( + name = "static_library", + doc = "Returns the static library created by aapt2.", + structField = true + ) public abstract Artifact getStaticLibrary(); @Nullable + @SkylarkCallable( + name = "aapt2_r_txt", + doc = "Returns the R.txt generated by aapt2.", + structField = true + ) public abstract Artifact getAapt2RTxt(); @Nullable diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/ResourceDependencies.java b/src/main/java/com/google/devtools/build/lib/rules/android/ResourceDependencies.java index ab9cefb844..9226d3376d 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/ResourceDependencies.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/ResourceDependencies.java @@ -104,8 +104,8 @@ public final class ResourceDependencies { if (!attributes.has(attr, BuildType.LABEL_LIST) && !attributes.has(attr, BuildType.LABEL)) { continue; } - for (AndroidResourcesProvider resources : - ruleContext.getPrerequisites(attr, Mode.TARGET, AndroidResourcesProvider.class)) { + for (AndroidResourcesInfo resources : + ruleContext.getPrerequisites(attr, Mode.TARGET, AndroidResourcesInfo.PROVIDER)) { transitiveDependencies.addTransitive(resources.getTransitiveAndroidResources()); directDependencies.addTransitive(resources.getDirectAndroidResources()); transitiveResources.addTransitive(resources.getTransitiveResources()); @@ -233,23 +233,22 @@ public final class ResourceDependencies { } /** - * Creates a new AndroidResourcesProvider with the supplied ResourceContainer as the direct dep. + * Creates a new AndroidResourcesInfo with the supplied ResourceContainer as the direct dep. * - * <p>When a library produces a new resource container the AndroidResourcesProvider should use - * that container as a the direct dependency for that library. This makes the consuming rule to + * <p>When a library produces a new resource container the AndroidResourcesInfo should use that + * container as a the direct dependency for that library. This makes the consuming rule to * identify the new container and merge appropriately. The previous direct dependencies are then * added to the transitive dependencies. * * @param label The label of the library exporting this provider. - * @param newDirectResource The new direct dependency for AndroidResourcesProvider + * @param newDirectResource The new direct dependency for AndroidResourcesInfo * @return A provider with the current resources and label. */ - public AndroidResourcesProvider toProvider( - Label label, ResourceContainer newDirectResource) { + public AndroidResourcesInfo toInfo(Label label, ResourceContainer newDirectResource) { if (neverlink) { - return ResourceDependencies.empty().toProvider(label); + return ResourceDependencies.empty().toInfo(label); } - return AndroidResourcesProvider.create( + return new AndroidResourcesInfo( label, NestedSetBuilder.<ResourceContainer>naiveLinkOrder() .addTransitive(transitiveResourceContainers) @@ -272,19 +271,8 @@ public final class ResourceDependencies { withDirectAndTransitive(newDirectResource.getRTxt(), transitiveRTxt)); } - private static NestedSet<Artifact> withDirectAndTransitive( - @Nullable Artifact direct, NestedSet<Artifact> transitive) { - NestedSetBuilder<Artifact> builder = NestedSetBuilder.naiveLinkOrder(); - builder.addTransitive(transitive); - if (direct != null) { - builder.add(direct); - } - - return builder.build(); - } - /** - * Create a new AndroidResourcesProvider from the dependencies of this library. + * Create a new AndroidResourcesInfo from the dependencies of this library. * * <p>When a library doesn't export resources it should simply forward the current transitive and * direct resources to the consuming rule. This allows the consuming rule to make decisions about @@ -293,11 +281,11 @@ public final class ResourceDependencies { * @param label The label of the library exporting this provider. * @return A provider with the current resources and label. */ - public AndroidResourcesProvider toProvider(Label label) { + public AndroidResourcesInfo toInfo(Label label) { if (neverlink) { - return ResourceDependencies.empty().toProvider(label); + return ResourceDependencies.empty().toInfo(label); } - return AndroidResourcesProvider.create( + return new AndroidResourcesInfo( label, transitiveResourceContainers, directResourceContainers, @@ -311,6 +299,17 @@ public final class ResourceDependencies { transitiveRTxt); } + private static NestedSet<Artifact> withDirectAndTransitive( + @Nullable Artifact direct, NestedSet<Artifact> transitive) { + NestedSetBuilder<Artifact> builder = NestedSetBuilder.naiveLinkOrder(); + builder.addTransitive(transitive); + if (direct != null) { + builder.add(direct); + } + + return builder.build(); + } + /** * Provides an NestedSet of the direct and transitive resources. * |