Example usage for com.google.common.collect ImmutableMap values

List of usage examples for com.google.common.collect ImmutableMap values

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableMap values.

Prototype

public ImmutableCollection<V> values() 

Source Link

Usage

From source file:com.facebook.buck.thrift.ThriftLibraryDescription.java

/**
 * Create the build rules which compile the input thrift sources into their respective
 * language specific sources./*w  w  w .  j  a va2s  . c  om*/
 */
@VisibleForTesting
protected ImmutableMap<String, ThriftCompiler> createThriftCompilerBuildRules(BuildRuleParams params,
        BuildRuleResolver resolver, CompilerType compilerType, ImmutableList<String> flags, String language,
        ImmutableSet<String> options, ImmutableMap<String, SourcePath> srcs,
        ImmutableSortedSet<ThriftLibrary> deps,
        ImmutableMap<String, ImmutableSortedSet<String>> generatedSources) {

    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
    Tool compiler = thriftBuckConfig.getCompiler(compilerType, resolver);

    // Build up the include roots to find thrift file deps and also the build rules that
    // generate them.
    ImmutableMap.Builder<Path, SourcePath> includesBuilder = ImmutableMap.builder();
    ImmutableSortedSet.Builder<HeaderSymlinkTree> includeTreeRulesBuilder = ImmutableSortedSet.naturalOrder();
    ImmutableList.Builder<Path> includeRootsBuilder = ImmutableList.builder();
    ImmutableSet.Builder<Path> headerMapsBuilder = ImmutableSet.builder();
    for (ThriftLibrary dep : deps) {
        includesBuilder.putAll(dep.getIncludes());
        includeTreeRulesBuilder.add(dep.getIncludeTreeRule());
        includeRootsBuilder.add(dep.getIncludeTreeRule().getIncludePath());
        headerMapsBuilder.addAll(OptionalCompat.asSet(dep.getIncludeTreeRule().getHeaderMap()));
    }
    ImmutableMap<Path, SourcePath> includes = includesBuilder.build();
    ImmutableSortedSet<HeaderSymlinkTree> includeTreeRules = includeTreeRulesBuilder.build();
    ImmutableList<Path> includeRoots = includeRootsBuilder.build();
    ImmutableSet<Path> headerMaps = headerMapsBuilder.build();

    // For each thrift source, add a thrift compile rule to generate it's sources.
    ImmutableMap.Builder<String, ThriftCompiler> compileRules = ImmutableMap.builder();
    for (ImmutableMap.Entry<String, SourcePath> ent : srcs.entrySet()) {
        String name = ent.getKey();
        SourcePath source = ent.getValue();
        ImmutableSortedSet<String> genSrcs = Preconditions.checkNotNull(generatedSources.get(name));

        BuildTarget target = createThriftCompilerBuildTarget(params.getBuildTarget(), name);
        Path outputDir = getThriftCompilerOutputDir(params.getProjectFilesystem(), params.getBuildTarget(),
                name);

        compileRules.put(name, new ThriftCompiler(
                params.copyWithChanges(target, Suppliers.ofInstance(ImmutableSortedSet.<BuildRule>naturalOrder()
                        .addAll(compiler.getDeps(ruleFinder))
                        .addAll(ruleFinder.filterBuildRuleInputs(ImmutableList.<SourcePath>builder().add(source)
                                .addAll(includes.values()).build()))
                        .addAll(includeTreeRules).build()), Suppliers.ofInstance(ImmutableSortedSet.of())),
                compiler, flags, outputDir, source, language, options, includeRoots, headerMaps, includes,
                genSrcs));
    }

    return compileRules.build();
}

From source file:com.facebook.buck.lua.AbstractNativeExecutableStarter.java

