Java Tutorial/Ant/Properties — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 15:31, 31 мая 2010
Содержание
Built in properties
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<target name="properties.built-in">
<echo message="The base directory: ${basedir}"/>
<echo message="This file: ${ant.file}"/>
<echo message="Ant version: ${ant.version}"/>
<echo message="Project name: ${ant.project.name}"/>
<echo message="Java version: ${ant.java.version}"/>
</target>
</project>
Define custom properties based on the existing properties
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<target name="properties.custom">
<property name="fs" value="${file.separator}"/>
<property name="ps" value="${path.separator}"/>
<echo message="File: ${basedir}${fs}build.xml"/>
<echo message="Path: ${basedir}${fs}build.xml${ps}${basedir}${fs}build.properties"/>
</target>
</project>
environment properties
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<target name="properties">
<property environment="env"/>
<echo message="Built on: ${env.OS} ${env.PROCESSOR_ARCHITECTURE}"/>
<echo message="ANT_HOME: ${env.ant_home}"/>
</target>
</project>
Properties based on build.properties file
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<target name="properties">
<property file="build.properties"/>
<path id="build.classpath.id">
<pathelement path="${build.classpath}"/>
</path>
<property name="build.classpath.property" refid="build.classpath.id"/>
<echo message="Server URL: ${server.url}"/>
<echo message="Build classpath: ${build.classpath}"/>
<echo message="Build classpath converted: ${build.classpath.property}"/>
</target>
</project>
File: build.properties
server.name=localhost
server.port=8080
server.scheme=http
server.manager.name=manager
server.url=${server.scheme}://${server.name}:${server.port}/${server.manager.name}/
j2ee.home=C:/j2ee
catalina.home=C:/jakarta-tomcat
j2ee.jar=${j2ee.home}/lib/j2ee.jar
jsp.jar=${catalina.home}/common/lib/jsp-api.jar
servlet.jar=${catalina.home}/common/lib/servlet-api.jar
mysql.jar=${catalina.home}/common/lib/mysql.jar
build.classpath=${mysql.jar};${j2ee.jar};${jsp.jar};${servlet.jar}
Reference defined properties
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<target name="properties.custom">
<property name="project.dtd" location="project.dtd"/>
<echo message="Location of project.dtd: ${project.dtd}"/>
</target>
</project>