Example usage for com.google.common.collect ImmutableList.Builder addAll

List of usage examples for com.google.common.collect ImmutableList.Builder addAll

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableList.Builder addAll.

Prototype

boolean addAll(Collection<? extends E> c);

Source Link

Document

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation).

Usage

From source file:com.facebook.buck.apple.MultiarchFile.java

private void lipoBinaries(BuildContext context, ImmutableList.Builder<Step> steps) {
    ImmutableList.Builder<String> commandBuilder = ImmutableList.builder();
    commandBuilder.addAll(lipo.getCommandPrefix(context.getSourcePathResolver()));
    commandBuilder.add("-create", "-output", getProjectFilesystem().resolve(output).toString());
    for (SourcePath thinBinary : thinBinaries) {
        commandBuilder.add(context.getSourcePathResolver().getAbsolutePath(thinBinary).toString());
    }/*from   w  w  w. j  av  a  2  s  .  c  om*/
    steps.add(new DefaultShellStep(getProjectFilesystem().getRootPath(), commandBuilder.build(),
            lipo.getEnvironment()));
}

From source file:org.openqa.selenium.buck.file.Folder.java

@Override
public ImmutableList<Step> getBuildSteps(BuildContext buildContext, ProjectFilesystem filesystem,
        OutputPathResolver outputPathResolver, BuildCellRelativePathFactory buildCellPathFactory) {
    ImmutableList.Builder<Step> steps = ImmutableList.builder();

    Path out = outputPathResolver.resolvePath(output);
    steps.addAll(MakeCleanDirectoryStep.of(buildCellPathFactory.from(out.getParent())));

    Path scratch = BuildTargetPaths.getScratchPath(getProjectFilesystem(), getBuildTarget(),
            "%s-scratch/" + folderName);
    steps.addAll(MakeCleanDirectoryStep.of(buildCellPathFactory.from(scratch)));

    FileBundler bundler = new SrcZipAwareFileBundler(getBuildTarget(), PatternsMatcher.EMPTY);
    bundler.copy(getProjectFilesystem(), buildCellPathFactory, steps, scratch, srcs,
            buildContext.getSourcePathResolver());
    steps.add(new ZipStep(getProjectFilesystem(), out, ImmutableSet.of(), false, DEFAULT, scratch.getParent()));

    return steps.build();
}

From source file:com.facebook.buck.features.go.CGoGenSource.java

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {

    ImmutableList.Builder<Step> steps = ImmutableList.builder();
    steps.addAll(MakeCleanDirectoryStep.of(BuildCellRelativePath
            .fromCellRelativePath(context.getBuildCellRootPath(), getProjectFilesystem(), genDir)));
    steps.add(new CGoCompileStep(getProjectFilesystem().getRootPath(),
            cgo.getEnvironment(context.getSourcePathResolver()),
            cgo.getCommandPrefix(context.getSourcePathResolver()), cgoCompilerFlags,
            cgoSrcs.stream().map(context.getSourcePathResolver()::getRelativePath)
                    .collect(ImmutableList.toImmutableList()),
            includeDirs, platform, genDir));

    buildableContext.recordArtifact(genDir);
    return steps.build();
}

From source file:com.facebook.buck.features.go.GoTestCoverSource.java

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {

    ImmutableList.Builder<Step> steps = ImmutableList.builder();
    steps.addAll(MakeCleanDirectoryStep.of(BuildCellRelativePath
            .fromCellRelativePath(context.getBuildCellRootPath(), getProjectFilesystem(), genDir)));

    for (Map.Entry<SourcePath, SourcePath> entry : coveredSources.entrySet()) {
        steps.add(new GoTestCoverStep(getProjectFilesystem().getRootPath(),
                context.getSourcePathResolver().getAbsolutePath(entry.getKey()),
                genDir.resolve(context.getSourcePathResolver().getAbsolutePath(entry.getValue())),
                cover.getEnvironment(context.getSourcePathResolver()),
                cover.getCommandPrefix(context.getSourcePathResolver()), coverageMode));
    }/*from w w  w  .  ja  v a2s.c  om*/

    buildableContext.recordArtifact(genDir);
    return steps.build();
}

From source file:com.facebook.buck.features.ocaml.OcamlDebugLauncherStep.java

private String getDebugCmd() {
    ImmutableList.Builder<String> debugCmd = ImmutableList.builder();
    debugCmd.add("rlwrap");
    debugCmd.addAll(args.ocamlDebug.getCommandPrefix(resolver));

    ImmutableList<String> includesBytecodeFlags = ImmutableList.copyOf(MoreIterables.zipAndConcat(
            Iterables.cycle(OcamlCompilables.OCAML_INCLUDE_FLAG), args.transitiveBytecodeIncludes));

    debugCmd.addAll(includesBytecodeFlags);
    debugCmd.addAll(args.bytecodeIncludeFlags);

    debugCmd.add(args.bytecodeOutput.toString());
    return Shell.shellQuoteJoin(debugCmd.build(), " ") + " $@";
}

From source file:com.spotify.heroic.aggregation.AbstractAggregationDSL.java

