Exemplo n.º 1
0
  public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException {
    modules = Collections.emptyMap(); // needed during load
    super.onLoad(parent, name);

    modules =
        loadChildren(
            this,
            getModulesDir(),
            new Function1<ModuleName, MavenModule>() {
              public ModuleName call(MavenModule module) {
                return module.getModuleName();
              }
            });
    // update the transient nest level field.
    MavenModule root = getRootModule();
    if (root != null && root.getChildren() != null) {
      List<MavenModule> sortedList = new ArrayList<MavenModule>();
      Stack<MavenModule> q = new Stack<MavenModule>();
      root.nestLevel = 0;
      q.push(root);
      while (!q.isEmpty()) {
        MavenModule p = q.pop();
        sortedList.add(p);
        List<MavenModule> children = p.getChildren();
        if (children != null) {
          for (MavenModule m : children) m.nestLevel = p.nestLevel + 1;
          for (int i = children.size() - 1; i >= 0; i--) // add them in the reverse order
          q.push(children.get(i));
        }
      }
      this.sortedActiveModules = sortedList;
    } else {
      this.sortedActiveModules = getDisabledModules(false);
    }

    if (reporters == null)
      reporters = new DescribableList<MavenReporter, Descriptor<MavenReporter>>(this);
    reporters.setOwner(this);
    if (publishers == null)
      publishers = new DescribableList<Publisher, Descriptor<Publisher>>(this);
    publishers.setOwner(this);
    if (buildWrappers == null)
      buildWrappers = new DescribableList<BuildWrapper, Descriptor<BuildWrapper>>(this);
    buildWrappers.setOwner(this);

    updateTransientActions();
  }