Program: 110549
Project: 110549
Buggy source:
@Override public ConfiguredTarget create(RuleContext ruleContext) throws InterruptedException, RuleErrorException, ActionConflictException {
  validateRuleContext(ruleContext);
  JavaSemantics javaSemantics=createJavaSemantics();
  AndroidSemantics androidSemantics=createAndroidSemantics();
  androidSemantics.validateAndroidLibraryRuleContext(ruleContext);
  createAndroidMigrationSemantics().validateRuleContext(ruleContext);
  AndroidSdkProvider.verifyPresence(ruleContext);
  NestedSetBuilder<Aar> transitiveAars=NestedSetBuilder.naiveLinkOrder();
  NestedSetBuilder<Artifact> transitiveAarArtifacts=NestedSetBuilder.stableOrder();
  collectTransitiveAars(ruleContext,transitiveAars,transitiveAarArtifacts);
  NestedSetBuilder<Artifact> proguardConfigsbuilder=NestedSetBuilder.stableOrder();
  ProguardLibrary proguardLibrary=new ProguardLibrary(ruleContext);
  proguardConfigsbuilder.addTransitive(proguardLibrary.collectProguardSpecs());
  AndroidIdlHelper.maybeAddSupportLibProguardConfigs(ruleContext,proguardConfigsbuilder);
  NestedSet<Artifact> transitiveProguardConfigs=proguardConfigsbuilder.build();
  JavaCommon javaCommon=AndroidCommon.createJavaCommonWithAndroidDataBinding(ruleContext,javaSemantics,true);
  javaSemantics.checkRule(ruleContext,javaCommon);
  AndroidCommon androidCommon=new AndroidCommon(javaCommon);
  AndroidConfiguration androidConfig=AndroidCommon.getAndroidConfig(ruleContext);
  boolean definesLocalResources=AndroidResources.definesAndroidResources(ruleContext.attributes());
  if (definesLocalResources) {
    AndroidResources.validateRuleContext(ruleContext);
  }
  boolean isNeverLink=JavaCommon.isNeverLink(ruleContext) && (definesLocalResources || androidConfig.fixedResourceNeverlinking());
  ResourceDependencies resourceDeps=ResourceDependencies.fromRuleDeps(ruleContext,isNeverLink);
  AssetDependencies assetDeps=AssetDependencies.fromRuleDeps(ruleContext,isNeverLink);
  final ResourceApk resourceApk;
  if (definesLocalResources) {
    if (androidConfig.decoupleDataProcessing()) {
      StampedAndroidManifest manifest=AndroidManifest.from(ruleContext,androidSemantics).stamp(ruleContext);
      ValidatedAndroidResources resources=AndroidResources.from(ruleContext,"String_Node_Str").process(ruleContext,manifest,isNeverLink);
      MergedAndroidAssets assets=AndroidAssets.from(ruleContext).process(ruleContext,isNeverLink);
      resourceApk=ResourceApk.of(resources,assets);
    }
 else {
      ApplicationManifest applicationManifest=androidSemantics.getManifestForRule(ruleContext).renamePackage(ruleContext,AndroidCommon.getJavaPackage(ruleContext));
      resourceApk=applicationManifest.packLibraryWithDataAndResources(ruleContext,resourceDeps,ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_R_TXT),ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_MERGED_SYMBOLS),ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_PROCESSED_MANIFEST),ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_RESOURCES_ZIP),DataBinding.isEnabled(ruleContext) ? DataBinding.getLayoutInfoFile(ruleContext) : null);
    }
    if (ruleContext.hasErrors()) {
      return null;
    }
  }
 else {
    resourceApk=ResourceApk.processFromTransitiveLibraryData(ruleContext,resourceDeps,assetDeps,StampedAndroidManifest.createEmpty(ruleContext,false));
  }
  JavaTargetAttributes javaTargetAttributes=androidCommon.init(javaSemantics,androidSemantics,resourceApk,false,true,false,null,false);
  if (javaTargetAttributes == null) {
    return null;
  }
  Artifact classesJar=ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_LIBRARY_CLASS_JAR);
  Artifact aarOut=ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_LIBRARY_AAR);
  final Aar aar;
  if (definesLocalResources) {
    aar=Aar.create(aarOut,resourceApk.getManifest());
    addAarToProvider(aar,transitiveAars,transitiveAarArtifacts);
  }
 else {
    aar=null;
  }
  new AarGeneratorBuilder(ruleContext).withPrimaryResources(resourceApk.getPrimaryResources()).withPrimaryAssets(resourceApk.getPrimaryAssets()).withManifest(resourceApk.getManifest()).withRtxt(resourceApk.getRTxt()).withClasses(classesJar).setAAROut(aarOut).setProguardSpecs(proguardLibrary.collectLocalProguardSpecs()).setThrowOnResourceConflict(androidConfig.throwOnResourceConflict()).build(ruleContext);
  RuleConfiguredTargetBuilder builder=new RuleConfiguredTargetBuilder(ruleContext);
  androidCommon.addTransitiveInfoProviders(builder,aarOut,resourceApk,null,ImmutableList.<Artifact>of(),NativeLibs.EMPTY,androidCommon.isNeverLink());
  NestedSetBuilder<Artifact> transitiveResourcesJars=collectTransitiveResourceJars(ruleContext);
  if (resourceApk.getResourceJavaClassJar() != null) {
    transitiveResourcesJars.add(resourceApk.getResourceJavaClassJar());
  }
  builder.addNativeDeclaredProvider(new AndroidNativeLibsInfo(AndroidCommon.collectTransitiveNativeLibs(ruleContext).build())).add(JavaSourceInfoProvider.class,JavaSourceInfoProvider.fromJavaTargetAttributes(javaTargetAttributes,javaSemantics)).add(AndroidCcLinkParamsProvider.class,AndroidCcLinkParamsProvider.create(androidCommon.getCcLinkParamsStore())).add(ProguardSpecProvider.class,new ProguardSpecProvider(transitiveProguardConfigs)).addOutputGroup(OutputGroupInfo.HIDDEN_TOP_LEVEL,transitiveProguardConfigs).add(AndroidLibraryResourceClassJarProvider.class,AndroidLibraryResourceClassJarProvider.create(transitiveResourcesJars.build()));
  if (!JavaCommon.isNeverLink(ruleContext)) {
    builder.add(AndroidLibraryAarProvider.class,AndroidLibraryAarProvider.create(aar,transitiveAars.build(),transitiveAarArtifacts.build()));
  }
  return builder.build();
}

