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.go.GoTestDescription.java
@Override public <A extends Arg> BuildRule createBuildRule(TargetGraph targetGraph, BuildRuleParams params, final BuildRuleResolver resolver, A args) throws NoSuchBuildTargetException { GoPlatform platform = goBuckConfig.getPlatformFlavorDomain().getValue(params.getBuildTarget()) .orElse(goBuckConfig.getDefaultPlatform()); if (params.getBuildTarget().getFlavors().contains(TEST_LIBRARY_FLAVOR)) { return createTestLibrary(params, resolver, args, platform); }/*from ww w . j a v a 2s. co m*/ GoBinary testMain = createTestMainRule(params, resolver, args, platform); resolver.addToIndex(testMain); SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver)); return new GoTest( params.copyWithDeps(Suppliers.ofInstance(ImmutableSortedSet.of(testMain)), Suppliers.ofInstance(ImmutableSortedSet.of())), pathResolver, testMain, args.labels, args.contacts, args.testRuleTimeoutMs.map(Optional::of).orElse(defaultTestRuleTimeoutMs), args.runTestSeparately.orElse(false), args.resources); }
From source file:org.onosproject.onosjar.OnosJarStepFactory.java
@Override public void createCompileToJarStep(BuildContext context, ImmutableSortedSet<Path> sourceFilePaths, BuildTarget invokingRule, SourcePathResolver resolver, 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, ImmutableList.Builder<Step> steps, BuildableContext buildableContext, ImmutableSet<Pattern> classesToRemoveFromJar) { ImmutableSet.Builder<Path> sourceFilePathBuilder = ImmutableSet.builder(); sourceFilePathBuilder.addAll(sourceFilePaths); ImmutableSet.Builder<Pattern> blacklistBuilder = ImmutableSet.builder(); blacklistBuilder.addAll(classesToRemoveFromJar); // precompilation steps // - generate sources // add all generated sources ot pathToSrcsList if (webContext != null && apiTitle != null && resources.isPresent()) { ImmutableSortedSet<Path> resourceFilePaths = findSwaggerModelDefs(resolver, resources.get()); blacklistBuilder.addAll(resourceFilePaths.stream() .map(rp -> Pattern.compile(rp.getFileName().toString(), Pattern.LITERAL)) .collect(Collectors.toSet())); Path genSourcesOutput = workingDirectory.get(); SwaggerStep swaggerStep = new SwaggerStep(filesystem, sourceFilePaths, resourceFilePaths, genSourcesOutput, outputDirectory, webContext, apiTitle, apiVersion, apiPackage, apiDescription);/*from w w w . j a v a 2 s.co m*/ sourceFilePathBuilder.add(swaggerStep.apiRegistratorPath()); steps.add(swaggerStep); // steps.addAll(sourceFilePaths.stream() // .filter(sp -> sp.startsWith("src/main/webapp/")) // .map(sp -> CopyStep.forFile(filesystem, sp, outputDirectory)) // .iterator()); } createCompileStep(context, ImmutableSortedSet.copyOf(sourceFilePathBuilder.build()), invokingRule, resolver, filesystem, declaredClasspathEntries, outputDirectory, workingDirectory, pathToSrcsList, suggestBuildRules, usedClassesFileWriter, steps, buildableContext); // post compilation steps // FIXME BOC: add mechanism to inject new Steps //context.additionalStepFactory(JavaStep.class); // build the jar steps.add(new JarDirectoryStep(filesystem, outputJar, ImmutableSortedSet.of(outputDirectory), mainClass.orNull(), manifestFile.orNull(), true, blacklistBuilder.build())); OSGiWrapper osgiStep = new OSGiWrapper(outputJar, //input jar outputJar, //Paths.get(outputJar.toString() + ".jar"), //output jar invokingRule.getBasePath(), // sources dir outputDirectory, // classes dir declaredClasspathEntries, // classpath bundleName, // bundle name groupId, // groupId bundleVersion, // bundle version bundleLicense, // bundle license importPackages, // import packages exportPackages, // export packages includeResources, // include resources webContext, // web context dynamicimportPackages, // dynamic import packages bundleDescription // bundle description ); steps.add(osgiStep); //steps.add(CopyStep.forFile(filesystem, Paths.get(outputJar.toString() + ".jar"), outputJar)); }
From source file:com.facebook.buck.go.GoTestDescription.java
private GoBinary createTestMainRule(BuildRuleParams params, final BuildRuleResolver resolver, Arg args, GoPlatform platform) throws NoSuchBuildTargetException { Path packageName = getGoPackageName(resolver, params.getBuildTarget(), args); BuildRuleParams testTargetParams = params .copyWithBuildTarget(params.getBuildTarget().withAppendedFlavors(TEST_LIBRARY_FLAVOR)); BuildRule testLibrary = new NoopBuildRule(testTargetParams, new SourcePathResolver(new SourcePathRuleFinder(resolver))); resolver.addToIndex(testLibrary);//from w w w . j a v a2 s. c o m BuildRule generatedTestMain = requireTestMainGenRule(params, resolver, args.srcs, packageName); GoBinary testMain = GoDescriptors.createGoBinaryRule( params.copyWithChanges(params.getBuildTarget().withAppendedFlavors(ImmutableFlavor.of("test-main")), Suppliers.ofInstance(ImmutableSortedSet.of(testLibrary)), Suppliers.ofInstance(ImmutableSortedSet.of(generatedTestMain))), resolver, goBuckConfig, ImmutableSet.of(new BuildTargetSourcePath(generatedTestMain.getBuildTarget())), args.compilerFlags, args.assemblerFlags, args.linkerFlags, platform); resolver.addToIndex(testMain); return testMain; }
From source file:com.facebook.buck.haskell.HaskellLibraryDescription.java
private HaskellPackageRule createPackage(BuildTarget target, BuildRuleParams baseParams, BuildRuleResolver resolver, SourcePathResolver pathResolver, SourcePathRuleFinder ruleFinder, CxxPlatform cxxPlatform, Arg args, Linker.LinkableDepType depType) throws NoSuchBuildTargetException { BuildRule library;//www . jav a2 s . com switch (depType) { case SHARED: library = requireSharedLibrary(getBaseBuildTarget(target), baseParams, resolver, pathResolver, ruleFinder, cxxPlatform, args); break; case STATIC: case STATIC_PIC: library = requireStaticLibrary(getBaseBuildTarget(target), baseParams, resolver, pathResolver, ruleFinder, cxxPlatform, args, depType); break; default: throw new IllegalStateException(); } ImmutableSortedMap.Builder<String, HaskellPackage> depPackagesBuilder = ImmutableSortedMap.naturalOrder(); for (BuildRule rule : baseParams.getDeclaredDeps().get()) { if (rule instanceof HaskellCompileDep) { ImmutableList<HaskellPackage> packages = ((HaskellCompileDep) rule) .getCompileInput(cxxPlatform, depType).getPackages(); for (HaskellPackage pkg : packages) { depPackagesBuilder.put(pkg.getInfo().getIdentifier(), pkg); } } } ImmutableSortedMap<String, HaskellPackage> depPackages = depPackagesBuilder.build(); HaskellCompileRule compileRule = requireCompileRule(baseParams, resolver, pathResolver, ruleFinder, cxxPlatform, args, depType); return HaskellPackageRule.from(target, baseParams, pathResolver, ruleFinder, haskellConfig.getPackager().resolve(resolver), haskellConfig.getHaskellVersion(), getPackageInfo(target), depPackages, compileRule.getModules(), ImmutableSortedSet.of(new BuildTargetSourcePath(library.getBuildTarget())), ImmutableSortedSet.of(compileRule.getInterfaces())); }
From source file:com.google.enterprise.quality.sxse.storage.textstorage.TextPreferencesStorage.java
private void readPreferences() throws SxseStorageException { try {/*from w ww . j a v a 2 s .c om*/ // Move to beginning of file. raf.seek(0L); } catch (IOException e) { throw new SxseStorageException(e); } String firstProfileName = null; String secondProfileName = null; while (true) { String line; try { line = raf.readLine(); } catch (IOException e) { throw new SxseStorageException(e); } if (line == null) { // Reached end of file break; } KeyValuePair kvp = TextUtil.makeKeyValuePair(line); if (kvp.key.equals(TextPreferencesKeys.PASSWORD_SALT)) { passwordHasher.setSalt(TextUtil.hexStringToBytes(kvp.value)); } else if (kvp.key.equals(TextPreferencesKeys.PASSWORD_HASH)) { passwordHash = TextUtil.hexStringToBytes(kvp.value); } else if (kvp.key.equals(TextPreferencesKeys.PASSWORD_HINT)) { passwordHint = kvp.value; } else if (kvp.key.equals(TextPreferencesKeys.ADMINISTRATORS)) { administrators = ImmutableSortedSet.of(kvp.value.split(ADMIN_DELIMETER)); } else if (kvp.key.equals(TextPreferencesKeys.FIRST_PROFILE)) { firstProfileName = kvp.value; } else if (kvp.key.equals(TextPreferencesKeys.SECOND_PROFILE)) { secondProfileName = kvp.value; } else if (kvp.key.equals(TextPreferencesKeys.PROFILES_SIZE)) { final int numProfiles = Integer.valueOf(kvp.value); for (int i = 0; i < numProfiles; ++i) { ScoringPolicyProfile profile = readScoringPolicyProfile(raf); if (getProfile(profile.getName()) == null) { // Do not allow profiles to have duplicate names. profiles.add(profile); } } } } // Set which two profiles are active. firstProfile = getProfile(firstProfileName); if (firstProfile == null) { firstProfile = ScoringPolicyProfile.EMPTY_PROFILE; } secondProfile = getProfile(secondProfileName); if (secondProfile == null) { secondProfile = ScoringPolicyProfile.EMPTY_PROFILE; } }
From source file:com.facebook.buck.halide.HalideLibraryDescription.java
private BuildRule createHalideCompile(BuildRuleParams params, BuildRuleResolver resolver, SourcePathResolver pathResolver, CxxPlatform platform, Optional<ImmutableList<String>> compilerInvocationFlags, Optional<String> functionName) throws NoSuchBuildTargetException { CxxBinary halideCompiler = (CxxBinary) resolver .requireRule(params.getBuildTarget().withFlavors(HALIDE_COMPILER_FLAVOR)); return new HalideCompile( params.copyWithExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.of(halideCompiler))), pathResolver, halideCompiler.getExecutableCommand(), halideBuckConfig.getHalideTargetForPlatform(platform), expandInvocationFlags(compilerInvocationFlags, platform), functionName); }
From source file:com.facebook.buck.distributed.testutil.CustomActiongGraphBuilderFactory.java
public static BuildRuleResolver createGraphWithUncacheableRuntimeDeps() { ActionGraphBuilder graphBuilder = new TestActionGraphBuilder(); BuildTarget root = BuildTargetFactory.newInstance(ROOT_TARGET); BuildTarget left = BuildTargetFactory.newInstance(LEFT_TARGET); BuildTarget right = BuildTargetFactory.newInstance(RIGHT_TARGET); BuildRule leafRule = newCacheableRule(graphBuilder, LEAF_TARGET); BuildRule uncachableRuleA = newUncacheableRule(graphBuilder, UNCACHABLE_A); BuildRule rightRule = new FakeHasRuntimeDepsRule(right, new FakeProjectFilesystem(), ImmutableSet.of(leafRule), uncachableRuleA); graphBuilder.addToIndex(rightRule);//from ww w .j a v a 2 s. co m BuildRule uncachableRuleB = newUncacheableRule(graphBuilder, UNCACHABLE_B); BuildRule cachableRuleC = newCacheableRule(graphBuilder, CACHABLE_C); BuildRule leftRule = new FakeHasRuntimeDepsRule(left, new FakeProjectFilesystem(), ImmutableSet.of(leafRule), uncachableRuleB, cachableRuleC); graphBuilder.addToIndex(leftRule); ImmutableSortedSet<BuildRule> buildRules = ImmutableSortedSet .of(JavaLibraryBuilder.createBuilder(root).addDep(left).addDep(right).build(graphBuilder)); buildRules.forEach(graphBuilder::addToIndex); return graphBuilder; }
From source file:com.facebook.buck.distributed.testutil.CustomActionGraphBuilderFactory.java
public static BuildRuleResolver createGraphWithUncacheableRuntimeDeps() { ActionGraphBuilder graphBuilder = new TestActionGraphBuilder(); BuildTarget root = BuildTargetFactory.newInstance(ROOT_TARGET); BuildTarget left = BuildTargetFactory.newInstance(LEFT_TARGET); BuildTarget right = BuildTargetFactory.newInstance(RIGHT_TARGET); BuildRule leafRule = newCacheableRule(graphBuilder, LEAF_TARGET); BuildRule uncachableRuleA = newUncacheableRule(graphBuilder, UNCACHABLE_A); BuildRule rightRule = new FakeHasRuntimeDepsRule(right, new FakeProjectFilesystem(), ImmutableSet.of(leafRule), uncachableRuleA); graphBuilder.addToIndex(rightRule);//from w ww.j a v a2 s. c o m BuildRule uncachableRuleB = newUncacheableRule(graphBuilder, UNCACHABLE_B); BuildRule cachableRuleC = newCacheableRule(graphBuilder, CACHABLE_C); BuildRule leftRule = new FakeHasRuntimeDepsRule(left, new FakeProjectFilesystem(), ImmutableSet.of(leafRule), uncachableRuleB, cachableRuleC); graphBuilder.addToIndex(leftRule); ImmutableSortedSet<BuildRule> buildRules = ImmutableSortedSet .of(FakeTargetNodeBuilder.newBuilder(root).setDeps(left, right).build(graphBuilder)); buildRules.forEach(graphBuilder::addToIndex); return graphBuilder; }
From source file:com.facebook.buck.features.d.DDescriptionUtils.java
/** * Ensures that a DCompileBuildRule exists for the given target, creating a DCompileBuildRule if * neccesary.//from ww w . j a va 2 s . c o m * * @param baseParams build parameters for the rule * @param graphBuilder BuildRuleResolver the rule should be in * @param src the source file to be compiled * @param compilerFlags flags to pass to the compiler * @param compileTarget the target the rule should be for * @param dBuckConfig the Buck configuration for D * @return the build rule */ public static DCompileBuildRule requireBuildRule(BuildTarget compileTarget, BuildTarget baseBuildTarget, ProjectFilesystem projectFilesystem, BuildRuleParams baseParams, ActionGraphBuilder graphBuilder, SourcePathRuleFinder ruleFinder, DBuckConfig dBuckConfig, ImmutableList<String> compilerFlags, String name, SourcePath src, DIncludes includes) { return (DCompileBuildRule) graphBuilder.computeIfAbsent(compileTarget, ignored -> { Tool compiler = dBuckConfig.getDCompiler(); Map<BuildTarget, DIncludes> transitiveIncludes = new TreeMap<>(); transitiveIncludes.put(baseBuildTarget, includes); for (Map.Entry<BuildTarget, DLibrary> library : getTransitiveDLibraryRules(baseParams.getBuildDeps()) .entrySet()) { transitiveIncludes.put(library.getKey(), library.getValue().getIncludes()); } ImmutableSortedSet.Builder<BuildRule> depsBuilder = ImmutableSortedSet.naturalOrder(); depsBuilder.addAll(BuildableSupport.getDepsCollection(compiler, ruleFinder)); depsBuilder.addAll(ruleFinder.filterBuildRuleInputs(src)); for (DIncludes dIncludes : transitiveIncludes.values()) { depsBuilder.addAll(dIncludes.getDeps(ruleFinder)); } ImmutableSortedSet<BuildRule> deps = depsBuilder.build(); return new DCompileBuildRule(compileTarget, projectFilesystem, baseParams.withDeclaredDeps(deps).withoutExtraDeps(), compiler, ImmutableList.<String>builder().addAll(dBuckConfig.getBaseCompilerFlags()).addAll(compilerFlags) .build(), name, ImmutableSortedSet.of(src), ImmutableList.copyOf(transitiveIncludes.values())); }); }
From source file:com.facebook.buck.features.js.JsBundleDescription.java
private static BuildRule createAndroidResources(ToolchainProvider toolchainProvider, BuildTarget buildTarget, ProjectFilesystem projectFilesystem, SourcePathRuleFinder ruleFinder, JsBundle jsBundle, String rDotJavaPackage) { if (buildTarget.getFlavors().contains(AndroidResourceDescription.AAPT2_COMPILE_FLAVOR)) { AndroidPlatformTarget androidPlatformTarget = toolchainProvider .getByName(AndroidPlatformTarget.DEFAULT_NAME, AndroidPlatformTarget.class); return new Aapt2Compile(buildTarget, projectFilesystem, androidPlatformTarget, ImmutableSortedSet.of(jsBundle), jsBundle.getSourcePathToResources()); }//from w w w . ja v a2 s .c o m BuildRuleParams params = new BuildRuleParams(() -> ImmutableSortedSet.of(), () -> ImmutableSortedSet.of(jsBundle), ImmutableSortedSet.of()); return new AndroidResource(buildTarget, projectFilesystem, params, ruleFinder, ImmutableSortedSet.of(), // deps jsBundle.getSourcePathToResources(), ImmutableSortedMap.of(), // resSrcs rDotJavaPackage, null, ImmutableSortedMap.of(), null, false); }