private NativeLinkableInput getNativeLinkableInput() throws NoSuchBuildTargetException {
    Iterable<? extends AbstractCxxLibrary> nativeStarterDeps = getNativeStarterDeps();
    ImmutableMap<CxxPreprocessAndCompile, SourcePath> objects = CxxSourceRuleFactory
            .requirePreprocessAndCompileRules(getBaseParams(), getRuleResolver(), getPathResolver(),
                    getRuleFinder(), getCxxBuckConfig(), getCxxPlatform(),
                    ImmutableList.<CxxPreprocessorInput>builder()
                            .add(CxxPreprocessorInput.builder()
                                    .putAllPreprocessorFlags(CxxSource.Type.CXX,
                                            getNativeStarterLibrary().isPresent() ? ImmutableList.of()
                                                    : ImmutableList.of("-DBUILTIN_NATIVE_STARTER"))
                                    .build())
                            .addAll(getTransitiveCxxPreprocessorInput(getCxxPlatform(), nativeStarterDeps))
                            .build(),//from  ww  w.  jav a  2s  .  co m
                    ImmutableMultimap.of(), Optional.empty(), Optional.empty(),
                    ImmutableMap.of("native-starter.cpp", getNativeStarterCxxSource()),
                    CxxSourceRuleFactory.PicType.PDC, Optional.empty());
    return NativeLinkableInput.builder()
            .addAllArgs(getRelativeNativeLibsDir().isPresent() ? StringArg.from(Linkers.iXlinker("-rpath",
                    String.format("%s/%s", getCxxPlatform().getLd().resolve(getRuleResolver()).origin(),
                            getRelativeNativeLibsDir().get().toString())))
                    : ImmutableList.of())
            .addAllArgs(SourcePathArg.from(getPathResolver(), objects.values())).build();
}

From source file:google.registry.dns.writer.clouddns.CloudDnsWriter.java

/**
 * Get a callback to mutate the zone with the provided {@code desiredRecords}.
 *///from  w w  w.j a  v a 2  s .  c om
@VisibleForTesting
Callable<Void> getMutateZoneCallback(
        final ImmutableMap<String, ImmutableSet<ResourceRecordSet>> desiredRecords) {
    return new Callable<Void>() {
        @Override
        public Void call() throws IOException, ZoneStateException {
            // Fetch all existing records for names that this writer is trying to modify
            Builder<ResourceRecordSet> existingRecords = new Builder<>();
            for (String domainName : desiredRecords.keySet()) {
                List<ResourceRecordSet> existingRecordsForDomain = getResourceRecordsForDomain(domainName);
                existingRecords.addAll(existingRecordsForDomain);

                // Fetch glue records for in-bailiwick nameservers
                for (ResourceRecordSet record : existingRecordsForDomain) {
                    if (!record.getType().equals("NS")) {
                        continue;
                    }
                    for (String hostName : record.getRrdatas()) {
                        if (hostName.endsWith(domainName) && !hostName.equals(domainName)) {
                            existingRecords.addAll(getResourceRecordsForDomain(hostName));
                        }
                    }
                }
            }

            // Flatten the desired records into one set.
            Builder<ResourceRecordSet> flattenedDesiredRecords = new Builder<>();
            for (ImmutableSet<ResourceRecordSet> records : desiredRecords.values()) {
                flattenedDesiredRecords.addAll(records);
            }

            // Delete all existing records and add back the desired records
            updateResourceRecords(flattenedDesiredRecords.build(), existingRecords.build());
            return null;
        }
    };
}

From source file:org.elasticsearch.snapshots.SnapshotsService.java

/**
 * Cleans up shard snapshots that were running on removed nodes
 *
 * @param event cluster changed event/* w w  w.  j a  v  a 2 s.  com*/
 */
