posts - 165, comments - 198, trackbacks - 0, articles - 1
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

制定自己 ant 标签

Posted on 2007-04-11 17:11 G_G 阅读(417) 评论(0)  编辑  收藏 所属分类: ant
/src/my/test.java

package my ;

import java.util.Date ;

public class test{
    private String name ;
    private Date nowTime ;
   
    public void setName(String name){
        this.name = name ;   
    }
    public String getName(){
        return this.name;   
    }
   
    public void setNowTime(String nowTime)throws Exception{
        this.nowTime = (Date)(Class.forName( nowTime ).newInstance()) ;
    }
    public Date getNowTime(){
        return this.nowTime ;   
    }
   
   
    public void execute(){
        System.out.println("ok : "+name+" : "+nowTime);       
    }
}
 /////////////////////////////////////////// ant ///////////////////////////////////

<?xml version="1.0"?>

<project name="test" default="compile">

    <property name="src" location="src" />
    <property name="build" location="build" />
   
    <target name="init">
        <mkdir dir="${build}" />
    </target>
   
    <target name="compile" depends="init">
        <javac srcdir="${src}" destdir="${build}" />   
    </target>
   
    <target name="test" depends="compile">
        <taskdef name="test" classname="my.test" classpath="${build}" />
        <test
            name="liukaiyi"
            nowTime="java.util.Date"
        />
    </target>
   
    <target name="delete">
        <delete dir="${build}" />
    </target>
   
</project>


代码先上哈 
我感觉 可以 动态的写配置 ant  并动态运行 ant  再把 新生成的 对象放在 jvm 中 动态的使用 
新手 多指教

只有注册用户登录后才能发表评论。


网站导航: