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

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

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

Project.createTask介绍

[英]Create a new instance of a task, adding it to a list of created tasks for later invalidation. This causes all tasks to be remembered until the containing project is removed
[中]创建任务的新实例,并将其添加到已创建任务的列表中,以供以后失效。这会导致所有任务都被记住,直到包含的项目被删除

代码示例

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

String classname = definition.className;
if (classname == null) {
  instance = getProject().createTask(definition.type);
  if (instance == null) {
    instance = getProject().createDataType(definition.type);

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

/**
 * Creates a named task and configures it up to the init() stage.
 *
 * @param ue The UnknownElement to create the real task for.
 *           Must not be <code>null</code>.
 * @param w  Ignored.
 *
 * @return the task specified by the given unknown element, or
 *         <code>null</code> if the task name is not recognised.
 */
protected Task makeTask(UnknownElement ue, RuntimeConfigurable w) {
  Task task = getProject().createTask(ue.getTag());
  if (task != null) {
    task.setLocation(getLocation());
    // UnknownElement always has an associated target
    task.setOwningTarget(getOwningTarget());
    task.init();
  }
  return task;
}

代码示例来源:origin: spotbugs/spotbugs

@Override
public void execute() throws BuildException {
  findbugsEngine = (Java) getProject().createTask("java");

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

/**
 * Generate the client jar corresponding to the jar file passed as parameter
 * the method uses the BorlandGenerateClient task.
 * @param sourceJar java.io.File representing the produced jar file
 */
private void generateClient(File sourceJar) {
  getTask().getProject().addTaskDefinition("internal_bas_generateclient",
    org.apache.tools.ant.taskdefs.optional.ejb.BorlandGenerateClient.class);
  BorlandGenerateClient gentask;
  log("generate client for " + sourceJar, Project.MSG_INFO);
  try {
    Project project = getTask().getProject();
    gentask
      = (BorlandGenerateClient) project.createTask("internal_bas_generateclient");
    gentask.setEjbjar(sourceJar);
    gentask.setDebug(java2iiopdebug);
    Path classpath = getCombinedClasspath();
    if (classpath != null) {
      gentask.setClasspath(classpath);
    }
    gentask.setVersion(version);
    gentask.setTaskName("generate client");
    gentask.execute();
  } catch (Exception e) {
    //TO DO : delete the file if it is not a valid file.
    throw new BuildException("Exception while calling " + VERIFY, e);
  }
}

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

task = helperImpl.project.createTask(tag);
} catch (BuildException e) {

代码示例来源:origin: org.apache.geronimo.genesis.plugins/plugin-support

public Task createTask(final String name) throws BuildException {
  assert name != null;
  return getAnt().createTask(name);
}

代码示例来源:origin: appfuse/appfuse

private void removeUITests() {
  File existingFile = new File(installedDirectory + "/src/test/resources/web-tests.xml");
  if (existingFile.exists()) {
    parseXMLFile(existingFile, pojoName);
    // Remove tests in run-all-tests target
    Replace replace = (Replace) antProject.createTask("replace");
    replace.setFile(existingFile);
    replace.setToken("," + pojoName + "Tests");
    replace.execute();
  }
}

代码示例来源:origin: appfuse/appfuse

private void installStrutsViews() {
  Copy copy = (Copy) antProject.createTask("copy");
  copy.setFile(new File(sourceDirectory + "/src/main/webapp/WEB-INF/pages/" + pojoName + "Form.jsp"));
  copy.setTofile(new File(destinationDirectory + "/src/main/webapp/WEB-INF/pages/" + pojoNameLower + "Form.jsp"));
  copy.execute();
  copy.setFile(new File(sourceDirectory + "/src/main/webapp/WEB-INF/pages/" + pojoName + "List.jsp"));
  copy.setTofile(new File(destinationDirectory + "/src/main/webapp/WEB-INF/pages/" + pojoNameLower + "List.jsp"));
  copy.execute();
}

代码示例来源:origin: appfuse/appfuse

private void installStripesViews() {
  Copy copy = (Copy) antProject.createTask("copy");
  copy.setFile(new File(sourceDirectory + "/src/main/webapp/" + pojoName + "Form.jsp"));
  copy.setTofile(new File(destinationDirectory + "/src/main/webapp/" + pojoNameLower + "Form.jsp"));
  copy.execute();
  copy.setFile(new File(sourceDirectory + "/src/main/webapp/" + pojoName + "List.jsp"));
  copy.setTofile(new File(destinationDirectory + "/src/main/webapp/" + pojoNameLower + "List.jsp"));
  copy.execute();
}

代码示例来源:origin: appfuse/appfuse

private void installJSFViews() {
  Copy copy = (Copy) antProject.createTask("copy");
  copy.setFile(new File(sourceDirectory + "/src/main/webapp/" + pojoName + "Form.xhtml"));
  copy.setTofile(new File(destinationDirectory + "/src/main/webapp/" + pojoNameLower + "Form.xhtml"));
  copy.execute();
  copy.setFile(new File(sourceDirectory + "/src/main/webapp/" + pojoName + "s.xhtml"));
  copy.setTofile(new File(destinationDirectory + "/src/main/webapp/" + util.getPluralForWord(pojoNameLower) + ".xhtml"));
  copy.execute();
}

代码示例来源:origin: appfuse/appfuse

private void installSpringViews() {
  Copy copy = (Copy) antProject.createTask("copy");
  copy.setFile(new File(sourceDirectory + "/src/main/webapp/WEB-INF/pages/" + pojoName + "form.jsp"));
  copy.setTofile(new File(destinationDirectory + "/src/main/webapp/WEB-INF/pages/" + pojoNameLower + "form.jsp"));
  copy.execute();
  copy.setFile(new File(sourceDirectory + "/src/main/webapp/WEB-INF/pages/" + pojoName + "s.jsp"));
  copy.setTofile(new File(destinationDirectory + "/src/main/webapp/WEB-INF/pages/" + util.getPluralForWord(pojoNameLower) + ".jsp"));
  copy.execute();
}

代码示例来源:origin: appfuse/appfuse

private void installSpringFreemarkerViews() {
  Copy copy = (Copy) antProject.createTask("copy");
  copy.setFile(new File(sourceDirectory + "/src/main/webapp/" + pojoName + "form.ftl"));
  copy.setTofile(new File(destinationDirectory + "/src/main/webapp/" + pojoNameLower + "form.ftl"));
  copy.execute();
  copy.setFile(new File(sourceDirectory + "/src/main/webapp/" + pojoName + "list.ftl"));
  copy.setTofile(new File(destinationDirectory + "/src/main/webapp/" + util.getPluralForWord(pojoNameLower) + ".ftl"));
  copy.execute();
}

代码示例来源:origin: appfuse/appfuse

private void installTapestryViews() {
  Copy copy = (Copy) antProject.createTask("copy");
  copy.setFile(new File(sourceDirectory + "/src/main/webapp/" + pojoName + "Form.tml"));
  copy.setTodir(new File(destinationDirectory + "/src/main/webapp"));
  copy.execute();
  copy.setFile(new File(sourceDirectory + "/src/main/webapp/" + pojoName + "List.tml"));
  copy.execute();
  log("Installing menu...");
  createLoadFileTask("src/main/webapp/" + pojoName + "-menu.tml", "tapestry-menu").execute();
  File existingFile = new File(destinationDirectory + "/src/main/resources/" +
      project.getGroupId().replace(".", "/") + "/webapp/components/Layout.tml");
  parseXMLFile(existingFile, pojoName, "<!-- Add new menu items here -->", "tapestry-menu");
}

代码示例来源:origin: appfuse/appfuse

/**
 * This method will remove files from the source directory.
 *
 * @param installedDirectory The destination directory to copy to.
 * @param removePattern      The file pattern to match to locate files to copy.
 */
protected void removeGeneratedFiles(final String installedDirectory, final String removePattern) {
  Delete deleteTask = (Delete) antProject.createTask("delete");
  FileSet fileSet = AntUtils.createFileset(installedDirectory, removePattern, new ArrayList());
  log("Removing generated files (pattern: " + removePattern + ")...");
  deleteTask.addFileset(fileSet);
  deleteTask.execute();
}

代码示例来源:origin: stackoverflow.com

Project p = new Project();
p.init();
p.addBuildListener( new SimpleBuildListener() );
p.setBaseDir( new File( "." ).getAbsoluteFile() );

Javac task = (Javac) p.createTask( "javac" );
task.srcdir( srcDirPath );

// Filsets can be built this way
FileSet set = new FileSet();
set.setDir( srcDirPath );
set.setIncludes( "**/*.java" );

task.addFileset( set );

代码示例来源:origin: net.wasdev.wlp.ant/wlp-anttasks

protected void installLiberty(File jarFile) throws Exception {
  Java java = (Java) getProject().createTask("java");
  java.setJar(jarFile);
  java.setFork(true);
  java.createArg().setValue("-acceptLicense");
  java.createArg().setValue(baseDir);
  int exitCode = java.executeJava();
  if (exitCode != 0) {
    throw new BuildException("Error installing Liberty.");
  }
}

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

private void loadDeliveryList() {
  Property property = (Property) getProject().createTask("property");
  property.setOwningTarget(getOwningTarget());
  property.init();
  property.setFile(deliveryList);
  property.perform();
}

代码示例来源:origin: net.wasdev.wlp.ant/wlp-anttasks

private void onlineDownload(URL source, File dest) throws IOException {
  Get get = (Get) getProject().createTask("get");
  DownloadProgress progress = null;
  if (verbose) {
    progress = new Get.VerboseProgress(System.out);
  }
  get.setUseTimestamp(true);
  get.setUsername(username);
  get.setPassword(password);
  get.setMaxTime(maxDownloadTime);
  get.doGet(source, dest, Project.MSG_INFO, progress);
}

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

private void appendDeliveryList(String msg) {
  Echo echo = (Echo) getProject().createTask("echo");
  echo.setOwningTarget(getOwningTarget());
  echo.init();
  echo.setFile(deliveryList);
  echo.setMessage(msg + "\n");
  echo.setAppend(true);
  echo.perform();
}

代码示例来源:origin: axis/axis-ant

/**
 * Call the selected ant task.
 */
private void antcall (String taskName) {
  CallTarget callee;
  callee = (CallTarget) getProject().createTask("antcall");
  callee.setOwningTarget(getOwningTarget());
  callee.setTaskName(getTaskName());
  callee.setLocation(getLocation());
  callee.init();
  callee.setTarget(taskName);
  callee.execute();
}

相关文章