protected void buildDependencyGraph(DependencyGraph graph) {
   Collection<MavenModule> modules = getModules();
   for (MavenModule m : modules) {
     m.buildDependencyGraph(graph);
   }
   publishers.buildDependencyGraph(this, graph);
   buildWrappers.buildDependencyGraph(this, graph);
 }
  /**
   * The next build of {@link MavenModuleSet} must have the build number newer than any of the
   * current module build.
   */
  /*package*/ void updateNextBuildNumber() throws IOException {
    int next = this.nextBuildNumber;
    for (MavenModule m : modules.values()) next = Math.max(next, m.getNextBuildNumber());

    if (this.nextBuildNumber != next) {
      this.nextBuildNumber = next;
      this.saveNextBuildNumber();
    }
  }
  /**
   * Possibly empty list of all disabled modules (if disabled==true) or all enabeld modules (if
   * disabled==false)
   */
  public List<MavenModule> getDisabledModules(boolean disabled) {
    if (!disabled && sortedActiveModules != null) return sortedActiveModules;

    List<MavenModule> r = new ArrayList<MavenModule>();
    for (MavenModule m : modules.values()) {
      if (m.isDisabled() == disabled) r.add(m);
    }
    return r;
  }
  protected List<Action> createTransientActions() {
    List<Action> r = super.createTransientActions();

    // Fix for ISSUE-1149
    for (MavenModule module : modules.values()) {
      module.updateTransientActions();
    }

    if (publishers
        != null) // this method can be loaded from within the onLoad method, where this might be
      // null
      for (BuildStep step : publishers) r.addAll(step.getProjectActions(this));

    if (buildWrappers != null)
      for (BuildWrapper step : buildWrappers) r.addAll(step.getProjectActions(this));

    return r;
  }
  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();
  }
 /** Delete all disabled modules. */
 public void doDoDeleteAllDisabledModules(StaplerResponse rsp)
     throws IOException, InterruptedException {
   checkPermission(DELETE);
   for (MavenModule m : getDisabledModules(true)) m.delete();
   rsp.sendRedirect2(".");
 }
 public void logRotate() throws IOException, InterruptedException {
   super.logRotate();
   // perform the log rotation of modules
   for (MavenModule m : modules.values()) m.logRotate();
 }
 public File getRootDirFor(MavenModule child) {
   return new File(getModulesDir(), child.getModuleName().toFileSystemName());
 }
 /** Returns true if there's any disabled module. */
 public boolean hasDisabledModule() {
   for (MavenModule m : modules.values()) {
     if (m.isDisabled()) return true;
   }
   return false;
 }
 /**
  * Called by {@link MavenModule#doDoDelete(StaplerRequest, StaplerResponse)}. Real deletion is
  * done by the caller, and this method only adjusts the data structure the parent maintains.
  */
 /*package*/ void onModuleDeleted(MavenModule module) {
   modules.remove(module.getModuleName());
 }