code: List<ResolveTask> adjustResourceRenames(final List<ResolveTask> renames) {
          final Map<KeyScope, List<ResolveTask>> scopes = renames.stream().collect(Collectors.groupingBy(rt -> rt.scope));
  
          final List<ResolveTask> res = new ArrayList<>();
          for (final Map.Entry<KeyScope, List<ResolveTask>> group : scopes.entrySet()) {
              final KeyScope scope = group.getKey();
              final List<ResolveTask> tasks = group.getValue();
              final Map<URI, URI> rewrites = tasks.stream()
                      // FIXME this should be filtered out earlier
                      .filter(t -> t.out != null)
                      .collect(toMap(
                              t -> t.in.uri,
                              t -> t.out.uri
                      ));
              final KeyScope resScope = rewriteScopeTargets(scope, rewrites);
              tasks.stream().map(t -> new ResolveTask(resScope, t.in, t.out)).forEach(res::add);
          }
  
          return res;
      }
docs: Adjust key targets per rewrites