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 Mon, 06 Dec 2004 02:20:01 GMT
At 11:32 AM 12/5/2004 -0800, you wrote:
 >On Sat, 04 Dec 2004 23:50:02 -0600, Jacob Kjome <hoju@visi.com> wrote:
 >>
 >> 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.
 >
 >Thanks, I did read the whole thread. What I really want is Dominique's
 ><super>, but it seems that that isn't going to happen. That's a shame,
 >since it just seems like such a clean solution to this issue.
 >

Yeah, it probably would have been.  Maybe it was too risky at the 
time?  Something for Ant-1.7?

 >The second link, above, looked viable until I read the comment from
 >Dominique on dependent targets. That scared me off, and Jan's solution
 >to that scared me off even more. If I added something like that to our
 >build system, I can pretty much guarantee that nobody else in the team
 >would have a clue what's going on.
 >

I added it to mine, actually, except I added if/unless and 
"followDependencies" parameters.  There are a very few times when I want to 
avoid following dependencies, so it is a nice option to have.  Otherwise, 
dependent targets are followed by default.  I never intentionally fail if 
the target I'm calling has dependencies.  I suppose I could make it an 
option, but certainly not a default one.

 >So, I guess I'm stuck with doing things the clunky way. Sigh.
 >

It works well for me and I don't think it the least bit confusing.  Suit 
yourself.

 >Thanks, anyway, for your help.
 >

No problem,

Jake

 >--
 >Martin Cooper
 >
 >
 >> 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
 >>
 >>
 >
 >---------------------------------------------------------------------
 >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