ant初识(二)


<?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);
	}

}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值