ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject Re: Properties getting unset with <import>?
Date Sun, 05 Dec 2004 05:50:02 GMT

I disagree with your statement that <import> is almost no better than 
entity includes if you can't get the exact functionality you are looking 
for here.  However, I do see the general utility in what you are 
describing.  Luckily, there is a way to get what you want using <scriptdef>...

http://marc.theaimsgroup.com/?t=107585688000004&r=1&w=2

This one shows a quick and simple example of what you want...
http://marc.theaimsgroup.com/?l=ant-user&m=107589782422983&w=2

However, you should read the whole thread.  Lots of good stuff there.


Jake

At 08:05 PM 12/4/2004 -0800, you wrote:
 >
 >
 >On Sat, 4 Dec 2004, Jacob Kjome wrote:
 >
 >>
 >> You should have expected this because you are using <antcall>.  It 
creates a
 >> new Ant project which is discarded after the call returns.  I think 
what you
 >> meant to do is...
 >
 >No, actually I specifically didn't want to do that. I wanted to do what
 >the documentation for <import> says I should be able to do: "This enables
 >the new implementation to call the old target, thus enhancing it with
 >tasks called before or after it". If <antcall> won't work, then how do I
 >achieve the "tasks called before" part of this?
 >
 >What I wanted to do was:
 >
 ><target name="init">
 >   <!-- Do before-init stuff -->
 >   <!-- Invoke imported.init -->
 >   <!-- Do after-init stuff -->
 ></target>
 >
 >If I can't do that, this seems to me to considerably lessen the value of
 ><import> over just a plain entity include.
 >
 >The only way I can think of now is to define more targets:
 >
 ><target name="before-init">
 >   ...
 ></target>
 >
 ><target name="init" depends="before-init,imported.init">
 >   <!-- Do after-init stuff here -->
 ></target>
 >
 >This will result in a bunch of otherwise unnecessary targets cluttering
 >up my build file, just to get stuff done before the target I'm trying to
 >override.
 >
 >Is there a better way?
 >
 >TIA.
 >
 >--
 >Martin Cooper
 >
 >
 >> <project name="importer" basedir=".">
 >>  <import file="imported.xml"/>
 >>  <target name="init" depends="imported.init"/>
 >> </project>
 >>
 >> That should work as expected.
 >>
 >> Jake
 >>
 >> At 11:39 AM 12/4/2004 -0800, you wrote:
 >>> This is weird. I'm using Ant 1.6.2, and trying to use <import> with
 >>> selective overriding of targets. The problem is that when I invoke an
 >>> imported target from its override, any properties set in that target
 >>> appear to be "forgotten" later on. An example will make this clear, I
 >>> hope.
 >>>
 >>> <project name="imported" basedir=".">
 >>>   <target name="init">
 >>>     <property name="foo" value="foo-value"/>
 >>>     <echo message="foo is set"/>
 >>>   </target>
 >>>   <target name="show" depends="init">
 >>>     <echo message="foo = ${foo}"/>
 >>>   </target>
 >>> </project>
 >>>
 >>> <project name="importer" basedir=".">
 >>>   <import file="imported.xml"/>
 >>>   <target name="init">
 >>>       <antcall target="imported.init"/>
 >>>   </target>
 >>> </project>
 >>>
 >>> Now if I do:
 >>>
 >>> ant -f importer.xml show
 >>>
 >>> I get:
 >>>
 >>> init:
 >>>
 >>> imported.init:
 >>>      [echo] foo is set
 >>>
 >>> show:
 >>>      [echo] foo = ${foo}
 >>>
 >>> The property has been forgotten? This is clearly not what I would expect!
 >>>
 >>> Now, if I remove the overridden 'init' target, I get:
 >>>
 >>> init:
 >>>      [echo] foo is set
 >>>
 >>> show:
 >>>      [echo] foo = foo-value
 >>>
 >>> which is what I expect.
 >>>
 >>> Is this a known bug? Or is there something I'm doing wrong? If it's a bug,
 >>> is there a workaround? I can't really do much with <import> when my
 >>> properties get forgotten. ;-}
 >>>
 >>> TIA.
 >>>
 >>> --
 >>> Martin Cooper
 >>>
 >>>
 >>> ---------------------------------------------------------------------
 >>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
 >>> For additional commands, e-mail: user-help@ant.apache.org
 >>>
 >>>
 >>
 >> ---------------------------------------------------------------------
 >> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
 >> For additional commands, e-mail: user-help@ant.apache.org
 >>
 >>
 >
 >---------------------------------------------------------------------
 >To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
 >For additional commands, e-mail: user-help@ant.apache.org
 >
 >  


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message