Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Ant problem with property substitutions.

Reply
Thread Tools

Ant problem with property substitutions.

 
 
RJGraham
Guest
Posts: n/a
 
      06-28-2004
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>



 
Reply With Quote
 
 
 
 
Tony Morris
Guest
Posts: n/a
 
      06-28-2004
$(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:(E-Mail Removed)...
> 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>
>
>
>



 
Reply With Quote
 
 
 
 
RJGraham
Guest
Posts: n/a
 
      06-28-2004
Thanks, but I don't understand....

-Randy

"Tony Morris" <(E-Mail Removed)> wrote in message
news:cbnq31$tgq$(E-Mail Removed)...
> $(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:(E-Mail Removed)...
> > 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>
> >
> >
> >

>
>



 
Reply With Quote
 
Tony Morris
Guest
Posts: n/a
 
      06-28-2004
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:(E-Mail Removed)...
> Thanks, but I don't understand....
>
> -Randy
>
> "Tony Morris" <(E-Mail Removed)> wrote in message
> news:cbnq31$tgq$(E-Mail Removed)...
> > $(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:(E-Mail Removed)...
> > > 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>
> > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Sudsy
Guest
Posts: n/a
 
      06-28-2004
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...

 
Reply With Quote
 
RJGraham
Guest
Posts: n/a
 
      06-28-2004
Aaaarrrghhh !!!

Damn, what a stupid mistake !!!!

Thanks!

-Randy




"Sudsy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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...
>



 
Reply With Quote
 
RJGraham
Guest
Posts: n/a
 
      06-28-2004
Thanks,

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

-Randy


"Tony Morris" <(E-Mail Removed)> wrote in message
news:cbo1v5$gm0$(E-Mail Removed)...
> 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:(E-Mail Removed)...
> > Thanks, but I don't understand....
> >
> > -Randy
> >
> > "Tony Morris" <(E-Mail Removed)> wrote in message
> > news:cbnq31$tgq$(E-Mail Removed)...
> > > $(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:(E-Mail Removed)...
> > > > 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>
> > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ant setting property by regexp substitution on an existing property kevin cline Java 2 07-26-2008 02:21 PM
Run ant script from ant script? lionelv@gmail.com Java 6 07-26-2007 02:12 AM
error runing ant in eclipse ant view yihucd@gmail.com Java 1 03-07-2006 08:39 PM
trouble with Hibernate and Ant (probably just Ant) john martin Java 2 04-07-2005 09:27 PM
wondering how i can launch tomcat from ant without ant hanging... Chris Bedford Java 6 12-23-2004 12:41 AM



Advertisments