void loadMetadataIntoObjectGraph()

in java/io/bazel/rules/closure/webfiles/server/Metadata.java [150:187]


    void loadMetadataIntoObjectGraph() throws IOException {
      long start = System.currentTimeMillis();
      ImmutableSet.Builder<Path> manifestPaths = new ImmutableSet.Builder<>();
      manifestPaths.add(config.getPath());
      WebfilesServerInfo params = config.get();
      List<Webfiles> manifests = new ArrayList<>();
      for (String longPath : params.getManifestList()) {
        Path manifestPath = runfiles.getPath(longPath);
        manifestPaths.add(manifestPath);
        Webfiles.Builder builder = Webfiles.newBuilder();
        TextFormat.getParser().merge(new String(Files.readAllBytes(manifestPath), UTF_8), builder);
        manifests.add(builder.build());
      }
      SortedMap<Webpath, Path> assets = new TreeMap<>(Ordering.natural());
      for (AssetInfo asset : params.getExternalAssetList()) {
        assets.put(Webpath.get(asset.getWebpath()), runfiles.getPath(asset.getPath()));
      }
      for (Webfiles manifest : manifests) {
        for (WebfilesSource src : manifest.getSrcList()) {
          assets.put(Webpath.get(src.getWebpath()), runfiles.getPath(src.getLongpath()));
        }
      }
      Set<Webpath> webpaths = new LinkedHashSet<>();
      for (Webfiles manifest : Lists.reverse(manifests)) {
        for (WebfilesSource src : manifest.getSrcList()) {
          webpaths.add(Webpath.get(src.getWebpath()));
        }
      }
      container.snapshot =
          new Snapshot(
              ImmutableSortedMap.copyOfSorted(assets),
              ImmutableSet.copyOf(webpaths),
              manifestPaths.build());
      logger.info(String.format("Loaded build graph in %,dms", System.currentTimeMillis() - start));
      synchronized (container) {
        container.notifyAll();
      }
    }