Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Check out the source of Ant's main class, <a href="http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/Main.java?view=co" rel="nofollow noreferrer"><code>org.apache.tools.ant.Main</code></a>. You can try to invoke its <code>main</code> or <code>start</code> method directly, or copy some of its logic to your application. <del>After those methods finish, your application should continue execution.</del></p> <p><strong>EDIT:</strong></p> <p><a href="https://stackoverflow.com/a/8715524/232235">The answer by Paul Cager</a> is correct, I somehow missed the fact that Ant's <code>Main</code> calls <code>System.exit()</code>.</p> <p>Another thing about the <code>main</code>/<code>start</code>/<code>startAnt</code> methods is that they expect the arguments as an array of strings. This can be handy, but it's not particularly typesafe or object-oriented. To invoke Ant for a given buildfile and target, you can use something like this:</p> <pre><code>public static void runAnt(String buildfile, String target) throws Exception { File buildFile = new File(buildfile); Exception error = null; org.apache.tools.ant.Project project = new org.apache.tools.ant.Project(); try { project.addBuildListener(new org.apache.tools.ant.listener.Log4jListener()); project.fireBuildStarted(); project.init(); project.setUserProperty(org.apache.tools.ant.MagicNames.ANT_FILE, buildFile.getAbsolutePath()); org.apache.tools.ant.ProjectHelper.configureProject(project, buildFile); project.executeTarget(target); } catch (Exception e) { error = e; throw e; } finally { project.fireBuildFinished(error); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload