DPML
Project Properties Tutorial
HomeUtilitiesStationMetro
Declaring Properties

This tutorial demonstrates the addition of property declarations to our project definition.

index.xml

Any number of properties can be declared within an enclosing properties element. The properties element may be declared within a project defintion, a module defintion (more on that later), and/or within the index file. In the following example we are declaring a single property inside the project defintion which we will reference in our build file.

<?xml version="1.0" encoding="ISO-8859-1"?>
<index xmlns="dpml:library">

  <project name="demo" basedir=".">
    <properties>
      <property name="message" value="Hello"/>
    </properties>
  </project>

</index>
build.xml

The build file is updated to demonstrate a reference to our project defined property value in an echo statement.

<project name="demo" default="install">

  <target name="clean">
    <!-- nothing to do -->
  </target>

  <target name="build">
    <echo message="${message}"/>
  </target>

  <target name="install" depends="build"/>

</project>
Building the project ..
$ cd tutorials\tooling\properties
$ build

-------------------------------------------------------------------------
demo#SNAPSHOT
-------------------------------------------------------------------------

build:
     [echo] Hello

BUILD SUCCESSFUL
Total time: 0 seconds

$
        
Standard Properties

When Depot creates a new Ant project it automatically populates the project with a set of properties derived from the associated project model. These properties contain information about the project name, group, version, and default directory locations for src files, test source files, compiled classes, deliverables resulting from the build and the system wide cache location. If the project also declares one or more produced types - then a set of properties are made available that contain deliverable names and local directories together with the directories and full paths relative to the system cache. An example of the use of standard properties is included in the Type Production Tutorial build file.

Supplimentary Test Properties

Supplimentary property declarations used during testcase execution may be declared in a file name test.properties in the project base directory. Property values may include any of the following symbolic values (since 1.0.4):

  • any system property .. e.g. ${user.name}
  • any of the standard DPML environment properties .. e.g. ${dpml.prefs}
  • any property declared in the project definition e.g. ${project.name}
  • the testcase base directory ${project.test.basedir}
Summary

When Depot establishes the Ant project, it consults the Depot project defintion for all properties declared within the project and any enclosing scopes (e.g. module level properties and properties declared within the index itself). Properties declared within a project take precidence over properties declared at module scope which in turn take precidence over properties declared at index scope.

The following totorial updates the example to include symbolic references to system properties.