private void processSnapshotsOnRemovedNodes(ClusterChangedEvent event) {
    if (removedNodesCleanupNeeded(event)) {
        // Check if we just became the master
        final boolean newMaster = !event.previousState().nodes().localNodeMaster();
        clusterService.submitStateUpdateTask("update snapshot state after node removal",
                new ClusterStateUpdateTask() {
                    @Override
                    public ClusterState execute(ClusterState currentState) throws Exception {
                        DiscoveryNodes nodes = currentState.nodes();
                        MetaData metaData = currentState.metaData();
                        MetaData.Builder mdBuilder = MetaData.builder(currentState.metaData());
                        SnapshotMetaData snapshots = metaData.custom(SnapshotMetaData.TYPE);
                        if (snapshots == null) {
                            return currentState;
                        }
                        boolean changed = false;
                        ArrayList<SnapshotMetaData.Entry> entries = newArrayList();
                        for (final SnapshotMetaData.Entry snapshot : snapshots.entries()) {
                            SnapshotMetaData.Entry updatedSnapshot = snapshot;
                            boolean snapshotChanged = false;
                            if (snapshot.state() == State.STARTED || snapshot.state() == State.ABORTED) {
                                ImmutableMap.Builder<ShardId, ShardSnapshotStatus> shards = ImmutableMap
                                        .builder();
                                for (ImmutableMap.Entry<ShardId, ShardSnapshotStatus> shardEntry : snapshot
                                        .shards().entrySet()) {
                                    ShardSnapshotStatus shardStatus = shardEntry.getValue();
                                    if (!shardStatus.state().completed() && shardStatus.nodeId() != null) {
                                        if (nodes.nodeExists(shardStatus.nodeId())) {
                                            shards.put(shardEntry);
                                        } else {
                                            // TODO: Restart snapshot on another node?
                                            snapshotChanged = true;
                                            logger.warn("failing snapshot of shard [{}] on closed node [{}]",
                                                    shardEntry.getKey(), shardStatus.nodeId());
                                            shards.put(shardEntry.getKey(), new ShardSnapshotStatus(
                                                    shardStatus.nodeId(), State.FAILED, "node shutdown"));
                                        }
                                    }
                                }
                                if (snapshotChanged) {
                                    changed = true;
                                    ImmutableMap<ShardId, ShardSnapshotStatus> shardsMap = shards.build();
                                    if (!snapshot.state().completed() && completed(shardsMap.values())) {
                                        updatedSnapshot = new SnapshotMetaData.Entry(snapshot.snapshotId(),
                                                snapshot.includeGlobalState(), State.SUCCESS,
                                                snapshot.indices(), shardsMap);
                                        endSnapshot(updatedSnapshot);
                                    } else {
                                        updatedSnapshot = new SnapshotMetaData.Entry(snapshot.snapshotId(),
                                                snapshot.includeGlobalState(), snapshot.state(),
                                                snapshot.indices(), shardsMap);
                                    }
                                }
                                entries.add(updatedSnapshot);
                            } else if (snapshot.state() == State.INIT && newMaster) {
                                // Clean up the snapshot that failed to start from the old master
                                deleteSnapshot(snapshot.snapshotId(), new DeleteSnapshotListener() {
                                    @Override
                                    public void onResponse() {
                                        logger.debug("cleaned up abandoned snapshot {} in INIT state",
                                                snapshot.snapshotId());
                                    }

                                    @Override
                                    public void onFailure(Throwable t) {
                                        logger.warn("failed to clean up abandoned snapshot {} in INIT state",
                                                snapshot.snapshotId());
                                    }
                                });
                            } else if (snapshot.state() == State.SUCCESS && newMaster) {
                                // Finalize the snapshot
                                endSnapshot(snapshot);
                            }
                        }
                        if (changed) {
                            snapshots = new SnapshotMetaData(
                                    entries.toArray(new SnapshotMetaData.Entry[entries.size()]));
                            mdBuilder.putCustom(SnapshotMetaData.TYPE, snapshots);
                            return ClusterState.builder(currentState).metaData(mdBuilder).build();
                        }
                        return currentState;
                    }

                    @Override
                    public void onFailure(String source, Throwable t) {
                        logger.warn("failed to update snapshot state after node removal");
                    }
                });
    }
}

From source file:com.facebook.buck.features.lua.AbstractNativeExecutableStarter.java

private NativeLinkableInput getNativeLinkableInput() {
    Iterable<? extends AbstractCxxLibrary> nativeStarterDeps = getNativeStarterDeps();
    ImmutableMap<CxxPreprocessAndCompile, SourcePath> objects = CxxSourceRuleFactory
            .of(getProjectFilesystem(), getBaseTarget(), getActionGraphBuilder(), getPathResolver(),
                    getRuleFinder(), getCxxBuckConfig(), getLuaPlatform().getCxxPlatform(),
                    ImmutableList.<CxxPreprocessorInput>builder()
                            .add(CxxPreprocessorInput.builder()
                                    .putAllPreprocessorFlags(CxxSource.Type.CXX,
                                            getNativeStarterLibrary().isPresent() ? ImmutableList.of()
                                                    : StringArg.from("-DBUILTIN_NATIVE_STARTER"))
                                    .build())
                            .addAll(getTransitiveCxxPreprocessorInput(getLuaPlatform().getCxxPlatform(),
                                    nativeStarterDeps))
                            .build(),//from   www.  java2 s  . c om
                    ImmutableMultimap.of(), Optional.empty(), Optional.empty(), PicType.PDC)
            .requirePreprocessAndCompileRules(
                    ImmutableMap.of("native-starter.cpp", getNativeStarterCxxSource()));
    return NativeLinkableInput.builder()
            .addAllArgs(getRelativeNativeLibsDir().isPresent()
                    ? StringArg.from(Linkers.iXlinker("-rpath",
                            String.format("%s/%s",
                                    getLuaPlatform().getCxxPlatform().getLd().resolve(getActionGraphBuilder())
                                            .origin(),
                                    getRelativeNativeLibsDir().get().toString())))
                    : ImmutableList.of())
            .addAllArgs(SourcePathArg.from(objects.values())).build();
}

