Example #1
0
 /**
  * Detects cyclical dependencies in this <code>Project</code>. This method returns the <code>
  * Builder</code> instances that are in cyclical dependencies. If there are no cyclical
  * dependencies, this method returns <code>null</code>.
  *
  * <p>The <code>Builder</code> instances in cyclical dependencies do not participate in <code>
  * build(boolean)</code>, <code>clean()</code> or <code>stop()</code> methods.
  *
  * <p>The <code>getBuildOrder()</code> method does not iterate over <code>Builder</code> instances
  * that are in cyclical dependencies.
  *
  * <p>You should call this method at least once.
  *
  * @return A set of <code>Builder</code> instances that are in cyclical dependencies.
  */
 public Set detectCycles() {
   Set builders = Algorithms.detectCycles(dependencies);
   if (builders != null && builders.size() == 0) {
     builders = null;
   }
   return builders;
 }
Example #2
0
  /**
   * Gets the build order for the <code>Project</code>. The build order is determined by the
   * dependencies among <code>Builder</code> instances.
   *
   * @return <code>Iterator</code> build order; the elements are either instance of the <code>
   *     Application</code> class or the <code>Library</code> class.
   */
  public Iterator<Builder> getBuildOrder() {
    final List<Builder> buildOrder = new ArrayList<Builder>(dependencies.size());

    Algorithms.topologicalSort(
        dependencies,
        new Visitor<Vertex<String, Builder>>() {
          public void visit(Vertex<String, Builder> v) {
            String name = v.getWeight();
            buildOrder.add(dependencies.get(name));
          }
        });

    return buildOrder.iterator();
  }