@Override
  public Collection<? extends Action> getProjectActions(AbstractProject<?, ?> project) {
    ArrayList<TestflightBuildAction> actions = new ArrayList<TestflightBuildAction>();
    RunList<? extends AbstractBuild<?, ?>> builds = project.getBuilds();

    Collection predicated =
        CollectionUtils.select(
            builds,
            new Predicate() {
              public boolean evaluate(Object o) {
                Result result = ((AbstractBuild<?, ?>) o).getResult();
                if (result == null) return false; // currently running builds can have a null result
                return result.isBetterOrEqualTo(Result.SUCCESS);
              }
            });

    ArrayList<AbstractBuild<?, ?>> filteredList = new ArrayList<AbstractBuild<?, ?>>(predicated);

    Collections.reverse(filteredList);
    for (AbstractBuild<?, ?> build : filteredList) {
      List<TestflightBuildAction> testflightActions = build.getActions(TestflightBuildAction.class);
      if (testflightActions != null && testflightActions.size() > 0) {
        for (TestflightBuildAction action : testflightActions) {
          actions.add(new TestflightBuildAction(action));
        }
        break;
      }
    }

    return actions;
  }
예제 #2
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();
  }