From source file:org.elasticsearch.snapshots.SnapshotsService.java

private void processStartedShards(ClusterChangedEvent event) {
    if (waitingShardsStartedOrUnassigned(event)) {
        clusterService.submitStateUpdateTask("update snapshot state after shards started",
                new ClusterStateUpdateTask() {
                    @Override//from w  w w  . ja  v  a 2s . c om
                    public ClusterState execute(ClusterState currentState) throws Exception {
                        MetaData metaData = currentState.metaData();
                        RoutingTable routingTable = currentState.routingTable();
                        MetaData.Builder mdBuilder = MetaData.builder(currentState.metaData());
                        SnapshotMetaData snapshots = metaData.custom(SnapshotMetaData.TYPE);
                        if (snapshots != null) {
                            boolean changed = false;
                            ArrayList<SnapshotMetaData.Entry> entries = newArrayList();
                            for (final SnapshotMetaData.Entry snapshot : snapshots.entries()) {
                                SnapshotMetaData.Entry updatedSnapshot = snapshot;
                                if (snapshot.state() == State.STARTED) {
                                    ImmutableMap<ShardId, ShardSnapshotStatus> shards = processWaitingShards(
                                            snapshot.shards(), routingTable);
                                    if (shards != null) {
                                        changed = true;
                                        if (!snapshot.state().completed() && completed(shards.values())) {
                                            updatedSnapshot = new SnapshotMetaData.Entry(snapshot.snapshotId(),
                                                    snapshot.includeGlobalState(), State.SUCCESS,
                                                    snapshot.indices(), shards);
                                            endSnapshot(updatedSnapshot);
                                        } else {
                                            updatedSnapshot = new SnapshotMetaData.Entry(snapshot.snapshotId(),
                                                    snapshot.includeGlobalState(), snapshot.state(),
                                                    snapshot.indices(), shards);
                                        }
                                    }
                                    entries.add(updatedSnapshot);
                                }
                            }
                            if (changed) {
                                snapshots = new SnapshotMetaData(
                                        entries.toArray(new SnapshotMetaData.Entry[entries.size()]));
                                mdBuilder.putCustom(SnapshotMetaData.TYPE, snapshots);
                                return ClusterState.builder(currentState).metaData(mdBuilder).build();
                            }
                        }
                        return currentState;
                    }

                    @Override
                    public void onFailure(String source, Throwable t) {
                        logger.warn("failed to update snapshot state after shards started from [{}] ", t,
                                source);
                    }
                });
    }
}

From source file:com.facebook.buck.android.AndroidBinary.java

/**
 * @return the resulting set of ProGuarded classpath entries to dex.
 *//*from  w  ww  . j  a  v  a  2  s.co m*/
