code: public void flattenPackagesSourcesAndArtifacts(Map<String,Module> m) {
          modules = m;
          // Extract all the found packages.
          for (Module i : modules.values()) {
              for (Map.Entry<String,Package> j : i.packages().entrySet()) {
                  Package p = packages.get(j.getKey());
                  // Check that no two different packages are stored under same name.
                  assert(p == null || p == j.getValue());
                  if (p == null) {
                      p = j.getValue();
                      packages.put(j.getKey(),j.getValue());
                  }
                  for (Map.Entry<String,Source> k : p.sources().entrySet()) {
                      Source s = sources.get(k.getKey());
                      // Check that no two different sources are stored under same name.
                      assert(s == null || s == k.getValue());
                      if (s == null) {
                          s = k.getValue();
                          sources.put(k.getKey(), k.getValue());
                      }
                  }
                  for (Map.Entry<String,File> g : p.artifacts().entrySet()) {
                      File f = artifacts.get(g.getKey());
                      // Check that no two artifacts are stored under the same file.
                      assert(f == null || f == g.getValue());
                      if (f == null) {
                          f = g.getValue();
                          artifacts.put(g.getKey(), g.getValue());
                      }
                  }
              }
          }
      }
docs: Store references to all packages, sources and artifacts for all modules
  into the build state. I.e. flatten the module tree structure
  into global maps stored in the BuildState for easy access.
  
  @param m The set of modules.