ant notes

<!-- print classpath -->
<path id="somePathId">
    <pathelement path="someDir"/>
</path>
<property name="debug.classpath" refid="somePathId"/>
<echo message="Classpath = ${debug.classpath}"/>

 

<!-- modify path -->
<path id="p1">
    <fileset dir="lib">
        <include name="**/*.jar"/>
    </fileset>
</path>

<path id="p2">
    <path refid="p1"/>
    <fileset dir="src">
        <include name="**/*.java"/>
    </fileset>
</path>
 
<!-- exec -->
<target name="setenv">
<!-- need to specify the absolute path here, or will meet "Cannot run program" exception -->
    <exec executable="${current.dir}\setenv.cmd">
	<arg value="${pattern.type}"/>
    </exec>
</target>

 

<!--propertyregex -->

<!--1. substring from input, result is "Test_Sample.ear" -->
<propertyregex override="yes" property="server.name" input="WLS_Test_Sample.ear" regexp="(.*?)_(.*)" select="\2"/>

<!-- 2. find and replace, result is "root:[email protected]"-->
<propertyregex property="${svr1}" input="root:[email protected]" regexp='password' replace="pwd"/>

 

<!-- macrodef   -->
<macrodef name="patternType">
	<attribute name="name"/>
		<attribute name="version"/>
		<sequential>
			<var name="@{name}" value="weblogic"/>
			<if>
				<matches pattern="^[0-5]\.(.*)" string="@{version}"/>
				<then>
					<var name="@{name}" value="oc4j"/>
				</then>
			</if>
	</sequential>
</macrodef>

<!-- invoking, ${result} is "oc4j" -->
<patternType name="result" version="5.1"/>

 

<!-- Get the path of the current ant file: this is very useful if the current file is imported by other ant files, but the current file needs to load other files, if the relative path is used here, the file to be loaded will often not be found -->
<project name="IMPORTED">  
  <dirname property="IMPORTED.basedir" file="${ant.file.IMPORTED}" />  
  <property name="myresource" location="${IMPORTED.basedir}/some_resource_file"/>  
</project>

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327063559&siteId=291194637
ANT
ANT