O_O
O_O

Reputation: 4477

What does this ${..} do for variables in ant?

I'm trying to build an application in java and I am getting an error saying:

/home/user/Documents/Installation_Files/csa/build2/rtiperftest.1.1b/perftest_java/build.xml:97: Execute failed: java.io.IOException: Cannot run program "/home/user/Documents/Installation_Files/csa/build2/rtiperftest.1.1b/${env.NDDSHOME}/scripts/rtiddsgen" (in directory "/home/user/Documents/Installation_Files/csa/build2/rtiperftest.1.1b"): error=2, No such file or directory

Is env.NDDSHOME an environmental variable that needs to be set?

In the build.xml file, I also see ${rtidds.rtiddsgen}, ${rtidds.home}, ${script.suffix}, and others that have the syntax ${...}. What does this mean? Are these all defined in the environment variables?

Here is the build.xml file for reference:

<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: build.xml 2570 2009-05-28 14:42:37Z elaine $ Copyright 2006,
Real-Time Innovations. All rights reserved. No duplications, whole or
partial, manual or electronic, may be made without express written
permission. Any such copies, or revisions thereof, must display this
notice unaltered. This code contains trade secrets of Real-Time
Innovations, Inc. modification history:
=====================
17oct08,rbw Reorganized source files to make it easier to ship test
implementations separately 08oct08,rbw Refactored DDS dependencies to
com.rti.perftest.impl.PerfTestLauncher 20jun08,rbw javac path changes
23may08,rbw Enable preprocessor when running rtiddsgen to enable key
support 30apr08,rbw Fixed deletion order when cleaning 03apr08,rbw
Fail build when code gen fails 02apr08,rbw Created
========================================================================== -->
<project basedir=".." default="default" name="PerfTest">
  <!-- ===================================================================== -->
  <!-- End of $Id: build.xml 2570 2009-05-28 14:42:37Z elaine $ -->
  <description> A combined throughput and latency test for RTI Data Distribution Service in Java. </description>
  <!-- ================================================================= -->
  <!-- Public Targets -->
  <!-- ================================================================= -->
  <target name="default" description="Build a JAR file containing the test" depends="build-jar">
  </target>
  <target name="clean" description="Delete compiled code">
    <delete file="${jar.out.file}"/>
    <delete dir="${javac.out.dir}"/>
  </target>
  <!-- ================================================================= -->
  <!-- Internal Targets -->
  <!-- ================================================================= -->
  <target name="build-jar" depends="compile">
    <echo message="Building PerfTest JAR: ${jar.out.file}"/>
    <echo message="...containing classes: ${javac.out.dir}"/>
    <mkdir dir="${jar.out.dir}"/>
    <jar basedir="${javac.out.dir}" update="false" index="true" duplicate="fail" destfile="${jar.out.file}">
      <fileset dir="." includes="**/*.class"/>
      <manifest>
        <attribute name="Main-Class" value="com.rti.perftest.ddsimpl.PerfTestLauncher"/>
      </manifest>
    </jar>
  </target>
  <target name="compile" depends="generate">
    <echo message="Compiling PerfTest in dir: ${javac.out.dir}"/>
    <echo message="...using RTI DDS JAR file: ${rtidds.jar}"/>
    <mkdir dir="${javac.out.dir}"/>
    <javac target="1.5" optimize="${javac.optimize}" deprecation="${javac.deprecation}" debug="${javac.debug}" destdir="${javac.out.dir}" srcdir=".">
      <include name="perftest_java/**/*.java"/>
      <include name="perftest_java_util/**/*.java"/>
      <classpath>
        <pathelement path="${rtidds.jar}"/>
      </classpath>
    </javac>
  </target>
  <target name="generate" depends="properties">
    <echo message="Generating code with: ${rtidds.rtiddsgen} ${env.RTIDDSGEN_PREPROCESSOR} "/>
    <exec failonerror="true" failifexecutionfails="true" executable="${rtidds.rtiddsgen}">
      <arg line="-d perftest_java"/>
      <arg line="-language Java"/>
      <arg line="-package com.rti.perftest.gen"/>
      <arg line="-replace"/>
      <arg line="${env.RTIDDSGEN_PREPROCESSOR}"/>
      <arg file="idl/test.idl"/>
    </exec>
  </target>
  <target name="properties">
    <property environment="env"/>
    <property name="rtidds.home" location="${env.NDDSHOME}"/>
    <property name="rtidds.jar" location="${rtidds.home}/class/nddsjava.jar"/>
    <property name="env.RTIDDSGEN_PREPROCESSOR" value=""/>
    <condition value=".bat" else="" property="script.suffix">
      <os family="Windows"/>
    </condition>
    <property name="rtidds.rtiddsgen" location="${rtidds.home}/scripts/rtiddsgen${script.suffix}"/>
  </target>
</project>

Upvotes: 2

Views: 1035

Answers (1)

kjhughes
kjhughes

Reputation: 111521

In ant, ${property_name} evaluates to the value bound to the property named property_name.

The <property environment="env"/> statement means to bind environment values to env.. Other ${ } constructs without the env. prefix refer to other, non-environment properties, commonly set within the build file or in an external properties file.

So, your error message indicates a problem with the setting of the NDDSHOME environment variable. ${env.NDDSHOME} is used to set rtidds.home, which is used to specify the location of the rtidds.jarand also plays a part in specifying rtidds.rtiddsgen to ${rtidds.home}/scripts/rtiddsgen${script.suffix}. The script presumably expects you to set this correctly for your local installation.

Upvotes: 2

Related Questions