Properties based on build.properties file : Properties « Ant « Java Tutorial






<?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}








38.3.Properties
38.3.1.Built in properties
38.3.2.Define custom properties based on the existing properties
38.3.3.Reference defined properties
38.3.4.environment properties
38.3.5.Properties based on build.properties file