List of usage examples for com.google.common.collect ImmutableSortedSet of
public static <E extends Comparable<? super E>> ImmutableSortedSet<E> of(E element)
From source file:com.facebook.buck.thrift.ThriftJavaEnhancer.java
@Override public ImmutableSortedSet<String> getGeneratedSources(BuildTarget target, ThriftConstructorArg args, String thriftName, ImmutableList<String> services) { return ImmutableSortedSet.of(""); }
From source file:io.prestosql.plugin.accumulo.AccumuloQueryRunner.java
public static synchronized DistributedQueryRunner createAccumuloQueryRunner(Map<String, String> extraProperties) throws Exception { DistributedQueryRunner queryRunner = new DistributedQueryRunner(createSession(), 4, extraProperties); queryRunner.installPlugin(new TpchPlugin()); queryRunner.createCatalog("tpch", "tpch"); queryRunner.installPlugin(new AccumuloPlugin()); Map<String, String> accumuloProperties = ImmutableMap.<String, String>builder() .put(AccumuloConfig.INSTANCE, connector.getInstance().getInstanceName()) .put(AccumuloConfig.ZOOKEEPERS, connector.getInstance().getZooKeepers()) .put(AccumuloConfig.USERNAME, MAC_USER).put(AccumuloConfig.PASSWORD, MAC_PASSWORD) .put(AccumuloConfig.ZOOKEEPER_METADATA_ROOT, "/presto-accumulo-test").build(); queryRunner.createCatalog("accumulo", "accumulo", accumuloProperties); if (!tpchLoaded) { copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createSession(), TpchTable.getTables()); connector.tableOperations().addSplits("tpch.orders", ImmutableSortedSet.of(new Text(new LexicoderRowSerializer().encode(BIGINT, 7500L)))); tpchLoaded = true;/* w w w . j a va 2s.c o m*/ } return queryRunner; }
From source file:com.facebook.buck.jvm.java.GwtModule.java
@Override public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) { ImmutableList.Builder<Step> steps = ImmutableList.builder(); Path workingDirectory = outputFile.getParent(); steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), workingDirectory)); // A CopyResourcesStep is needed so that a file that is at java/com/example/resource.txt in the // repository will be added as com/example/resource.txt in the resulting JAR (assuming that // "/java/" is listed under src_roots in .buckconfig). Path tempJarFolder = workingDirectory.resolve("tmp"); steps.add(new CopyResourcesStep(getProjectFilesystem(), getResolver(), getBuildTarget(), filesForGwtModule, tempJarFolder, context.getJavaPackageFinder())); steps.add(new JarDirectoryStep(getProjectFilesystem(), outputFile, /* entriesToJar */ ImmutableSortedSet.of(tempJarFolder), /* mainClass */ null, /* manifestFile */ null)); buildableContext.recordArtifact(outputFile); return steps.build(); }
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//from w w w.j ava 2s .c om 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:com.facebook.buck.jvm.java.BaseCompileToJarStepFactory.java
@Override public void createCompileToJarStep(BuildContext context, ImmutableSortedSet<Path> sourceFilePaths, BuildTarget invokingRule, SourcePathResolver resolver, SourcePathRuleFinder ruleFinder, ProjectFilesystem filesystem, ImmutableSortedSet<Path> declaredClasspathEntries, Path outputDirectory, Optional<Path> workingDirectory, Path pathToSrcsList, Optional<SuggestBuildRules> suggestBuildRules, ImmutableList<String> postprocessClassesCommands, ImmutableSortedSet<Path> entriesToJar, Optional<String> mainClass, Optional<Path> manifestFile, Path outputJar, ClassUsageFileWriter usedClassesFileWriter, /* output params */ ImmutableList.Builder<Step> steps, BuildableContext buildableContext, ImmutableSet<Pattern> classesToRemoveFromJar) { createCompileStep(context, sourceFilePaths, invokingRule, resolver, ruleFinder, filesystem, declaredClasspathEntries, outputDirectory, workingDirectory, pathToSrcsList, suggestBuildRules, usedClassesFileWriter, steps, buildableContext); steps.addAll(Lists.newCopyOnWriteArrayList(addPostprocessClassesCommands(filesystem, postprocessClassesCommands, outputDirectory, declaredClasspathEntries, getBootClasspath(context)))); steps.add(new JarDirectoryStep(filesystem, outputJar, ImmutableSortedSet.of(outputDirectory), mainClass.orElse(null), manifestFile.orElse(null), true, classesToRemoveFromJar)); }
From source file:com.facebook.buck.gwt.GwtModule.java
@Override public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) { ImmutableList.Builder<Step> steps = ImmutableList.builder(); Path workingDirectory = outputFile.getParent(); steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), workingDirectory)); // A CopyResourcesStep is needed so that a file that is at java/com/example/resource.txt in the // repository will be added as com/example/resource.txt in the resulting JAR (assuming that // "/java/" is listed under src_roots in .buckconfig). Path tempJarFolder = workingDirectory.resolve("tmp"); steps.add(new CopyResourcesStep(getProjectFilesystem(), getResolver(), ruleFinder, getBuildTarget(), filesForGwtModule, tempJarFolder, context.getJavaPackageFinder())); steps.add(new JarDirectoryStep(getProjectFilesystem(), outputFile, /* entriesToJar */ ImmutableSortedSet.of(tempJarFolder), /* mainClass */ null, /* manifestFile */ null)); buildableContext.recordArtifact(outputFile); return steps.build(); }
From source file:com.facebook.buck.jvm.java.PrebuiltJarDescription.java
@Override public <A extends Arg> BuildRule createBuildRule(TargetGraph targetGraph, BuildRuleParams params, BuildRuleResolver resolver, A args) throws NoSuchBuildTargetException { SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver); if (params.getBuildTarget().getFlavors().contains(CalculateAbi.FLAVOR)) { return CalculateAbi.of(params.getBuildTarget(), ruleFinder, params, args.binaryJar); }/*from w w w . ja va 2s .com*/ SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder); BuildTarget abiJarTarget = params.getBuildTarget().withAppendedFlavors(CalculateAbi.FLAVOR); BuildRule prebuilt = new PrebuiltJar(params, pathResolver, args.binaryJar, abiJarTarget, args.sourceJar, args.gwtJar, args.javadocUrl, args.mavenCoords, args.provided.orElse(false)); UnflavoredBuildTarget prebuiltJarBuildTarget = params.getBuildTarget().checkUnflavored(); BuildTarget flavoredBuildTarget = BuildTargets.createFlavoredBuildTarget(prebuiltJarBuildTarget, JavaLibrary.GWT_MODULE_FLAVOR); BuildRuleParams gwtParams = params.copyWithChanges(flavoredBuildTarget, /* declaredDeps */ Suppliers.ofInstance(ImmutableSortedSet.of(prebuilt)), /* inferredDeps */ Suppliers.ofInstance(ImmutableSortedSet.of())); BuildRule gwtModule = createGwtModule(gwtParams, pathResolver, args); resolver.addToIndex(gwtModule); return prebuilt; }
From source file:org.onosproject.yangutils.plugin.buck.YangLibrary.java
@Override public ImmutableList<Step> getBuildSteps(BuildContext buildContext, BuildableContext buildableContext) { ImmutableList.Builder<Step> steps = ImmutableList.builder(); // Delete the old output for this rule, if it exists. steps.add(new RmStep(getProjectFilesystem(), getPathToOutput(), /* shouldForceDeletion */ true, /* shouldRecurse */ true)); // Make sure that the directory to contain the output file exists. Rules get output to a // directory named after the base path, so we don't want to nuke the entire directory. steps.add(new MkdirStep(getProjectFilesystem(), outputDirectory)); steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), genSrcsDirectory)); List<Path> sourcePaths = srcs.stream().map(s -> getResolver().getRelativePath(s)) .collect(Collectors.toList()); steps.add(new YangStep(getProjectFilesystem(), sourcePaths, genSrcsDirectory)); steps.add(new JarDirectoryStep(getProjectFilesystem(), output, ImmutableSortedSet.of(genSrcsDirectory), null, null));/* w w w.java 2 s .c o m*/ return steps.build(); }
From source file:com.facebook.buck.file.HttpArchiveDescription.java
@Override public BuildRule createBuildRule(BuildRuleCreationContextWithTargetGraph context, BuildTarget buildTarget, BuildRuleParams params, HttpArchiveDescriptionArg args) { HashCode sha256 = HttpCommonDescriptionArg.HttpCommonDescriptionArgHelpers.parseSha256(args.getSha256(), buildTarget);/*from w w w . jav a2 s .com*/ HttpCommonDescriptionArg.HttpCommonDescriptionArgHelpers.validateUris(args.getUrls(), buildTarget); String out = args.getOut().orElse(buildTarget.getShortNameAndFlavorPostfix()); ArchiveFormat format = args.getType().map(t -> getTypeFromType(t, buildTarget)) .orElseGet(() -> getTypeFromFilename(args.getUrls(), buildTarget)); ProjectFilesystem projectFilesystem = context.getProjectFilesystem(); // Setup the implicit download rule BuildTarget httpFileTarget = buildTarget.withAppendedFlavors(ARCHIVE_DOWNLOAD); HttpFile httpFile = new HttpFile(httpFileTarget, projectFilesystem, params, downloaderSupplier.get(), args.getUrls(), sha256, out, false); BuildRuleParams httpArchiveParams = new BuildRuleParams(() -> ImmutableSortedSet.of(httpFile), ImmutableSortedSet::of, ImmutableSortedSet.of()); context.getActionGraphBuilder().computeIfAbsent(httpFileTarget, ignored -> httpFile); return new HttpArchive(buildTarget, projectFilesystem, httpArchiveParams, httpFile, out, format, args.getStripPrefix().map(Paths::get)); }
From source file:com.google.devtools.build.lib.rules.config.ConfigFeatureFlagTaggedTrimmingTransitionFactory.java
@Override public PatchTransition buildTransitionFor(Rule rule) { NonconfigurableAttributeMapper attrs = NonconfigurableAttributeMapper.of(rule); RuleClass ruleClass = rule.getRuleClassObject(); if (ruleClass.getName().equals(ConfigRuleClasses.ConfigFeatureFlagRule.RULE_NAME)) { return new ConfigFeatureFlagTaggedTrimmingTransition(ImmutableSortedSet.of(rule.getLabel())); }//w w w . j a v a2 s .com ImmutableSortedSet.Builder<Label> requiredLabelsBuilder = new ImmutableSortedSet.Builder<>( Ordering.natural()); if (attrs.isAttributeValueExplicitlySpecified(attributeName) && !attrs.get(attributeName, NODEP_LABEL_LIST).isEmpty()) { requiredLabelsBuilder.addAll(attrs.get(attributeName, NODEP_LABEL_LIST)); } if (ruleClass.getTransitionFactory() instanceof ConfigFeatureFlagTransitionFactory) { String settingAttribute = ((ConfigFeatureFlagTransitionFactory) ruleClass.getTransitionFactory()) .getAttributeName(); // Because the process of setting a flag also creates a dependency on that flag, we need to // include all the set flags, even if they aren't actually declared as used by this rule. requiredLabelsBuilder.addAll(attrs.get(settingAttribute, LABEL_KEYED_STRING_DICT).keySet()); } ImmutableSortedSet<Label> requiredLabels = requiredLabelsBuilder.build(); if (requiredLabels.isEmpty()) { return ConfigFeatureFlagTaggedTrimmingTransition.EMPTY; } return new ConfigFeatureFlagTaggedTrimmingTransition(requiredLabels); }