protected List<Aggregation> flatten(final Value value) {
    if (value instanceof ListValue) {
        final ImmutableList.Builder<Aggregation> aggregations = ImmutableList.builder();

        for (final Value item : ((ListValue) value).getList()) {
            aggregations.addAll(flatten(item));
        }// w ww  .j a v  a2  s .  c  o  m

        return aggregations.build();
    }

    return ImmutableList.of(asAggregation(value.cast(AggregationValue.class)));
}

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

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    final Path projectRoot = context.getProjectRoot();
    ImmutableList.Builder<Step> steps = ImmutableList.builder();
    steps.add(new MakeCleanDirectoryStep(genPath));
    steps.addAll(FluentIterable.from(srcs).transform(new Function<SourcePath, Step>() {
        @Override//w w w.ja  v  a 2 s . c o m
        public Step apply(SourcePath input) {
            return new ThriftStep(input.resolve(), /* outputDir */ Optional.of(genPath),
                    /* outputLocation */ Optional.<Path>absent(),
                    /* includePaths */ ImmutableSortedSet.<Path>of(projectRoot), ImmutableSortedSet.of(JAVA),
                    /* commandLineArgs */ ImmutableSortedSet.<String>of());
        }
    }).toList());

    Path genJavaPath = genPath.resolve("gen-java");
    steps.add(new RmStep(srcJarOutputPath, true));
    steps.add(new ZipStep(srcJarOutputPath, /* paths */ ImmutableSet.<Path>of(), /* junkPaths */ false,
            ZipStep.DEFAULT_COMPRESSION_LEVEL, genJavaPath));
    buildableContext.recordArtifact(srcJarOutputPath);
    return steps.build();
}

From source file:org.openqa.selenium.buck.mozilla.Xpi.java

@Override
public ImmutableList<Step> getBuildSteps(BuildContext buildContext, ProjectFilesystem filesystem,
        OutputPathResolver outputPathResolver, BuildCellRelativePathFactory buildCellPathFactory) {
    Path scratch = BuildTargetPaths.getScratchPath(getProjectFilesystem(), getBuildTarget(), "%s-xpi");

    ImmutableList.Builder<Step> steps = ImmutableList.builder();

    steps.addAll(MakeCleanDirectoryStep.of(buildCellPathFactory.from(scratch)));

    steps.add(CopyStep.forFile(getProjectFilesystem(),
            buildContext.getSourcePathResolver().getAbsolutePath(chrome), scratch.resolve("chrome.manifest")));
    steps.add(CopyStep.forFile(getProjectFilesystem(),
            buildContext.getSourcePathResolver().getAbsolutePath(install), scratch.resolve("install.rdf")));

    FileBundler bundler = new SrcZipAwareFileBundler(getBuildTarget(), PatternsMatcher.EMPTY);

    Path contentDir = scratch.resolve("content");
    steps.add(MkdirStep.of(buildCellPathFactory.from(contentDir)));
    bundler.copy(getProjectFilesystem(), buildCellPathFactory, steps, contentDir, content,
            buildContext.getSourcePathResolver());

    Path componentDir = scratch.resolve("components");
    steps.add(MkdirStep.of(buildCellPathFactory.from(componentDir)));
    bundler.copy(getProjectFilesystem(), buildCellPathFactory, steps, componentDir, components,
            buildContext.getSourcePathResolver());

    Path platformDir = scratch.resolve("platform");
    steps.add(MkdirStep.of(buildCellPathFactory.from(platformDir)));
    bundler.copy(getProjectFilesystem(), buildCellPathFactory, steps, platformDir, platforms,
            buildContext.getSourcePathResolver());

    Path resourceDir = scratch.resolve("resource");
    steps.add(MkdirStep.of(buildCellPathFactory.from(resourceDir)));
    bundler.copy(getProjectFilesystem(), buildCellPathFactory, steps, resourceDir, resources,
            buildContext.getSourcePathResolver());

    Path out = outputPathResolver.resolvePath(output);
    steps.addAll(MakeCleanDirectoryStep.of(buildCellPathFactory.from(out.getParent())));
    steps.add(new ZipStep(getProjectFilesystem(), out.normalize().toAbsolutePath(), ImmutableSet.of(), false,
            DEFAULT, scratch));//from  ww w  .j a v  a  2s  . c om

    return steps.build();
}

From source file:org.mule.config.spring.CompositeOptionalObjectsController.java

@Override
public Collection<String> getAllOptionalKeys() {
    ImmutableList.Builder<String> builder = ImmutableList.builder();
    for (OptionalObjectsController controller : controllers) {
        builder.addAll(controller.getAllOptionalKeys());
    }//ww w.  ja  v a2s . co m

    return builder.build();
}

From source file:com.facebook.presto.sql.planner.plan.AggregationNode.java

@Override
public List<Symbol> getOutputSymbols() {
    ImmutableList.Builder<Symbol> symbols = ImmutableList.builder();
    symbols.addAll(groupByKeys);
    // output hashSymbol if present
    if (hashSymbol.isPresent()) {
        symbols.add(hashSymbol.get());/*from w w  w .  j  a v  a 2  s  .com*/
    }
    symbols.addAll(aggregations.keySet());
    return symbols.build();
}