Fixed version (ground truth):
@Override public ConfiguredTarget create(RuleContext ruleContext) throws InterruptedException, RuleErrorException, ActionConflictException {
  validateRuleContext(ruleContext);
  JavaSemantics javaSemantics=createJavaSemantics();
  AndroidSemantics androidSemantics=createAndroidSemantics();
  androidSemantics.validateAndroidLibraryRuleContext(ruleContext);
  createAndroidMigrationSemantics().validateRuleContext(ruleContext);
  AndroidSdkProvider.verifyPresence(ruleContext);
  NestedSetBuilder<Aar> transitiveAars=NestedSetBuilder.naiveLinkOrder();
  NestedSetBuilder<Artifact> transitiveAarArtifacts=NestedSetBuilder.stableOrder();
  collectTransitiveAars(ruleContext,transitiveAars,transitiveAarArtifacts);
  NestedSetBuilder<Artifact> proguardConfigsbuilder=NestedSetBuilder.stableOrder();
  ProguardLibrary proguardLibrary=new ProguardLibrary(ruleContext);
  proguardConfigsbuilder.addTransitive(proguardLibrary.collectProguardSpecs());
  AndroidIdlHelper.maybeAddSupportLibProguardConfigs(ruleContext,proguardConfigsbuilder);
  NestedSet<Artifact> transitiveProguardConfigs=proguardConfigsbuilder.build();
  JavaCommon javaCommon=AndroidCommon.createJavaCommonWithAndroidDataBinding(ruleContext,javaSemantics,true);
  javaSemantics.checkRule(ruleContext,javaCommon);
  AndroidCommon androidCommon=new AndroidCommon(javaCommon);
  AndroidConfiguration androidConfig=AndroidCommon.getAndroidConfig(ruleContext);
  boolean definesLocalResources=AndroidResources.definesAndroidResources(ruleContext.attributes());
  if (definesLocalResources) {
    AndroidResources.validateRuleContext(ruleContext);
  }
  boolean isNeverLink=JavaCommon.isNeverLink(ruleContext) && (definesLocalResources || androidConfig.fixedResourceNeverlinking());
  ResourceDependencies resourceDeps=ResourceDependencies.fromRuleDeps(ruleContext,isNeverLink);
  AssetDependencies assetDeps=AssetDependencies.fromRuleDeps(ruleContext,isNeverLink);
  final ResourceApk resourceApk;
  if (definesLocalResources) {
    if (androidConfig.decoupleDataProcessing()) {
      StampedAndroidManifest manifest=AndroidManifest.from(ruleContext,androidSemantics).stamp(ruleContext);
      ValidatedAndroidResources resources=AndroidResources.from(ruleContext,"String_Node_Str").process(ruleContext,manifest,isNeverLink);
      MergedAndroidAssets assets=AndroidAssets.from(ruleContext).process(ruleContext,isNeverLink);
      resourceApk=ResourceApk.of(resources,assets,null,null);
    }
 else {
      ApplicationManifest applicationManifest=androidSemantics.getManifestForRule(ruleContext).renamePackage(ruleContext,AndroidCommon.getJavaPackage(ruleContext));
      resourceApk=applicationManifest.packLibraryWithDataAndResources(ruleContext,resourceDeps,ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_R_TXT),ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_MERGED_SYMBOLS),ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_PROCESSED_MANIFEST),ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_RESOURCES_ZIP),DataBinding.isEnabled(ruleContext) ? DataBinding.getLayoutInfoFile(ruleContext) : null);
    }
    if (ruleContext.hasErrors()) {
      return null;
    }
  }
 else {
    resourceApk=ResourceApk.processFromTransitiveLibraryData(ruleContext,resourceDeps,assetDeps,StampedAndroidManifest.createEmpty(ruleContext,false));
  }
  JavaTargetAttributes javaTargetAttributes=androidCommon.init(javaSemantics,androidSemantics,resourceApk,false,true,false,null,false);
  if (javaTargetAttributes == null) {
    return null;
  }
  Artifact classesJar=ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_LIBRARY_CLASS_JAR);
  Artifact aarOut=ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_LIBRARY_AAR);
  final Aar aar;
  if (definesLocalResources) {
    aar=Aar.create(aarOut,resourceApk.getManifest());
    addAarToProvider(aar,transitiveAars,transitiveAarArtifacts);
  }
 else {
    aar=null;
  }
  new AarGeneratorBuilder(ruleContext).withPrimaryResources(resourceApk.getPrimaryResources()).withPrimaryAssets(resourceApk.getPrimaryAssets()).withManifest(resourceApk.getManifest()).withRtxt(resourceApk.getRTxt()).withClasses(classesJar).setAAROut(aarOut).setProguardSpecs(proguardLibrary.collectLocalProguardSpecs()).setThrowOnResourceConflict(androidConfig.throwOnResourceConflict()).build(ruleContext);
  RuleConfiguredTargetBuilder builder=new RuleConfiguredTargetBuilder(ruleContext);
  androidCommon.addTransitiveInfoProviders(builder,aarOut,resourceApk,null,ImmutableList.<Artifact>of(),NativeLibs.EMPTY,androidCommon.isNeverLink());
  NestedSetBuilder<Artifact> transitiveResourcesJars=collectTransitiveResourceJars(ruleContext);
  if (resourceApk.getResourceJavaClassJar() != null) {
    transitiveResourcesJars.add(resourceApk.getResourceJavaClassJar());
  }
  builder.addNativeDeclaredProvider(new AndroidNativeLibsInfo(AndroidCommon.collectTransitiveNativeLibs(ruleContext).build())).add(JavaSourceInfoProvider.class,JavaSourceInfoProvider.fromJavaTargetAttributes(javaTargetAttributes,javaSemantics)).add(AndroidCcLinkParamsProvider.class,AndroidCcLinkParamsProvider.create(androidCommon.getCcLinkParamsStore())).add(ProguardSpecProvider.class,new ProguardSpecProvider(transitiveProguardConfigs)).addOutputGroup(OutputGroupInfo.HIDDEN_TOP_LEVEL,transitiveProguardConfigs).add(AndroidLibraryResourceClassJarProvider.class,AndroidLibraryResourceClassJarProvider.create(transitiveResourcesJars.build()));
  if (!JavaCommon.isNeverLink(ruleContext)) {
    builder.add(AndroidLibraryAarProvider.class,AndroidLibraryAarProvider.create(aar,transitiveAars.build(),transitiveAarArtifacts.build()));
  }
  return builder.build();
}