@VisibleForTesting
ImmutableSet<Path> addProguardCommands(Set<Path> classpathEntriesToDex, Set<Path> depsProguardConfigs,
        ImmutableList.Builder<Step> steps, Set<Path> resDirectories, BuildableContext buildableContext) {
    final ImmutableSetMultimap<JavaLibrary, Path> classpathEntriesMap = getTransitiveClasspathEntries();
    ImmutableSet.Builder<Path> additionalLibraryJarsForProguardBuilder = ImmutableSet.builder();

    for (JavaLibrary buildRule : rulesToExcludeFromDex) {
        additionalLibraryJarsForProguardBuilder.addAll(classpathEntriesMap.get(buildRule));
    }

    // Clean out the directory for generated ProGuard files.
    Path proguardDirectory = getPathForProGuardDirectory();
    steps.add(new MakeCleanDirectoryStep(proguardDirectory));

    // Generate a file of ProGuard config options using aapt.
    Path generatedProGuardConfig = proguardDirectory.resolve("proguard.txt");
    GenProGuardConfigStep genProGuardConfig = new GenProGuardConfigStep(
            aaptPackageResources.getAndroidManifestXml(), resDirectories, generatedProGuardConfig);
    steps.add(genProGuardConfig);

    // Create list of proguard Configs for the app project and its dependencies
    ImmutableSet.Builder<Path> proguardConfigsBuilder = ImmutableSet.builder();
    proguardConfigsBuilder.addAll(depsProguardConfigs);
    if (proguardConfig.isPresent()) {
        proguardConfigsBuilder.add(proguardConfig.get().resolve());
    }

    // Transform our input classpath to a set of output locations for each input classpath.
    // TODO(devjasta): the output path we choose is the result of a slicing function against
    // input classpath. This is fragile and should be replaced with knowledge of the BuildTarget.
    final ImmutableMap<Path, Path> inputOutputEntries = FluentIterable.from(classpathEntriesToDex)
            .toMap(new Function<Path, Path>() {
                @Override
                public Path apply(Path classpathEntry) {
                    return getProguardOutputFromInputClasspath(classpathEntry);
                }
            });

    // Run ProGuard on the classpath entries.
    // TODO(user): ProGuardObfuscateStep's final argument should be a Path
    Step obfuscateCommand = ProGuardObfuscateStep.create(proguardJarOverride, generatedProGuardConfig,
            proguardConfigsBuilder.build(), useAndroidProguardConfigWithOptimizations, optimizationPasses,
            inputOutputEntries, additionalLibraryJarsForProguardBuilder.build(), proguardDirectory,
            buildableContext);
    steps.add(obfuscateCommand);

    // Apply the transformed inputs to the classpath (this will modify deps.classpathEntriesToDex
    // so that we're now dexing the proguarded artifacts).
    return ImmutableSet.copyOf(inputOutputEntries.values());
}

From source file:com.aitorvs.autoparcel.internal.codegen.AutoParcelProcessor.java

private String generateClass(TypeElement type, String className, String classToExtend, boolean isFinal) {
    if (type == null) {
        mErrorReporter.abortWithError("generateClass was invoked with null type", type);
    }/*from  w w  w.j a  v a  2 s  . c  om*/
    if (className == null) {
        mErrorReporter.abortWithError("generateClass was invoked with null class name", type);
    }
    if (classToExtend == null) {
        mErrorReporter.abortWithError("generateClass was invoked with null parent class", type);
    }
    List<VariableElement> nonPrivateFields = getParcelableFieldsOrError(type);
    if (nonPrivateFields.isEmpty()) {
        mErrorReporter.abortWithError("generateClass error, all fields are declared PRIVATE", type);
    }

    // get the properties
    ImmutableList<Property> properties = buildProperties(nonPrivateFields);

    // get the type adapters
    ImmutableMap<TypeMirror, FieldSpec> typeAdapters = getTypeAdapters(properties);

    // get the parcel version
    //noinspection ConstantConditions
    int version = type.getAnnotation(AutoParcel.class).version();

    // Generate the AutoParcel_??? class
    String pkg = TypeUtil.packageNameOf(type);
    TypeName classTypeName = ClassName.get(pkg, className);
    TypeSpec.Builder subClass = TypeSpec.classBuilder(className)
            // Add the version
            .addField(TypeName.INT, "version", PRIVATE)
            // Class must be always final
            .addModifiers(FINAL)
            // extends from original abstract class
            .superclass(ClassName.get(pkg, classToExtend))
            // Add the DEFAULT constructor
            .addMethod(generateConstructor(properties))
            // Add the private constructor
            .addMethod(generateConstructorFromParcel(processingEnv, properties, typeAdapters))
            // overrides describeContents()
            .addMethod(generateDescribeContents())
            // static final CREATOR
            .addField(generateCreator(processingEnv, properties, classTypeName, typeAdapters))
            // overrides writeToParcel()
            .addMethod(generateWriteToParcel(version, processingEnv, properties, typeAdapters)); // generate writeToParcel()

    if (!ancestoIsParcelable(processingEnv, type)) {
        // Implement android.os.Parcelable if the ancestor does not do it.
        subClass.addSuperinterface(ClassName.get("android.os", "Parcelable"));
    }

    if (!typeAdapters.isEmpty()) {
        typeAdapters.values().forEach(subClass::addField);
    }

    JavaFile javaFile = JavaFile.builder(pkg, subClass.build()).build();
    return javaFile.toString();
}

