Ant DataType

Ant DataType 小结:
<?xml version="1.0" encoding="UTF-8"?>
<project name="build" basedir=".">
	
	<property name="src.dir" value="src"/>
	<property name="doc.dir" value="doc"/>
	
	<target name="javadoc">
		<delete dir="build"/>
		<delete dir="${doc.dir}"/>
		<mkdir dir="${doc.dir}"/>
		<javadoc encoding="GBK"
				docencoding="GBK"
				destdir="${doc.dir}">
				<fileset dir="${src.dir}">
				</fileset>
		</javadoc>
	</target>
	
	<target name="copyfile">
		<copy todir="build1">
			<fileset dir=".">
				<include name="*.xml"/>
			</fileset>
		</copy>
	</target>
	
	<path id="project.class.path">
		<pathelement location="bin"/>
		<pathelement location="*.jar"/>
	</path>
	
	<!-- argument demo -->
	<target name="argDemo">
		<java fork="true" classname="hello.AntMain" failοnerrοr="true">
			<arg line="shi jie"/>
			<arg path="/temp;"/>
			<arg path="/temp"/>
			<arg value="-IN hello world -IN people -OUT outed"/>
			<classpath refid="project.class.path"/>
		</java>
	</target>
	
	<!-- environment demo -->
	<target name="envDemo" depends="checkHome">
		<property environment="env"/>
		<echo message="${env.MY_HOME}"/>
	</target>
	
	<target name="checkHome" unless="env.MY_HOME">
		<fail message="MY_HOME must be set!"/>
	</target>
	
	<!-- fileset demo -->
	<property name="build.dist" value="dist"/>
	<target name="filesetDemo">
		<delete dir="${build.dist}"/>
		<mkdir dir="${build.dist}"/>
		<copy todir="${build.dist}">
			<fileset dir=".">
				<patternset refid="pn2"/>
			</fileset>
		</copy>
	</target>
	<patternset id="pn2">
		<include name="*.xml"/>
	</patternset>
	
	<!-- patternset demo -->
	<property name="build.dir" value="build"/>
	<target name="prepare">
		<delete dir="${build.dir}"/>
		<mkdir dir="${build.dir}"/>
		<mkdir dir="${build.dir}/classes"/>
	</target>
	<target name="compile1" depends="prepare">
		<javac destdir="${build.dir}/classes">
			<src path="${src.dir}"/>
			<patternset refid="pnCom1"/>
		</javac>
	</target>
	<patternset id="pnCom1">
		<include name="**" unless="PG.java"/>
	</patternset>
	
	<!-- tokenFilter demo -->
	<target name="tokenFilterDemo">
		<tstamp>
			<format property="now" pattern="yyyy MM dd hh:mm:ss"/>
		</tstamp>
		<copy todir="${build.dir}" filtering="true">
			<fileset dir="${src.dir}">
				<include name="**/*.java"/>
			</fileset>
			<!-- search %BUILD_DATE! %COPYRIGHT! -->
			<filterset begintoken="%" endtoken="!">
				<filter token="BUILD_DATE" value="${now}"/>
				<filter token="COPYRIGHT" value="Copyright (C) 2002 O'Reilly"/>
			</filterset>
		</copy>
	</target>
	
	<!-- path demo -->
	<target name="pathDemo">
		<path id="clsPath">
			<fileset dir="${src.lib}" includes="*.jar"/>
		</path>
	</target>
	
	<!-- glob mapper demo -->
	<mapper id="backManager" type="glob" from="*.java" to="*.java.bkb"/>
	<mapper id="mpr1" type="identity"/>
	<mapper id="mpr2" type="flatten"/>
	<!-- 此时from属性被付略,将原文件名和to属性制定的相匹配 -->
	<mapper id="mpr3" type="merge" to="oreilly.zip"/>
	<target name="prepare1">
		<delete dir="${build.dir}/bkb"/>
		<mkdir dir="${build.dir}/bkb"/>
	</target>
	<target name="backupFiles" depends="prepare1">
		<copy todir="${build.dir}/bkb">
			<fileset dir="${src.dir}" includes="**/*.java"/>
			<mapper refid="mpr3"/>
		</copy>
	</target>
</project>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值