Ant problem with property substitutions.

Discussion in 'Java' started by RJGraham, Jun 28, 2004.

  1. RJGraham

    RJGraham Guest

    Hello,

    I have a few properties defined in my ant build file, but substitutions are
    not occurring on all tasks.

    For example, in the snippet below, my jar file gets named correctly with the
    build number property value added to my jar file name, e.g. 'camlet1.jar'
    for build.number = 1.
    The mkdir task also creates the proper directory (ie., 'dist' directory is
    created).

    But, the copy task creates a directory named '$deploy' instead of 'dist' as
    expected.
    The two replace tasks also insert '$(build.nember)' instead of the build
    number value.

    What am I doing wrong?
    I assume property substitutions should work with copy and replace.

    Thanks for any help.

    -Randy


    <property name="build" location="build/"/>

    <property name="dist" location="dist/"/>

    <property name="deploy" location="dist/"/>

    <target name="dist" depends="compile"

    description="generate the distribution" >

    <!-- Create the distribution directory -->

    <mkdir dir="${dist}"/>

    <jar jarfile="${dist}/camlet${build.number}.jar" basedir="${build}"

    manifest="deployed/MANIFEST.MF"/>

    <copy todir="$(deploy)/">

    <fileset dir="deployed">

    <exclude name="MANIFEST.MF"/>

    </fileset>

    </copy>

    <replace file="$(deploy)/camlet.html" token="camlet.jad"
    value="camlet$(build.number).jad"/>

    <replace file="$(deploy)/camlet.jad" token="camlet.jar"
    value="camlet$(build.number).jar"/>

    </target>
     
    RJGraham, Jun 28, 2004
    #1
    1. Advertising

  2. RJGraham

    Tony Morris Guest

    $(deploy)

    is not the same as

    ${deploy}

    Depending on what font you use, that should be obvious.
    If it isn't, open this message in a hex editor.

    --
    Tony Morris
    (BInfTech, Cert 3 I.T.)
    Software Engineer
    (2003 VTR1000F)
    Sun Certified Programmer for the Java 2 Platform (1.4)
    Sun Certified Developer for the Java 2 Platform


    "RJGraham" <spamcop_764376_@surfbytes_123_._5637.com_4785> wrote in message
    news:...
    > Hello,
    >
    > I have a few properties defined in my ant build file, but substitutions

    are
    > not occurring on all tasks.
    >
    > For example, in the snippet below, my jar file gets named correctly with

    the
    > build number property value added to my jar file name, e.g. 'camlet1.jar'
    > for build.number = 1.
    > The mkdir task also creates the proper directory (ie., 'dist' directory is
    > created).
    >
    > But, the copy task creates a directory named '$deploy' instead of 'dist'

    as
    > expected.
    > The two replace tasks also insert '$(build.nember)' instead of the build
    > number value.
    >
    > What am I doing wrong?
    > I assume property substitutions should work with copy and replace.
    >
    > Thanks for any help.
    >
    > -Randy
    >
    >
    > <property name="build" location="build/"/>
    >
    > <property name="dist" location="dist/"/>
    >
    > <property name="deploy" location="dist/"/>
    >
    > <target name="dist" depends="compile"
    >
    > description="generate the distribution" >
    >
    > <!-- Create the distribution directory -->
    >
    > <mkdir dir="${dist}"/>
    >
    > <jar jarfile="${dist}/camlet${build.number}.jar" basedir="${build}"
    >
    > manifest="deployed/MANIFEST.MF"/>
    >
    > <copy todir="$(deploy)/">
    >
    > <fileset dir="deployed">
    >
    > <exclude name="MANIFEST.MF"/>
    >
    > </fileset>
    >
    > </copy>
    >
    > <replace file="$(deploy)/camlet.html" token="camlet.jad"
    > value="camlet$(build.number).jad"/>
    >
    > <replace file="$(deploy)/camlet.jad" token="camlet.jar"
    > value="camlet$(build.number).jar"/>
    >
    > </target>
    >
    >
    >
     
    Tony Morris, Jun 28, 2004
    #2
    1. Advertising

  3. RJGraham

    RJGraham Guest

    Thanks, but I don't understand....

    -Randy

    "Tony Morris" <> wrote in message
    news:cbnq31$tgq$...
    > $(deploy)
    >
    > is not the same as
    >
    > ${deploy}
    >
    > Depending on what font you use, that should be obvious.
    > If it isn't, open this message in a hex editor.
    >
    > --
    > Tony Morris
    > (BInfTech, Cert 3 I.T.)
    > Software Engineer
    > (2003 VTR1000F)
    > Sun Certified Programmer for the Java 2 Platform (1.4)
    > Sun Certified Developer for the Java 2 Platform
    >
    >
    > "RJGraham" <spamcop_764376_@surfbytes_123_._5637.com_4785> wrote in

    message
    > news:...
    > > Hello,
    > >
    > > I have a few properties defined in my ant build file, but substitutions

    > are
    > > not occurring on all tasks.
    > >
    > > For example, in the snippet below, my jar file gets named correctly with

    > the
    > > build number property value added to my jar file name, e.g.

    'camlet1.jar'
    > > for build.number = 1.
    > > The mkdir task also creates the proper directory (ie., 'dist' directory

    is
    > > created).
    > >
    > > But, the copy task creates a directory named '$deploy' instead of 'dist'

    > as
    > > expected.
    > > The two replace tasks also insert '$(build.nember)' instead of the build
    > > number value.
    > >
    > > What am I doing wrong?
    > > I assume property substitutions should work with copy and replace.
    > >
    > > Thanks for any help.
    > >
    > > -Randy
    > >
    > >
    > > <property name="build" location="build/"/>
    > >
    > > <property name="dist" location="dist/"/>
    > >
    > > <property name="deploy" location="dist/"/>
    > >
    > > <target name="dist" depends="compile"
    > >
    > > description="generate the distribution" >
    > >
    > > <!-- Create the distribution directory -->
    > >
    > > <mkdir dir="${dist}"/>
    > >
    > > <jar jarfile="${dist}/camlet${build.number}.jar" basedir="${build}"
    > >
    > > manifest="deployed/MANIFEST.MF"/>
    > >
    > > <copy todir="$(deploy)/">
    > >
    > > <fileset dir="deployed">
    > >
    > > <exclude name="MANIFEST.MF"/>
    > >
    > > </fileset>
    > >
    > > </copy>
    > >
    > > <replace file="$(deploy)/camlet.html" token="camlet.jad"
    > > value="camlet$(build.number).jad"/>
    > >
    > > <replace file="$(deploy)/camlet.jad" token="camlet.jar"
    > > value="camlet$(build.number).jar"/>
    > >
    > > </target>
    > >
    > >
    > >

    >
    >
     
    RJGraham, Jun 28, 2004
    #3
  4. RJGraham

    Tony Morris Guest

    Try this:

    class X
    {
    public static void main(String[] args)
    {
    System.out.println('(' == '{');
    System.out.println(')' == '}');
    }
    }

    If you copy/paste it correctly and run it, you should see:
    false
    false

    I don't know how else to explain it.
    "$(deploy)".equals("${deploy}")
    will return false.

    --
    Tony Morris
    (BInfTech, Cert 3 I.T.)
    Software Engineer
    (2003 VTR1000F)
    Sun Certified Programmer for the Java 2 Platform (1.4)
    Sun Certified Developer for the Java 2 Platform


    "RJGraham" <spamcop_764376_@surfbytes_123_._5637.com_4785> wrote in message
    news:...
    > Thanks, but I don't understand....
    >
    > -Randy
    >
    > "Tony Morris" <> wrote in message
    > news:cbnq31$tgq$...
    > > $(deploy)
    > >
    > > is not the same as
    > >
    > > ${deploy}
    > >
    > > Depending on what font you use, that should be obvious.
    > > If it isn't, open this message in a hex editor.
    > >
    > > --
    > > Tony Morris
    > > (BInfTech, Cert 3 I.T.)
    > > Software Engineer
    > > (2003 VTR1000F)
    > > Sun Certified Programmer for the Java 2 Platform (1.4)
    > > Sun Certified Developer for the Java 2 Platform
    > >
    > >
    > > "RJGraham" <spamcop_764376_@surfbytes_123_._5637.com_4785> wrote in

    > message
    > > news:...
    > > > Hello,
    > > >
    > > > I have a few properties defined in my ant build file, but

    substitutions
    > > are
    > > > not occurring on all tasks.
    > > >
    > > > For example, in the snippet below, my jar file gets named correctly

    with
    > > the
    > > > build number property value added to my jar file name, e.g.

    > 'camlet1.jar'
    > > > for build.number = 1.
    > > > The mkdir task also creates the proper directory (ie., 'dist'

    directory
    > is
    > > > created).
    > > >
    > > > But, the copy task creates a directory named '$deploy' instead of

    'dist'
    > > as
    > > > expected.
    > > > The two replace tasks also insert '$(build.nember)' instead of the

    build
    > > > number value.
    > > >
    > > > What am I doing wrong?
    > > > I assume property substitutions should work with copy and replace.
    > > >
    > > > Thanks for any help.
    > > >
    > > > -Randy
    > > >
    > > >
    > > > <property name="build" location="build/"/>
    > > >
    > > > <property name="dist" location="dist/"/>
    > > >
    > > > <property name="deploy" location="dist/"/>
    > > >
    > > > <target name="dist" depends="compile"
    > > >
    > > > description="generate the distribution" >
    > > >
    > > > <!-- Create the distribution directory -->
    > > >
    > > > <mkdir dir="${dist}"/>
    > > >
    > > > <jar jarfile="${dist}/camlet${build.number}.jar" basedir="${build}"
    > > >
    > > > manifest="deployed/MANIFEST.MF"/>
    > > >
    > > > <copy todir="$(deploy)/">
    > > >
    > > > <fileset dir="deployed">
    > > >
    > > > <exclude name="MANIFEST.MF"/>
    > > >
    > > > </fileset>
    > > >
    > > > </copy>
    > > >
    > > > <replace file="$(deploy)/camlet.html" token="camlet.jad"
    > > > value="camlet$(build.number).jad"/>
    > > >
    > > > <replace file="$(deploy)/camlet.jad" token="camlet.jar"
    > > > value="camlet$(build.number).jar"/>
    > > >
    > > > </target>
    > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Tony Morris, Jun 28, 2004
    #4
  5. RJGraham

    Sudsy Guest

    RJGraham wrote:
    > Thanks, but I don't understand....
    >
    > -Randy


    Tony gave you exactly the information you require, namely that
    you are apparently trying to use regular brackets () instead of
    the curly braces {} required.
    Instead of
    $(build.nember)
    (sic), you should be usiung
    ${build.nember}
    But if build.nember should actually be build.member then you've
    already located your mistake...
     
    Sudsy, Jun 28, 2004
    #5
  6. RJGraham

    RJGraham Guest

    Aaaarrrghhh !!!

    Damn, what a stupid mistake !!!!

    Thanks!

    -Randy




    "Sudsy" <> wrote in message
    news:...
    > RJGraham wrote:
    > > Thanks, but I don't understand....
    > >
    > > -Randy

    >
    > Tony gave you exactly the information you require, namely that
    > you are apparently trying to use regular brackets () instead of
    > the curly braces {} required.
    > Instead of
    > $(build.nember)
    > (sic), you should be usiung
    > ${build.nember}
    > But if build.nember should actually be build.member then you've
    > already located your mistake...
    >
     
    RJGraham, Jun 28, 2004
    #6
  7. RJGraham

    RJGraham Guest

    Thanks,

    That'll learn me for using tiny fonts with eclipse ;)
    (and my mail reader).

    -Randy


    "Tony Morris" <> wrote in message
    news:cbo1v5$gm0$...
    > Try this:
    >
    > class X
    > {
    > public static void main(String[] args)
    > {
    > System.out.println('(' == '{');
    > System.out.println(')' == '}');
    > }
    > }
    >
    > If you copy/paste it correctly and run it, you should see:
    > false
    > false
    >
    > I don't know how else to explain it.
    > "$(deploy)".equals("${deploy}")
    > will return false.
    >
    > --
    > Tony Morris
    > (BInfTech, Cert 3 I.T.)
    > Software Engineer
    > (2003 VTR1000F)
    > Sun Certified Programmer for the Java 2 Platform (1.4)
    > Sun Certified Developer for the Java 2 Platform
    >
    >
    > "RJGraham" <spamcop_764376_@surfbytes_123_._5637.com_4785> wrote in

    message
    > news:...
    > > Thanks, but I don't understand....
    > >
    > > -Randy
    > >
    > > "Tony Morris" <> wrote in message
    > > news:cbnq31$tgq$...
    > > > $(deploy)
    > > >
    > > > is not the same as
    > > >
    > > > ${deploy}
    > > >
    > > > Depending on what font you use, that should be obvious.
    > > > If it isn't, open this message in a hex editor.
    > > >
    > > > --
    > > > Tony Morris
    > > > (BInfTech, Cert 3 I.T.)
    > > > Software Engineer
    > > > (2003 VTR1000F)
    > > > Sun Certified Programmer for the Java 2 Platform (1.4)
    > > > Sun Certified Developer for the Java 2 Platform
    > > >
    > > >
    > > > "RJGraham" <spamcop_764376_@surfbytes_123_._5637.com_4785> wrote in

    > > message
    > > > news:...
    > > > > Hello,
    > > > >
    > > > > I have a few properties defined in my ant build file, but

    > substitutions
    > > > are
    > > > > not occurring on all tasks.
    > > > >
    > > > > For example, in the snippet below, my jar file gets named correctly

    > with
    > > > the
    > > > > build number property value added to my jar file name, e.g.

    > > 'camlet1.jar'
    > > > > for build.number = 1.
    > > > > The mkdir task also creates the proper directory (ie., 'dist'

    > directory
    > > is
    > > > > created).
    > > > >
    > > > > But, the copy task creates a directory named '$deploy' instead of

    > 'dist'
    > > > as
    > > > > expected.
    > > > > The two replace tasks also insert '$(build.nember)' instead of the

    > build
    > > > > number value.
    > > > >
    > > > > What am I doing wrong?
    > > > > I assume property substitutions should work with copy and replace.
    > > > >
    > > > > Thanks for any help.
    > > > >
    > > > > -Randy
    > > > >
    > > > >
    > > > > <property name="build" location="build/"/>
    > > > >
    > > > > <property name="dist" location="dist/"/>
    > > > >
    > > > > <property name="deploy" location="dist/"/>
    > > > >
    > > > > <target name="dist" depends="compile"
    > > > >
    > > > > description="generate the distribution" >
    > > > >
    > > > > <!-- Create the distribution directory -->
    > > > >
    > > > > <mkdir dir="${dist}"/>
    > > > >
    > > > > <jar jarfile="${dist}/camlet${build.number}.jar" basedir="${build}"
    > > > >
    > > > > manifest="deployed/MANIFEST.MF"/>
    > > > >
    > > > > <copy todir="$(deploy)/">
    > > > >
    > > > > <fileset dir="deployed">
    > > > >
    > > > > <exclude name="MANIFEST.MF"/>
    > > > >
    > > > > </fileset>
    > > > >
    > > > > </copy>
    > > > >
    > > > > <replace file="$(deploy)/camlet.html" token="camlet.jad"
    > > > > value="camlet$(build.number).jad"/>
    > > > >
    > > > > <replace file="$(deploy)/camlet.jad" token="camlet.jar"
    > > > > value="camlet$(build.number).jar"/>
    > > > >
    > > > > </target>
    > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    RJGraham, Jun 28, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Goller
    Replies:
    4
    Views:
    386
    Jordan Stewart
    Mar 9, 2005
  2. Tony Eva
    Replies:
    1
    Views:
    497
    Jeff Epler
    Nov 9, 2003
  3. Vivien Mallet

    Backslash substitutions

    Vivien Mallet, Sep 29, 2004, in forum: Python
    Replies:
    1
    Views:
    318
    Peter Otten
    Sep 29, 2004
  4. rh0dium
    Replies:
    6
    Views:
    278
    Dennis Lee Bieber
    Aug 5, 2005
  5. kevin  cline
    Replies:
    2
    Views:
    2,442
    Gilbert Rebhan
    Jul 26, 2008
Loading...

Share This Page