Java calls Ant's custom task, which is not a build.xml problem by default

Source: Internet
Author: User

Java calls the ant's custom task,

File BuildFile = new File (".//ee-build.xml");

Create an ant project

Project P = new Project ();

Create a default listener to listen for log operations during project build

Defaultlogger Consolelogger = new Defaultlogger ();

Consolelogger.seterrorprintstream (System.err);

Consolelogger.setoutputprintstream (System.out);

Consolelogger.setmessageoutputlevel (Project.msg_info);

P.addbuildlistener (Consolelogger);

try {

P.firebuildstarted ();

Initialize the project

P.init ();

Projecthelper helper = Projecthelper.getprojecthelper ();

Parse the project's build file

Helper.parse (P, buildfile);

Perform one of the objectives of a project

P.executetarget ("Hello");

P.firebuildfinished (NULL);

} catch (Buildexception be) {

P.firebuildfinished (BE);

}

}

If the target in the Java call uses Antcall to invoke another target, and the target is not defined in Build.xml, the target cannot be found. Because although the file specified above is ee-build.xml, Ant will find the target from Build.xml by default.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Java calls Ant's custom task, which is not a build.xml problem by default

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.