org.apache.tools.ant.Project.topoSort()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(4.1k)|赞(0)|评价(0)|浏览(111)

本文整理了Java中org.apache.tools.ant.Project.topoSort()方法的一些代码示例,展示了Project.topoSort()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project.topoSort()方法的具体详情如下:
包路径:org.apache.tools.ant.Project
类名称:Project
方法名:topoSort

Project.topoSort介绍

[英]Topologically sort a set of targets. Equivalent to calling topoSort(new String[] {root}, targets, true).
[中]对一组目标进行拓扑排序。相当于呼叫topoSort(new String[] {root}, targets, true)

代码示例

代码示例来源:origin: org.apache.ant/ant

/**
 * Topologically sort a set of targets.  Equivalent to calling
 * <code>topoSort(new String[] {root}, targets, returnAll)</code>.
 *
 * @param root The name of the root target. The sort is created in such
 *             a way that the sequence of Targets up to the root
 *             target is the minimum possible such sequence.
 *             Must not be <code>null</code>.
 * @param targetTable A Hashtable mapping names to Targets.
 *                Must not be <code>null</code>.
 * @param returnAll <code>boolean</code> indicating whether to return all
 *                  targets, or the execution sequence only.
 * @return a Vector of Target objects in sorted order.
 * @exception BuildException if there is a cyclic dependency among the
 *                           targets, or if a named target does not exist.
 * @since Ant 1.6.3
 */
public final Vector<Target> topoSort(final String root, final Hashtable<String, Target> targetTable,
               final boolean returnAll) throws BuildException {
  return topoSort(new String[] {root}, targetTable, returnAll);
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Topologically sort a set of targets.  Equivalent to calling
 * <code>topoSort(new String[] {root}, targets, true)</code>.
 *
 * @param root The name of the root target. The sort is created in such
 *             a way that the sequence of Targets up to the root
 *             target is the minimum possible such sequence.
 *             Must not be <code>null</code>.
 * @param targetTable A Hashtable mapping names to Targets.
 *                Must not be <code>null</code>.
 * @return a Vector of ALL Target objects in sorted order.
 * @exception BuildException if there is a cyclic dependency among the
 *                           targets, or if a named target does not exist.
 */
public final Vector<Target> topoSort(final String root, final Hashtable<String, Target> targetTable)
  throws BuildException {
  return topoSort(new String[] {root}, targetTable, true);
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Execute the specified target and any targets it depends on.
 *
 * @param targetName The name of the target to execute.
 *                   Must not be <code>null</code>.
 *
 * @exception BuildException if the build failed.
 */
public void executeTarget(final String targetName) throws BuildException {
  // sanity check ourselves, if we've been asked to build nothing
  // then we should complain
  if (targetName == null) {
    final String msg = "No target specified";
    throw new BuildException(msg);
  }
  // Sort and run the dependency tree.
  // Sorting checks if all the targets (and dependencies)
  // exist, and if there is any cycle in the dependency
  // graph.
  executeSortedTargets(topoSort(targetName, targets, false));
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Does this target depend on the named target?
 * @param other the other named target.
 * @return true if the target does depend on the named target
 * @since Ant 1.6
 */
public boolean dependsOn(String other) {
  Project p = getProject();
  Hashtable<String, Target> t = p == null ? null : p.getTargets();
  return p != null && p.topoSort(getName(), t, false).contains(t.get(other));
}

代码示例来源:origin: org.apache.ant/ant

/** {@inheritDoc}. */
public void executeTargets(Project project, String[] targetNames)
  throws BuildException {
    project.executeSortedTargets(
      project.topoSort(targetNames, project.getTargets(), false));
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ant.ui

/**
 * method assumes sendor has checked whether to report problems
 */
private void checkCircularDependencies(IAntElement node) {
  Target target = ((AntTargetNode) node).getTarget();
  String name = target.getName();
  if (name == null) {
    return;
  }
  try {
    target.getProject().topoSort(name, target.getProject().getTargets());
  }
  catch (BuildException be) {
    // possible circular dependency
    String message = be.getMessage();
    if (message.startsWith("Circular")) { //$NON-NLS-1$ //we do our own checking for missing dependencies
      IProblem problem = createProblem(message, node.getProjectNode().getOffset(), node.getProjectNode().getSelectionLength(), AntModelProblem.SEVERITY_ERROR);
      acceptProblem(problem);
      markHierarchy(node.getProjectNode(), AntModelProblem.SEVERITY_ERROR, message);
    }
  }
}

相关文章