您的位置:首页 > 其它

ant初识(二)

2015-03-28 23:32 99 查看
<?xml version="1.0"?>
<project name="AntTEST" default="runjar">

<target name="testjar">
<jar destfile="helloworld.jar" basedir="build/classes">
<manifest>
<attribute name="Main-Class" value="test.HelloWorld" />
</manifest>
</jar>
</target>

<target name="createfile">
<touch file="b.txt">
</touch>
<echo file="a.txt" >create file : a.txt</echo>
<!-- create file and set/reset content -->
</target>

<target name="renamefile">
<rename dest="aa.txt" src="a.txt"/>
</target>

<target name="delfile">
<delete file="aa.txt">
</delete>
</target>

<target name="fileops">
<antcall target="delfile">
</antcall><span style="font-family: Arial, Helvetica, sans-serif;"><!-- ant可以组织外部文件  --></span>

</target>

<!-- 执行程序  -->
<target name="cmdtest">
<exec executable="cmd">
<arg value="/c" />
<arg value="ipconfig"/>
</exec>
</target>

<!-- run jar -->
<target name="runjar">
<java jar="helloworld.jar" fork="true">
<arg value="2"/>
</java>
</target>

<!-- 编译依赖 -->
<path id="base.classpath">
<fileset dir="${basedir}/src/web/META-INF/lib" />
</path>
<path id="depend.classpath">
<!-- depend jars -->
<fileset dir="${base.root.dir}/Common/lib-compile" includes="*.jar" />
<!-- depend project source -->
<pathelement location="${base.root.dir}/SDK/build/classes" />
</path>
<target name="compilewithdepend">
<javac destdir="${basedir}/src/web/META-INF/classes" srcdir="${basedir}/src/java" debug="true" includeantruntime="false">
<classpath refid="base.classpath" />
</javac>
</target>

<!--  创建时间戳文件,标记执行时间 -->
<target name="runtime">
<property name="runtimefile" value="runtime.txt">
</property>
<tstamp >
<format pattern="yyyy-MM-dd HH:mm:ss" property="tadaytstamp"/>
</tstamp>

<echo file="${runtimefile}" message="${tadaytstamp}">
</echo>
<touch file="${runtimefile}" datetime="${tadaytstamp}" pattern="yyyy-MM-dd HH:mm:ss"/>
</target>

</project>


java类HelloWorld:

package test;

public class HelloWorld {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("args.length=" + args.length);
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: