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

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

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

Project.getTargets介绍

[英]Return the hashtable of targets. The returned hashtable is "live" and so should not be modified.
[中]返回目标的哈希表。返回的哈希表是“活动”的,因此不应修改。

代码示例

代码示例来源:origin: org.testng/testng

protected void validateOptions() throws BuildException {
 int suiteCount = getSuiteFileNames().size();
 if (suiteCount == 0
  && m_classFilesets.size() == 0
  && Utils.isStringEmpty(m_methods)
  && ((null == m_testjar) || !m_testjar.isFile())) {
  throw new BuildException("No suites, classes, methods or jar file was specified.");
 }
 if((null != m_includedGroups) && (m_classFilesets.size() == 0 && suiteCount == 0)) {
  throw new BuildException("No class filesets or xml file sets specified while using groups");
 }
 if(m_onHaltTarget != null) {
  if(!getProject().getTargets().containsKey(m_onHaltTarget)) {
   throw new BuildException("Target " + m_onHaltTarget + " not found in this project");
  }
 }
}

代码示例来源:origin: cbeust/testng

protected void validateOptions() throws BuildException {
 int suiteCount = getSuiteFileNames().size();
 if (suiteCount == 0
   && m_classFilesets.size() == 0
   && Utils.isStringEmpty(m_methods)
   && ((null == m_testjar) || !m_testjar.isFile())) {
  throw new BuildException("No suites, classes, methods or jar file was specified.");
 }
 if ((null != m_includedGroups) && (m_classFilesets.size() == 0 && suiteCount == 0)) {
  throw new BuildException("No class filesets or xml file sets specified while using groups");
 }
 if (m_onHaltTarget != null) {
  if (!getProject().getTargets().containsKey(m_onHaltTarget)) {
   throw new BuildException("Target " + m_onHaltTarget + " not found in this project");
  }
 }
}

代码示例来源: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.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 {
  Hashtable<String, Target> targets = project.getTargets();
  BuildException thrownException = null;
  for (String targetName : targetNames) {
    try {
      Target t = targets.get(targetName);
      if (t == null) {
        throw new BuildException("Unknown target " + targetName);
      }
      t.performTasks();
    } catch (BuildException ex) {
      if (project.isKeepGoingMode()) {
        thrownException = ex;
      } else {
        throw ex;
      }
    }
  }
  if (thrownException != null) {
    throw thrownException;
  }
}

代码示例来源:origin: org.testng/testng

/** Executes the target, if any, that user designates executing before failing the test */
private void executeHaltTarget(int exitValue) {
 if(m_onHaltTarget != null) {
  if(m_outputDir != null) {
   getProject().setProperty("testng.outputdir", m_outputDir.getAbsolutePath());
  }
  getProject().setProperty("testng.returncode", String.valueOf(exitValue));
  Target t= getProject().getTargets().get(m_onHaltTarget);
  if(t != null) {
   t.execute();
  }
 }
}

代码示例来源:origin: apache/groovy

private Target onStartTarget(final Attributes attrs, String tagName, String ns) {
  final Target target = new Target();
  target.setProject(project);
  target.setLocation(new Location(antXmlContext.getLocator()));
  try {
    antTargetHandler.onStartElement(ns, tagName, tagName, attrs, antXmlContext);
    final Target newTarget = getProject().getTargets().get(attrs.getValue("name"));
    // execute dependencies (if any)
    final Vector<Target> targets = new Vector<Target>();
    for (final Enumeration<String> deps = newTarget.getDependencies(); deps.hasMoreElements();) {
      final String targetName = deps.nextElement();
      targets.add(project.getTargets().get(targetName));
    }
    getProject().executeSortedTargets(targets);
    antXmlContext.setCurrentTarget(newTarget);
    return newTarget;
  }
  catch (final SAXParseException e) {
    log.log(Level.SEVERE, "Caught: " + e, e);
  }
  return null;
}

代码示例来源:origin: cbeust/testng

/** Executes the target, if any, that user designates executing before failing the test */
private void executeHaltTarget(int exitValue) {
 if (m_onHaltTarget != null) {
  if (m_outputDir != null) {
   getProject().setProperty("testng.outputdir", m_outputDir.getAbsolutePath());
  }
  getProject().setProperty("testng.returncode", String.valueOf(exitValue));
  Target t = getProject().getTargets().get(m_onHaltTarget);
  if (t != null) {
   t.execute();
  }
 }
}

代码示例来源:origin: apache/groovy

private Target onDefineTarget(final Attributes attrs, String tagName, String ns) {
  final Target target = new Target();
  target.setProject(project);
  target.setLocation(new Location(antXmlContext.getLocator()));
  try {
    antTargetHandler.onStartElement(ns, tagName, tagName, attrs, antXmlContext);
    final Target newTarget = getProject().getTargets().get(attrs.getValue("name"));
    antXmlContext.setCurrentTarget(newTarget);
    definingTarget = newTarget;
    return newTarget;
  }
  catch (final SAXParseException e) {
    log.log(Level.SEVERE, "Caught: " + e, e);
  }
  return null;
}

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

Hashtable<String, Target> projectTargets = project.getTargets();
Target extPoint = null;
if (prefixAndSep == null) {

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

final Map<String, Target> ptargets = removeDuplicateTargets(project.getTargets());

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

target.getLocation());
Hashtable<String, Target> projectTargets = project.getTargets();
boolean usedTarget = false;

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

final Map<String, Target> targetsMap = getProject().getTargets();

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

/**
 * Returns the name of a missing dependency or <code>null</code> if all dependencies exist in the project.
 */
public String checkDependencies() {
  Enumeration<String> dependencies = fTarget.getDependencies();
  while (dependencies.hasMoreElements()) {
    String dependency = dependencies.nextElement();
    if (fTarget.getProject().getTargets().get(dependency) == null) {
      return dependency;
    }
  }
  return null;
}

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

private Map<String, Target> getTargets() {
  Project project = antModel.getProjectNode().getProject();
  return project.getTargets();
}

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

@Override
public void reset() {
  super.reset();
  Map<String, Target> currentTargets = fTarget.getProject().getTargets();
  if (currentTargets.get(fTarget.getName()) != null) {
    currentTargets.remove(fTarget.getName());
  }
}

代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm

private Target onStartTarget(final Attributes attrs, String tagName, String ns) {
  final Target target = new Target();
  target.setProject(project);
  target.setLocation(new Location(antXmlContext.getLocator()));
  try {
    antTargetHandler.onStartElement(ns, tagName, tagName, attrs, antXmlContext);
    final Target newTarget = (Target) getProject().getTargets().get(attrs.getValue("name"));
    // execute dependencies (if any)
    final Vector targets = new Vector();
    for (final Enumeration deps = newTarget.getDependencies(); deps.hasMoreElements();) {
      final String targetName = (String) deps.nextElement();
      targets.add(project.getTargets().get(targetName));
    }
    getProject().executeSortedTargets(targets);
    antXmlContext.setCurrentTarget(newTarget);
    return newTarget;
  }
  catch (final SAXParseException e) {
    log.log(Level.SEVERE, "Caught: " + e, e);
  }
  return null;
}

代码示例来源:origin: org.codehaus.groovy/groovy-ant

private Target onStartTarget(final Attributes attrs, String tagName, String ns) {
  final Target target = new Target();
  target.setProject(project);
  target.setLocation(new Location(antXmlContext.getLocator()));
  try {
    antTargetHandler.onStartElement(ns, tagName, tagName, attrs, antXmlContext);
    final Target newTarget = getProject().getTargets().get(attrs.getValue("name"));
    // execute dependencies (if any)
    final Vector<Target> targets = new Vector<Target>();
    for (final Enumeration<String> deps = newTarget.getDependencies(); deps.hasMoreElements();) {
      final String targetName = deps.nextElement();
      targets.add(project.getTargets().get(targetName));
    }
    getProject().executeSortedTargets(targets);
    antXmlContext.setCurrentTarget(newTarget);
    return newTarget;
  }
  catch (final SAXParseException e) {
    log.log(Level.SEVERE, "Caught: " + e, e);
  }
  return null;
}

代码示例来源:origin: org.kohsuke.droovy/groovy

private Target onStartTarget(final Attributes attrs, String tagName, String ns) {
  final Target target = new Target();
  target.setProject(project);
  target.setLocation(new Location(antXmlContext.getLocator()));
  try {
    antTargetHandler.onStartElement(ns, tagName, tagName, attrs, antXmlContext);
    final Target newTarget = (Target) getProject().getTargets().get(attrs.getValue("name"));
    // execute dependencies (if any)
    final Vector targets = new Vector();
    for (final Enumeration deps=newTarget.getDependencies(); deps.hasMoreElements();)
    {
      final String targetName = (String) deps.nextElement();
      targets.add(project.getTargets().get(targetName));
    }
    getProject().executeSortedTargets(targets);
    
    antXmlContext.setCurrentTarget(newTarget);
    return newTarget;
  } 
  catch (final SAXParseException e) {
    log.log(Level.SEVERE, "Caught: " + e, e);
  }
  return null;
}

代码示例来源:origin: org.codehaus.groovy/groovy-ant

private Target onDefineTarget(final Attributes attrs, String tagName, String ns) {
  final Target target = new Target();
  target.setProject(project);
  target.setLocation(new Location(antXmlContext.getLocator()));
  try {
    antTargetHandler.onStartElement(ns, tagName, tagName, attrs, antXmlContext);
    final Target newTarget = getProject().getTargets().get(attrs.getValue("name"));
    antXmlContext.setCurrentTarget(newTarget);
    definingTarget = newTarget;
    return newTarget;
  }
  catch (final SAXParseException e) {
    log.log(Level.SEVERE, "Caught: " + e, e);
  }
  return null;
}

相关文章