java - Logging in custom ant tasks -
i'm creating custom ant task, performs io tasks based on user received param(like file write/append)
i wanted write task if developer using in ant task runs -v
or -d
flag, output more,
i'm wondering how core ant tasks doing it. checking output level before printing console or done using java.util.logging.logger
follow tutorial.
extract :
integration taskadapter
our class has nil ant. extends no superclass , implements no interface. how ant know integrate? via name convention: our class provides method signature public void execute(). class wrapped ant's org.apache.tools.ant.taskadapter task , uses reflection setting reference project , calling execute() method.
setting reference project? interesting. project class gives nice abilities: access ant's logging facilities getting , setting properties , much more. seek utilize class:
import org.apache.tools.ant.project;
public class helloworld {
private project project; public void setproject(project proj) { project = proj; } public void execute() { string message = project.getproperty("ant.project.name"); project.log("here project '" + message + "'.", project.msg_info); } }
[...]
java logging ant
No comments:
Post a Comment