From source file:com.facebook.buck.artifact_cache.AbstractAsynchronousCache.java

private void doMultiCheck(ImmutableMap<RuleKey, ClaimedFetchRequest> ruleKeyToRequest) {
    try {/*w  w  w .j a va  2  s . c  o  m*/
        ImmutableMap<RuleKey, CacheResult> ruleKeyToResult = multiContainsImpl(ruleKeyToRequest.keySet())
                .getCacheResults();
        for (Map.Entry<RuleKey, CacheResult> result : ruleKeyToResult.entrySet()) {
            CacheResult cacheResult = result.getValue();
            ClaimedFetchRequest claimedFetchRequest = ruleKeyToRequest.get(result.getKey());
            if (claimedFetchRequest == null) {
                LOG.verbose("Recived cache result for not requested rule key.");
                continue;
            }
            if (!cacheResult.getType().isSuccess()) {
                // If rule key is not present in the cache, there is no point in trying to download
                // it.
                claimedFetchRequest.setResult(cacheResult);
            } else {
                // Otherwise reschedule it. It will be added to the fetch queue and it will be picked
                // by fetching thread.
                claimedFetchRequest.reschedule();
            }
        }
    } catch (IOException e) {
        String msg = String.format("multicheck(<%s>): %s: %s", Joiner.on(", ").join(ruleKeyToRequest.keySet()),
                e.getClass().getName(), e.getMessage());
        // Some of these might already be fulfilled. That's fine, this set() call will just be
        // ignored.
        for (ClaimedFetchRequest request : ruleKeyToRequest.values()) {
            request.setResult(CacheResult.error(name, mode, msg));
        }
    }
}

From source file:com.facebook.buck.jvm.java.JavaBinaryDescription.java

@Override
public <A extends Args> BuildRule createBuildRule(TargetGraph targetGraph, BuildRuleParams params,
        BuildRuleResolver resolver, A args) throws NoSuchBuildTargetException {

    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
    SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
    ImmutableMap<String, SourcePath> nativeLibraries = JavaLibraryRules.getNativeLibraries(params.getDeps(),
            cxxPlatform);//from  w w  w  . j ava 2  s . co  m
    BuildRuleParams binaryParams = params;

    // If we're packaging native libraries, we'll build the binary JAR in a separate rule and
    // package it into the final fat JAR, so adjust it's params to use a flavored target.
    if (!nativeLibraries.isEmpty()) {
        binaryParams = params.copyWithChanges(
                params.getBuildTarget().withAppendedFlavors(FAT_JAR_INNER_JAR_FLAVOR), params.getDeclaredDeps(),
                params.getExtraDeps());
    }

    // Construct the build rule to build the binary JAR.
    ImmutableSet<JavaLibrary> transitiveClasspathDeps = JavaLibraryClasspathProvider
            .getClasspathDeps(binaryParams.getDeps());
    ImmutableSet<Path> transitiveClasspaths = JavaLibraryClasspathProvider
            .getClasspathsFromLibraries(transitiveClasspathDeps);
    BuildRule rule = new JavaBinary(binaryParams.appendExtraDeps(transitiveClasspathDeps), pathResolver,
            javaOptions.getJavaRuntimeLauncher(), args.mainClass.orElse(null), args.manifestFile.orElse(null),
            args.mergeManifests.orElse(true), args.metaInfDirectory.orElse(null), args.blacklist,
            transitiveClasspathDeps, transitiveClasspaths, javaBuckConfig.shouldCacheBinaries());

    // If we're packaging native libraries, construct the rule to build the fat JAR, which packages
    // up the original binary JAR and any required native libraries.
    if (!nativeLibraries.isEmpty()) {
        BuildRule innerJarRule = rule;
        resolver.addToIndex(innerJarRule);
        SourcePath innerJar = new BuildTargetSourcePath(innerJarRule.getBuildTarget());
        rule = new JarFattener(
                params.appendExtraDeps(Suppliers.<Iterable<BuildRule>>ofInstance(
                        ruleFinder.filterBuildRuleInputs(ImmutableList.<SourcePath>builder().add(innerJar)
                                .addAll(nativeLibraries.values()).build()))),
                pathResolver, ruleFinder, javacOptions, innerJar, nativeLibraries,
                javaOptions.getJavaRuntimeLauncher());
    }

    return rule;
}