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

Ant Properties File Tutorial

    博客分类:
  • Ant
阅读更多

Ant > Ant Properties File

Ant Properties File

You can also group all the property values in a separate properties file and include it in the ant build file. Here the build.properties file contains all the property values. Remember the property value is immutable, so if you set a property value in the properties file you cannot change it in the build file. This give more control over the build process.

你可以集中所有的属性值到一个单独的属性文件中,用ant构建文件(build.xml)包含进来.这里的build.properties文件包含所有属性的值.记住属性的值是不可变得.所以如果你在属性文件中设定了值,那么你就不能在构建文件中更改它了.

The build.properties file.

web.lib.dir=${web.dir}/WEB-INF/lib
build.classes.dir=build/classes
dist.dir=dist
project.name=AntExample3

 Use the property task to include the properties file in the Ant build file.

用property task将这个属性文件包含到Ant构建文件中.

<property file="build.properties" />

 Here is the complete build file for your reference.

这里是是完整的构建文件(build.xml)供您参考.

<?xml version="1.0" ?>
<project name="AntExample3" default="war">
	<property file="build.properties" />
	<path id="compile.classpath">
		<fileset dir="${web.lib.dir}">
		<include name="*.jar"/>
		</fileset>
	</path>
	<target name="init" depends="clean">
		<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