com.google.common.collect.ImmutableSortedSet Java Examples
The following examples show how to use
com.google.common.collect.ImmutableSortedSet.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SdkMavenRepository.java From bazel with Apache License 2.0 | 7 votes |
/** * Parses a set of maven repository directory trees looking for and parsing .pom files. */ static SdkMavenRepository create(Iterable<Path> mavenRepositories) throws IOException { Collection<Path> pomPaths = new ArrayList<>(); for (Path mavenRepository : mavenRepositories) { pomPaths.addAll( FileSystemUtils.traverseTree(mavenRepository, path -> path.toString().endsWith(".pom"))); } ImmutableSortedSet.Builder<Pom> poms = new ImmutableSortedSet.Builder<>(Ordering.usingToString()); for (Path pomPath : pomPaths) { try { Pom pom = Pom.parse(pomPath); if (pom != null) { poms.add(pom); } } catch (ParserConfigurationException | SAXException e) { throw new IOException(e); } } return new SdkMavenRepository(poms.build()); }
Example #2
Source File: FileBundler.java From buck with Apache License 2.0 | 6 votes |
public void copy( ProjectFilesystem filesystem, BuildCellRelativePathFactory buildCellRelativePathFactory, ImmutableList.Builder<Step> steps, Path destinationDir, ImmutableSortedSet<SourcePath> toCopy, SourcePathResolverAdapter pathResolver) { copy( filesystem, buildCellRelativePathFactory, steps, destinationDir, toCopy, pathResolver, PatternsMatcher.NONE); }
Example #3
Source File: IncrementalActionGraphScenarioTest.java From buck with Apache License 2.0 | 6 votes |
@Test public void testCxxBinaryAndGenruleLoadedFromCache() { BuildTarget genruleTarget = BuildTargetFactory.newInstance("//:gen"); GenruleBuilder genruleBuilder = GenruleBuilder.newGenruleBuilder(genruleTarget).setCmd("cmd").setOut("out"); BuildTarget binaryTarget = BuildTargetFactory.newInstance("//:bin"); CxxBinaryBuilder binaryBuilder = new CxxBinaryBuilder(binaryTarget) .setHeaders(ImmutableSortedSet.of(DefaultBuildTargetSourcePath.of(genruleTarget))) .setSrcs( ImmutableSortedSet.of( SourceWithFlags.of(FakeSourcePath.of("binary.cpp"), ImmutableList.of()))); ActionGraphAndBuilder result = createActionGraph(binaryBuilder, genruleBuilder); queryTransitiveDeps(result); ImmutableMap<BuildRule, RuleKey> ruleKeys = getRuleKeys(result); ActionGraphAndBuilder newResult = createActionGraph(binaryBuilder, genruleBuilder); queryTransitiveDeps(newResult); ImmutableMap<BuildRule, RuleKey> newRuleKeys = getRuleKeys(newResult); assertBuildRulesSame(result, newResult); assertEquals(ruleKeys, newRuleKeys); }
Example #4
Source File: ConfigCommand.java From bazel with Apache License 2.0 | 6 votes |
/** * Returns the {@link Fragment}s and the {@link FragmentOptions} they require from Blaze's * runtime. * * <p>These are the fragments that Blaze "knows about", not necessarily the fragments in a {@link * BuildConfiguration}. Trimming, in particular, strips fragments out of actual configurations. * It's safe to assume untrimmed configuration have all fragments listed here. */ private static ImmutableSortedMap< Class<? extends Fragment>, ImmutableSortedSet<Class<? extends FragmentOptions>>> getFragmentDefs(ConfiguredRuleClassProvider ruleClassProvider) { ImmutableSortedMap.Builder< Class<? extends Fragment>, ImmutableSortedSet<Class<? extends FragmentOptions>>> fragments = ImmutableSortedMap.orderedBy((c1, c2) -> c1.getName().compareTo(c2.getName())); for (ConfigurationFragmentFactory fragmentFactory : ruleClassProvider.getConfigurationFragments()) { fragments.put( fragmentFactory.creates(), ImmutableSortedSet.copyOf( (c1, c2) -> c1.getName().compareTo(c2.getName()), fragmentFactory.requiredOptions())); } return fragments.build(); }
Example #5
Source File: AndroidBinaryFilesInfoTest.java From buck with Apache License 2.0 | 6 votes |
FakePreDexMerge(BuildTarget buildTarget, APKModuleGraph apkModuleGraph) { super( buildTarget, new FakeProjectFilesystem(), new BuildRuleParams( ImmutableSortedSet::of, ImmutableSortedSet::of, ImmutableSortedSet.of()), null, "dx", new DexSplitMode( /* shouldSplitDex */ true, DexSplitStrategy.MINIMIZE_PRIMARY_DEX_SIZE, DexStore.JAR, /* linearAllocHardLimit */ 4 * 1024 * 1024, /* primaryDexPatterns */ ImmutableSet.of("List"), Optional.of(FakeSourcePath.of("the/manifest.txt")), /* primaryDexScenarioFile */ Optional.empty(), /* isPrimaryDexScenarioOverflowAllowed */ false, /* secondaryDexHeadClassesFile */ Optional.empty(), /* secondaryDexTailClassesFile */ Optional.empty(), /* allowRDotJavaInSecondaryDex */ false), apkModuleGraph, null, MoreExecutors.newDirectExecutorService(), XzStep.DEFAULT_COMPRESSION_LEVEL, Optional.empty()); }
Example #6
Source File: ConcurrentIssueRegistry.java From n4js with Eclipse Public License 1.0 | 6 votes |
public boolean clearIssuesOfPersistedState(String containerHandle) { List<IssueRegistryChangeEvent> events; synchronized (this) { Map<URI, ImmutableSortedSet<LSPIssue>> containerIssues = getContainerIssues(containerHandle, false); if (containerIssues == null) { return false; } events = containerIssues.entrySet().stream() .map(e -> eventPersisted(containerHandle, e.getKey(), e.getValue(), null)) .collect(Collectors.toList()); containerIssues.keySet().forEach(persistedIssues::remove); container2persistedIssues.remove(containerHandle); } notifyListeners(events); return true; }
Example #7
Source File: RustLibraryDescriptionTest.java From buck with Apache License 2.0 | 6 votes |
@Test public void testGeneratedSourceFromCxxGenrule() throws NoSuchBuildTargetException { CxxGenruleBuilder srcBuilder = new CxxGenruleBuilder(BuildTargetFactory.newInstance("//:src")).setOut("lib.rs"); RustLibraryBuilder libraryBuilder = RustLibraryBuilder.from("//:lib") .setSrcs( ImmutableSortedSet.of(DefaultBuildTargetSourcePath.of(srcBuilder.getTarget()))); RustBinaryBuilder binaryBuilder = RustBinaryBuilder.from("//:bin") .setSrcs(ImmutableSortedSet.of(FakeSourcePath.of("main.rs"))) .setDeps(ImmutableSortedSet.of(libraryBuilder.getTarget())); TargetGraph targetGraph = TargetGraphFactory.newInstance( srcBuilder.build(), libraryBuilder.build(), binaryBuilder.build()); ActionGraphBuilder graphBuilder = new TestActionGraphBuilder(targetGraph); graphBuilder.requireRule(binaryBuilder.getTarget()); }
Example #8
Source File: BoundingBox.java From activitystreams with Apache License 2.0 | 6 votes |
protected static BoundingBox calculateBoundingBoxLineStrings(Iterable<LineString> lineStrings) { ImmutableSortedSet.Builder<Float> xset = ImmutableSortedSet.naturalOrder(); ImmutableSortedSet.Builder<Float> yset = ImmutableSortedSet.naturalOrder(); ImmutableSortedSet.Builder<Float> zset = ImmutableSortedSet.naturalOrder(); for (LineString ls : lineStrings) { for (Position p : ls) { xset.add(p.northing()); yset.add(p.easting()); if (p.hasAltitude()) zset.add(p.altitude()); } } return buildBoundingBox( xset.build(), yset.build(), zset.build()); }
Example #9
Source File: PrebuiltCxxLibraryDescriptionTest.java From buck with Apache License 2.0 | 6 votes |
@Test public void exportedHeaders() { ProjectFilesystem filesystem = new AllExistingProjectFilesystem(); PrebuiltCxxLibraryBuilder libBuilder = new PrebuiltCxxLibraryBuilder(TARGET) .setExportedHeaders( SourceSortedSet.ofNamedSources( ImmutableSortedMap.of("foo.h", FakeSourcePath.of("foo.h")))); TargetGraph targetGraph = TargetGraphFactory.newInstance(libBuilder.build()); ActionGraphBuilder graphBuilder = new TestActionGraphBuilder(targetGraph); PrebuiltCxxLibrary lib = (PrebuiltCxxLibrary) libBuilder.build(graphBuilder, filesystem, targetGraph); // Verify the preprocessable input is as expected. CxxPreprocessorInput input = lib.getCxxPreprocessorInput(CXX_PLATFORM, graphBuilder); assertThat(getHeaderNames(input.getIncludes()), Matchers.hasItem(filesystem.getPath("foo.h"))); assertThat( ImmutableSortedSet.copyOf(input.getDeps(graphBuilder)), Matchers.equalTo(graphBuilder.getAllRules(getInputRules(lib)))); }
Example #10
Source File: ServiceInfo.java From armeria with Apache License 2.0 | 6 votes |
/** * Merges the {@link MethodInfo}s with the same method name and {@link HttpMethod} pair * into a single {@link MethodInfo}. Note that only the {@link EndpointInfo}s are merged * because the {@link MethodInfo}s being merged always have the same * {@code exampleHttpHeaders} and {@code exampleRequests}. */ @VisibleForTesting static Set<MethodInfo> mergeEndpoints(Iterable<MethodInfo> methodInfos) { final Map<List<Object>, MethodInfo> methodInfoMap = new HashMap<>(); for (MethodInfo methodInfo : methodInfos) { final List<Object> mergeKey = ImmutableList.of(methodInfo.name(), methodInfo.httpMethod()); methodInfoMap.compute(mergeKey, (key, value) -> { if (value == null) { return methodInfo; } else { final Set<EndpointInfo> endpointInfos = Sets.union(value.endpoints(), methodInfo.endpoints()); return new MethodInfo(value.name(), value.returnTypeSignature(), value.parameters(), value.exceptionTypeSignatures(), endpointInfos, value.exampleHttpHeaders(), value.exampleRequests(), value.examplePaths(), value.exampleQueries(), value.httpMethod(), value.docString()); } }); } return ImmutableSortedSet .orderedBy(comparing(MethodInfo::name).thenComparing(MethodInfo::httpMethod)) .addAll(methodInfoMap.values()) .build(); }
Example #11
Source File: NinjaGraphArtifactsHelper.java From bazel with Apache License 2.0 | 6 votes |
/** * Constructor * * @param ruleContext parent NinjaGraphRule rule context * @param outputRootPath name of output directory for Ninja actions under execroot * @param workingDirectory relative path under execroot, the root for interpreting all paths in * Ninja file * @param symlinkPathToArtifact mapping of paths to artifacts for input symlinks under output_root * @param outputRootSymlinks list of output paths for which symlink artifacts should be created, * paths are relative to the output_root. */ NinjaGraphArtifactsHelper( RuleContext ruleContext, PathFragment outputRootPath, PathFragment workingDirectory, ImmutableSortedMap<PathFragment, Artifact> symlinkPathToArtifact, ImmutableSortedSet<PathFragment> outputRootSymlinks) { this.ruleContext = ruleContext; this.outputRootPath = outputRootPath; this.workingDirectory = workingDirectory; this.symlinkPathToArtifact = symlinkPathToArtifact; this.outputRootSymlinks = outputRootSymlinks; Path execRoot = Preconditions.checkNotNull(ruleContext.getConfiguration()) .getDirectories() .getExecRoot(ruleContext.getWorkspaceName()); this.derivedOutputRoot = ArtifactRoot.asDerivedRoot(execRoot, outputRootPath.getSegments().toArray(new String[0])); this.sourceRoot = ruleContext.getRule().getPackage().getSourceRoot().get(); }
Example #12
Source File: Cells.java From buck with Apache License 2.0 | 6 votes |
/** @return Path of the topmost cell's path that roots all other cells */ public AbsPath getSuperRootPath() { AbsPath cellRoot = getRootCell().getRoot(); ImmutableSortedSet<AbsPath> allRoots = getRootCell().getKnownRootsOfAllCells(); AbsPath path = cellRoot.getRoot(); // check if supercell is a root folder, like '/' or 'C:\' if (allRoots.contains(path)) { return path; } // There is an assumption that there is exactly one cell with a path that prefixes all other // cell paths. So just try to find the cell with the shortest common path. for (Path next : cellRoot.getPath()) { path = path.resolve(next); if (allRoots.contains(path)) { return path; } } throw new IllegalStateException( "Unreachable: at least one path should be in getKnownRoots(), including root cell '" + cellRoot.toString() + "'; known roots = [" + allRoots.stream().map(Objects::toString).collect(Collectors.joining(", ")) + "]"); }
Example #13
Source File: Utils.java From batfish with Apache License 2.0 | 5 votes |
/** Creates a generated reference book with the public IPs of the network interfaces */ static void createPublicIpsRefBook( Collection<NetworkInterface> networkInterfaces, Configuration cfgNode) { String publicIpBookName = GeneratedRefBookUtils.getName(cfgNode.getHostname(), BookType.PublicIps); checkArgument( !cfgNode.getGeneratedReferenceBooks().containsKey(publicIpBookName), "Generated reference book for public IPs already exists for node %s", cfgNode.getHostname()); List<AddressGroup> publicIpAddressGroups = networkInterfaces.stream() .map( iface -> new AddressGroup( iface.getPrivateIpAddresses().stream() .filter(privIp -> privIp.getPublicIp() != null) .map(privIp -> privIp.getPublicIp().toString()) .collect(ImmutableSortedSet.toImmutableSortedSet(naturalOrder())), publicIpAddressGroupName(iface))) .filter(ag -> !ag.getAddresses().isEmpty()) .collect(ImmutableList.toImmutableList()); if (!publicIpAddressGroups.isEmpty()) { cfgNode .getGeneratedReferenceBooks() .put( publicIpBookName, ReferenceBook.builder(publicIpBookName) .setAddressGroups(publicIpAddressGroups) .build()); } }
Example #14
Source File: CxxLinkableEnhancer.java From buck with Apache License 2.0 | 5 votes |
@Override public void appendToCommandLine(Consumer<String> consumer, SourcePathResolverAdapter resolver) { ImmutableSortedSet<Path> searchPaths = frameworkPaths.stream() .map(frameworkPathToSearchPath) .filter(Objects::nonNull) .collect(ImmutableSortedSet.toImmutableSortedSet(Ordering.natural())); for (Path searchPath : searchPaths) { consumer.accept("-L"); consumer.accept(searchPath.toString()); } }
Example #15
Source File: CxxCompilationDatabase.java From buck with Apache License 2.0 | 5 votes |
public static CxxCompilationDatabase createCompilationDatabase( BuildTarget buildTarget, ProjectFilesystem projectFilesystem, Iterable<CxxPreprocessAndCompile> compileAndPreprocessRules) { ImmutableSortedSet.Builder<BuildRule> deps = ImmutableSortedSet.naturalOrder(); ImmutableSortedSet.Builder<CxxPreprocessAndCompile> compileRules = ImmutableSortedSet.naturalOrder(); for (CxxPreprocessAndCompile compileRule : compileAndPreprocessRules) { compileRules.add(compileRule); deps.addAll(compileRule.getBuildDeps()); } return new CxxCompilationDatabase( buildTarget, projectFilesystem, compileRules.build(), deps.build()); }
Example #16
Source File: Layer3EdgeTest.java From batfish with Apache License 2.0 | 5 votes |
@Test public void testJsonSerialization() { Layer3Edge layer3Edge = new Layer3Edge( NodeInterfacePair.of("node1", "interface1"), NodeInterfacePair.of("node2", "interface2"), ImmutableSortedSet.of(ConcreteInterfaceAddress.create(Ip.parse("1.1.1.1"), 32)), ImmutableSortedSet.of(ConcreteInterfaceAddress.create(Ip.parse("2.2.2.2"), 32))); assertThat(BatfishObjectMapper.clone(layer3Edge, Layer3Edge.class), equalTo(layer3Edge)); }
Example #17
Source File: NodePropertiesAnswererTest.java From batfish with Apache License 2.0 | 5 votes |
@Test public void getProperties() { String property1 = NodePropertySpecifier.CONFIGURATION_FORMAT; String property2 = NodePropertySpecifier.NTP_SERVERS; NodePropertySpecifier propertySpec = new NodePropertySpecifier(ImmutableSet.of(property1, property2)); Configuration conf1 = new Configuration("node1", ConfigurationFormat.CISCO_IOS); Configuration conf2 = new Configuration("node2", ConfigurationFormat.HOST); conf2.setNtpServers(ImmutableSortedSet.of("sa")); Map<String, Configuration> configurations = ImmutableMap.of("node1", conf1, "node2", conf2); Map<String, ColumnMetadata> columns = NodePropertiesAnswerer.createTableMetadata(new NodePropertiesQuestion(null, propertySpec)) .toColumnMap(); NodeSpecifier nodeSpecifier = new NameRegexNodeSpecifier(Pattern.compile("node1|node2")); MockSpecifierContext ctxt = MockSpecifierContext.builder().setConfigs(configurations).build(); Multiset<Row> propertyRows = NodePropertiesAnswerer.getProperties(propertySpec, ctxt, nodeSpecifier, columns); // we should have exactly these two rows Multiset<Row> expected = HashMultiset.create( ImmutableList.of( Row.builder() .put(NodePropertiesAnswerer.COL_NODE, new Node("node1")) .put(property1, ConfigurationFormat.CISCO_IOS) .put(property2, ImmutableList.of()) .build(), Row.builder() .put(NodePropertiesAnswerer.COL_NODE, new Node("node2")) .put(property1, ConfigurationFormat.HOST) .put(property2, ImmutableList.of("sa")) .build())); assertThat(propertyRows, equalTo(expected)); }
Example #18
Source File: IjFolder.java From buck with Apache License 2.0 | 5 votes |
IjFolder(Path path, boolean wantsPackagePrefix, ImmutableSortedSet<Path> inputs) { this.path = path; this.wantsPackagePrefix = wantsPackagePrefix; this.inputs = (inputs == null) ? EMPTY_INPUTS : inputs; hashCodeSupplier = Suppliers.memoize( () -> (getPath().hashCode() << 31) ^ (getWantsPackagePrefix() ? 0x8000 : 0) ^ inputs.hashCode()); }
Example #19
Source File: NativeRelinker.java From buck with Apache License 2.0 | 5 votes |
private RelinkerRule makeRelinkerRule( TargetCpuType cpuType, SourcePath source, ImmutableList<RelinkerRule> relinkerDeps) { String libname = resolver.getAbsolutePath(source).getFileName().toString(); BuildRule baseRule = ruleFinder.getRule(source).orElse(null); ImmutableList<Arg> linkerArgs = ImmutableList.of(); Linker linker = null; if (baseRule instanceof CxxLink) { CxxLink link = (CxxLink) baseRule; linkerArgs = link.getArgs(); linker = link.getLinker(); } return new RelinkerRule( buildTarget.withAppendedFlavors( InternalFlavor.of("xdso-dce"), InternalFlavor.of(Flavor.replaceInvalidCharacters(cpuType.toString())), InternalFlavor.of(Flavor.replaceInvalidCharacters(libname))), projectFilesystem, resolver, cellPathResolver, ruleFinder, ImmutableSortedSet.copyOf( Lists.transform(relinkerDeps, RelinkerRule::getSymbolsNeededPath)), cpuType, Objects.requireNonNull(nativePlatforms.get(cpuType)).getObjdump(), cxxBuckConfig, source, linker, linkerArgs, symbolPatternWhitelist); }
Example #20
Source File: JavaFileParserTest.java From buck with Apache License 2.0 | 5 votes |
@Test public void testJavaFileParsingWithLocalClass() { JavaFileParser parser = JavaFileParser.createJavaFileParser(DEFAULT_JAVAC_OPTIONS.getLanguageLevelOptions()); ImmutableSortedSet<String> symbols = parser.getExportedSymbolsFromString(JAVA_CODE_WITH_LOCAL_CLASS); assertEquals( "getExportedSymbolsFromString should not consider non-local classes to be provided", ImmutableSortedSet.of("com.example.NonlocalClass"), symbols); }
Example #21
Source File: JavaFileParserTest.java From buck with Apache License 2.0 | 5 votes |
@Test public void testJavaFileParsingWithAnnotationType() { JavaFileParser parser = JavaFileParser.createJavaFileParser(DEFAULT_JAVAC_OPTIONS.getLanguageLevelOptions()); ImmutableSortedSet<String> symbols = parser.getExportedSymbolsFromString(JAVA_CODE_WITH_ANNOTATION_TYPE); assertEquals( "getExportedSymbolsFromString should be able to extract symbols with annotations", ImmutableSortedSet.of("ExampleAnnotationType"), symbols); }
Example #22
Source File: ResourceValidator.java From buck with Apache License 2.0 | 5 votes |
public static ImmutableSortedSet<SourcePath> validateResources( SourcePathResolverAdapter resolver, ProjectFilesystem filesystem, ImmutableSortedSet<SourcePath> resourcePaths) { for (Path path : resolver.filterInputsToCompareToOutput(resourcePaths)) { if (!filesystem.exists(path)) { throw new HumanReadableException("Error: `resources` argument '%s' does not exist.", path); } else if (filesystem.isDirectory(path)) { throw new HumanReadableException( "Error: a directory is not a valid input to the `resources` argument: %s", path); } } return resourcePaths; }
Example #23
Source File: ConcurrentIssueRegistry.java From n4js with Eclipse Public License 1.0 | 5 votes |
public void setIssuesOfPersistedState(String containerHandle, URI uri, Iterable<? extends LSPIssue> issues) { ImmutableSortedSet<LSPIssue> issuesNew = ImmutableSortedSet.copyOf(issueComparator, issues); ImmutableSortedSet<LSPIssue> issuesOld; synchronized (this) { Map<URI, ImmutableSortedSet<LSPIssue>> containerIssues = getContainerIssues(containerHandle, true); persistedIssues.put(uri, issuesNew); issuesOld = containerIssues.put(uri, issuesNew); } notifyListeners(eventPersisted(containerHandle, uri, issuesOld, issuesNew)); }
Example #24
Source File: PythonTestDescriptionTest.java From buck with Apache License 2.0 | 5 votes |
@Test public void platformDeps() throws IOException { SourcePath libASrc = FakeSourcePath.of("libA.py"); PythonLibraryBuilder libraryABuilder = PythonLibraryBuilder.createBuilder(BuildTargetFactory.newInstance("//:libA")) .setSrcs(SourceSortedSet.ofUnnamedSources(ImmutableSortedSet.of(libASrc))); SourcePath libBSrc = FakeSourcePath.of("libB.py"); PythonLibraryBuilder libraryBBuilder = PythonLibraryBuilder.createBuilder(BuildTargetFactory.newInstance("//:libB")) .setSrcs(SourceSortedSet.ofUnnamedSources(ImmutableSortedSet.of(libBSrc))); PythonTestBuilder binaryBuilder = PythonTestBuilder.create(BuildTargetFactory.newInstance("//:bin")) .setPlatformDeps( PatternMatchedCollection.<ImmutableSortedSet<BuildTarget>>builder() .add( Pattern.compile( CxxPlatformUtils.DEFAULT_PLATFORM_FLAVOR.toString(), Pattern.LITERAL), ImmutableSortedSet.of(libraryABuilder.getTarget())) .add( Pattern.compile("matches nothing", Pattern.LITERAL), ImmutableSortedSet.of(libraryBBuilder.getTarget())) .build()); TargetGraph targetGraph = TargetGraphFactory.newInstance( libraryABuilder.build(), libraryBBuilder.build(), binaryBuilder.build()); ActionGraphBuilder graphBuilder = new TestActionGraphBuilder(targetGraph); PythonTest test = (PythonTest) graphBuilder.requireRule(binaryBuilder.getTarget()); assertThat( test.getBinary() .getComponents() .resolve(graphBuilder.getSourcePathResolver()) .getAllModules() .values(), Matchers.allOf( Matchers.hasItem(graphBuilder.getSourcePathResolver().getAbsolutePath(libASrc)), Matchers.not( Matchers.hasItem(graphBuilder.getSourcePathResolver().getAbsolutePath(libBSrc))))); }
Example #25
Source File: BgpRoute.java From batfish with Apache License 2.0 | 5 votes |
/** Add a single community */ public B addCommunity(Community community) { if (_communities instanceof ImmutableSortedSet) { _communities = new TreeSet<>(_communities); } _communities.add(community); return getThis(); }
Example #26
Source File: CxxLibraryDescriptionTest.java From buck with Apache License 2.0 | 5 votes |
@Test public void sharedLibraryShouldLinkOwnRequiredLibraries() { ProjectFilesystem filesystem = new FakeProjectFilesystem(); CxxPlatform platform = CxxPlatformUtils.DEFAULT_PLATFORM; CxxLibraryBuilder libraryBuilder = new CxxLibraryBuilder( BuildTargetFactory.newInstance("//:foo") .withFlavors(platform.getFlavor(), CxxDescriptionEnhancer.SHARED_FLAVOR)); libraryBuilder .setLibraries( ImmutableSortedSet.of( FrameworkPath.ofSourceTreePath( new SourceTreePath( PBXReference.SourceTree.SDKROOT, Paths.get("/usr/lib/libz.dylib"), Optional.empty())), FrameworkPath.ofSourcePath(FakeSourcePath.of("another/path/liba.dylib")))) .setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(FakeSourcePath.of("foo.c")))); TargetGraph targetGraph = TargetGraphFactory.newInstance(libraryBuilder.build()); ActionGraphBuilder graphBuilder = new TestActionGraphBuilder(targetGraph); CxxLink library = (CxxLink) libraryBuilder.build(graphBuilder, filesystem, targetGraph); assertThat( Arg.stringify(library.getArgs(), graphBuilder.getSourcePathResolver()), hasItems("$SDKROOT/usr/lib", "-la", "-lz")); assertThat( Arg.stringify(library.getArgs(), graphBuilder.getSourcePathResolver()), hasItems("-L")); assertThat( Arg.stringify(library.getArgs(), graphBuilder.getSourcePathResolver()), hasItems(matchesPattern(".*another[/\\\\]path$"))); }
Example #27
Source File: IjProjectWriter.java From buck with Apache License 2.0 | 5 votes |
/** Update the modules.xml file with any new modules from the given set */ private void updateModulesIndex(ImmutableSet<IjModule> modulesEdited) throws IOException { final Set<ModuleIndexEntry> existingModules = modulesParser.getAllModules( projectFilesystem.newFileInputStream(getIdeaConfigDir().resolve("modules.xml"))); final Set<Path> existingModuleFilepaths = existingModules.stream() .map(ModuleIndexEntry::getFilePath) .map(PathFormatter::pathWithUnixSeparators) .map(Paths::get) .collect(ImmutableSet.toImmutableSet()); ImmutableSet<Path> remainingModuleFilepaths = modulesEdited.stream() .map(projectPaths::getModuleImlFilePath) .map(PathFormatter::pathWithUnixSeparators) .map(Paths::get) .filter(modulePath -> !existingModuleFilepaths.contains(modulePath)) .collect(ImmutableSet.toImmutableSet()); // Merge the existing and new modules into a single sorted set ImmutableSortedSet.Builder<ModuleIndexEntry> finalModulesBuilder = ImmutableSortedSet.orderedBy(Comparator.<ModuleIndexEntry>naturalOrder()); // Add the existing definitions finalModulesBuilder.addAll(existingModules); // Add any new module definitions that we haven't seen yet remainingModuleFilepaths.forEach( modulePath -> finalModulesBuilder.add( ModuleIndexEntry.of( getUrl(projectPaths.getProjectQualifiedPath(modulePath)), projectPaths.getProjectRelativePath(modulePath), projectConfig.getModuleGroupName()))); // Write out the merged set to disk writeModulesIndex(finalModulesBuilder.build()); }
Example #28
Source File: PythonLibraryDescriptionTest.java From buck with Apache License 2.0 | 5 votes |
@Test public void platformSrcs() { ProjectFilesystem filesystem = new FakeProjectFilesystem(); BuildTarget target = BuildTargetFactory.newInstance("//foo:lib"); SourcePath pyPlatformMatchedSource = FakeSourcePath.of("foo/a.py"); SourcePath cxxPlatformMatchedSource = FakeSourcePath.of("foo/b.py"); SourcePath unmatchedSource = FakeSourcePath.of("foo/c.py"); PythonLibraryBuilder builder = new PythonLibraryBuilder(target) .setPlatformSrcs( PatternMatchedCollection.<SourceSortedSet>builder() .add( Pattern.compile("^" + PythonTestUtils.PYTHON_PLATFORM.getFlavor() + "$"), SourceSortedSet.ofUnnamedSources( ImmutableSortedSet.of(pyPlatformMatchedSource))) .add( Pattern.compile("^" + CxxPlatformUtils.DEFAULT_PLATFORM_FLAVOR + "$"), SourceSortedSet.ofUnnamedSources( ImmutableSortedSet.of(cxxPlatformMatchedSource))) .add( Pattern.compile("won't match anything"), SourceSortedSet.ofUnnamedSources(ImmutableSortedSet.of(unmatchedSource))) .build()); TargetGraph targetGraph = TargetGraphFactory.newInstance(builder.build()); ActionGraphBuilder graphBuilder = new TestActionGraphBuilder(targetGraph); PythonLibrary library = builder.build(graphBuilder, filesystem, targetGraph); assertThat( library .getPythonModules( PythonTestUtils.PYTHON_PLATFORM, CxxPlatformUtils.DEFAULT_PLATFORM, graphBuilder) .map(modules -> modules.getComponents().values()) .orElseGet(ImmutableSet::of), Matchers.contains(pyPlatformMatchedSource, cxxPlatformMatchedSource)); }
Example #29
Source File: BoundingBox.java From activitystreams with Apache License 2.0 | 5 votes |
private static void addValues( ImmutableSortedSet.Builder<Float> xset, ImmutableSortedSet.Builder<Float> yset, ImmutableSortedSet.Builder<Float> zset, Iterable<Position> positions) { for (Position position : positions) { xset.add(position.northing()); yset.add(position.easting()); if (position.hasAltitude()) zset.add(position.altitude()); } }
Example #30
Source File: Registrar.java From nomulus with Apache License 2.0 | 5 votes |
/** * Returns a list of {@link RegistrarContact} objects of a given type for this registrar sorted by * their email address. */ public ImmutableSortedSet<RegistrarContact> getContactsOfType(final RegistrarContact.Type type) { return Streams.stream(getContactsIterable()) .filter(Objects::nonNull) .filter((@Nullable RegistrarContact contact) -> contact.getTypes().contains(type)) .collect(toImmutableSortedSet(CONTACT_EMAIL_COMPARATOR)); }