自定义简单的ant task

编写一个简单的java类,里面必须包含一个public的execute方法:

package org.home.ant.tasks;

public class MyTask {

	public void execute() {

		System.out.println("This is My  Task!");

	}
}

构建build.xml:

<?xml  version="1.0" encoding="UTF-8" ?>

<project  name="tasks"  default="main">

       <property  name="build.dir"  location="build"/>

       <target  name="init">

              <mkdir  dir="${build.dir}" />

       </target>

       <target  name="compile"  depends="init">

              <javac  srcdir="src"  destdir="${build.dir}"/>

       </target>

       <target  name="mytask"  depends="compile">

              <taskdef  name="mytask"

  classname="org.home.ant.tasks.MyTask" classpath="${build.dir}" />

                     <mytask/>

</target>

<target  name="clean">

       <delete  dir="${build.dir}" />

</target>

<target  name="main"  depends="mytask"/>

       </project>




 

你可能感兴趣的:(ant)