`
shoppingbill
  • 浏览: 58314 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Ant Property Task Tutorial

    博客分类:
  • Ant
阅读更多

Ant > Ant Property Task

Ant Property Task

The <property> task is used to set the Ant properties. The property value is immutable, once the value is set you cannot change it. To set a property to a specific value you use Name/value assignment.

<property> task 是用来设置Ant属性的. 属性的值是不可变,当你第一次设定它的时候就不能再更改了。给属性设置一个特殊的值用Name/value赋值.

<property name="project.name" value="AntExample2" />
 

 

To set a property to a location you use Name/location assignment.

用Name/location赋值来设置一个属性.

<property name="web.dir" location="WebContent"/>
<property name="web.lib.dir" location="${web.dir}/WEB-INF/lib"/>
<property name="build.classes.dir" location="build/classes"/>
<property name="dist.dir" location="dist"/>
 

To use the properties surround them with ${}.

用属性是要用到${属性名称}

The following build file shows how to set and use property values.

下面是build文件怎样设置和用属性值.

<?xml version="1.0" ?>
<project name="AntExample2" default="war">
<property name="web.dir" location="WebContent"/>
<property name="web.lib.dir" location="${web.dir}/WEB-INF/lib"/>
<property name="build.classes.dir" location="build/classes"/>
<property name="dist.dir" location="dist"/>
<property name="project.name" value="AntExample2" />
<path id="compile.classpath">
       <fileset dir="${web.lib.dir}">
                    <include name="*.jar"/>
       </fileset>
</path>
<target name="init">
         <mkdir dir="${build.classes.dir}"/>
         <mkdir dir="${dist.dir}" />
</target>
<target name="compile" depends="init" >
        <javac destdir="${build.classes.dir}" debug="true" srcdir="src">
                <classpath refid="compile.classpath"/>
        </javac>
</target>
<target name="war" depends="compile">
      <war destfile="${dist.dir}/${project.name}.war"webxml="${web.dir}/WEB-INF/web.xml">
                <fileset dir="${web.dir}"/>
                <lib dir="${web.lib.dir}"/>
                <classes dir="${build.classes.dir}"/>
       </war>
</target> 
<target name="clean">
             <delete dir="${dist.dir}" />
             <delete dir="${build.classes.dir}" />
</target>
</project>
 

 

You can download the build file here.

Build file :Download
Project :Download

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics