You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Matt Benson <gu...@yahoo.com> on 2006/08/31 16:39:02 UTC

copying references

DD, what was that task you had for doing something
with references at a different time than Ant normally
would?  Seems like it is attached to a BZ issue
someplace...  Do you know what I'm talking about?

All: shouldn't Ant have an e.g. <refcopy> task?

<refcopy refid="src" to="dest" />

Example, given the custom foo type:

<foo id="a" />
<foo id="b" refid="a" />

"b" != "a"; "b" is a distinct instance which by
convention has been programmed to delegate to "a".  If
"a" is subsequently redefined, "b" points to the NEW
"a".

Start over:

<foo id="a" />
<refcopy refid="a" to="b" />

Now, "b" == "a"; redefining "a" won't change that. 
This task seems useful, i.e. there's not AFAIK a way
to do this in Ant without Java or scripting.  It also
seems trivial to write.  Have I missed anything?

-Matt


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: copying references

Posted by Matt Benson <gu...@yahoo.com>.
--- Dominique Devienne <dd...@gmail.com> wrote:

> >  <!--
> >  Here you want to redefine "sel", incorporating
> its
> > current definition, whatever that may be.  How do
> you
> > do it?
> >  -->
> 
> I agree it's diserable, but it's indeed not
> currently possible to
> override a reference and at the same time reuse the
> previous
> definition, if any. You can do the override alone,
> albeit with a
> warning. This is hurting Ant's ability to define
> generic and reusable
> build files.
> 
> When I designed a generic build for my previous
> companie's projects, I
> really wished for the ability to use a <super>-like
> tag that 'inserts'
> the overriden target or id'd type.
> 
> > In the commented zone above, the following creates
> a
> > circular reference:
> >
> > <selector id="sel">
> >  <and>
> >    <selector refid="sel" />
> >    <contains text="foo" />
> >  </and>
> > </selector>
> 
> Yep, obviously.
> 
> > This doesn't yield the desired result either:
> >
> > <selector id="_sel">
> >  <and>
> >    <selector refid="sel" />
> >    <contains text="foo" />
> >  </and>
> > </selector>
> 
> Why doesn't this work? It should, no?
> Sure, having the use a new id is not great, but...
> 
> > <selector id="sel" refid="_sel" />
> 
> > You should still get a circular reference because
> of
> > the way references are resolved.
> 
> Yep, circular it is.
> 
> > The only way is:
> > <copyref refid="sel" to="a.sel" />
> > <!-- yes, I changed the name -->
> >
> > <selector id="sel">
> >  <and>
> >    <selector refid="a.sel" />
> >    <contains text="foo" />
> >  </and>
> > </selector>
> >
> > Is there another way, without code (I know, code
> is
> > not necessarily the most evil thing in the
> world...)?
> 
> Hmmm, I'm not fond of this notation. I see where you
> are going with
> this, and it would indeed solve the problem at hand,
> and even the
> problem generally, but it's still kinda ugly and
> hacky to me.
> 
> This all boils down to me to the lack of
> compartimentation of
> references in the context of import. We introduced
> compartimentation
> of target by allowing to reference them using the
> <project name>.<ref
> name> composed name, and allowing silent override of
> imported targets.
> 
> (FTR, I was against using <project name>. and would
> have preferred
> using a build-specific private name to refer to
> imported build file
> artifacts)
> 
> Having of compartimentation of references in the
> context of import
> would avoid the need of <refcopy> I think, as you
> could always refer
> to an imported reference thru its composed name, and
> override
> (hopefully silently) the non-composed name with the
> new definition.
> 
> Am I making sense? --DD

Yup.  It does indeed seem sensible to handle imported
refs like imported targets.  Probably a little more
complicated than the alternative though.  I wonder if
it's doable in the (tiny) 1.7 timeframe.

-Matt

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


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: copying references

Posted by Dominique Devienne <dd...@gmail.com>.
>  <!--
>  Here you want to redefine "sel", incorporating its
> current definition, whatever that may be.  How do you
> do it?
>  -->

I agree it's diserable, but it's indeed not currently possible to
override a reference and at the same time reuse the previous
definition, if any. You can do the override alone, albeit with a
warning. This is hurting Ant's ability to define generic and reusable
build files.

When I designed a generic build for my previous companie's projects, I
really wished for the ability to use a <super>-like tag that 'inserts'
the overriden target or id'd type.

> In the commented zone above, the following creates a
> circular reference:
>
> <selector id="sel">
>  <and>
>    <selector refid="sel" />
>    <contains text="foo" />
>  </and>
> </selector>

Yep, obviously.

> This doesn't yield the desired result either:
>
> <selector id="_sel">
>  <and>
>    <selector refid="sel" />
>    <contains text="foo" />
>  </and>
> </selector>

Why doesn't this work? It should, no?
Sure, having the use a new id is not great, but...

> <selector id="sel" refid="_sel" />

> You should still get a circular reference because of
> the way references are resolved.

Yep, circular it is.

> The only way is:
> <copyref refid="sel" to="a.sel" />
> <!-- yes, I changed the name -->
>
> <selector id="sel">
>  <and>
>    <selector refid="a.sel" />
>    <contains text="foo" />
>  </and>
> </selector>
>
> Is there another way, without code (I know, code is
> not necessarily the most evil thing in the world...)?

Hmmm, I'm not fond of this notation. I see where you are going with
this, and it would indeed solve the problem at hand, and even the
problem generally, but it's still kinda ugly and hacky to me.

This all boils down to me to the lack of compartimentation of
references in the context of import. We introduced compartimentation
of target by allowing to reference them using the <project name>.<ref
name> composed name, and allowing silent override of imported targets.

(FTR, I was against using <project name>. and would have preferred
using a build-specific private name to refer to imported build file
artifacts)

Having of compartimentation of references in the context of import
would avoid the need of <refcopy> I think, as you could always refer
to an imported reference thru its composed name, and override
(hopefully silently) the non-composed name with the new definition.

Am I making sense? --DD

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


Re: copying references

Posted by Matt Benson <gu...@yahoo.com>.
--- Dominique Devienne <dd...@gmail.com> wrote:

> On 8/31/06, Matt Benson <gu...@yahoo.com>
> wrote:
> > DD, what was that task you had for doing something
> > with references at a different time than Ant
> normally
> > would?  Seems like it is attached to a BZ issue
> > someplace...  Do you know what I'm talking about?
> 
> Yes, it's called <reference>, and is indeed attached
> somewhere in BZ.
> It postpones adding the reference to runtime instead
> of parse time.
> Additionally, the reference ID is not a string
> litteral, but a
> property-expanded string.
> 
> > All: shouldn't Ant have an e.g. <refcopy> task?
> 
> I'm not following at all this discussion of
> <refcopy> ;-)
> Would you have a more concrete use case? --DD

See
http://issues.apache.org/bugzilla/show_bug.cgi?id=27118
.  In an example here,

a.xml:
<project name="a">
  <selector id="sel">
    <filename name="**/*.txt" />
  </selector>
</project>

b.xml:
<project name="b">
  <import file="a.xml" />
  <!--
  Here you want to redefine "sel", incorporating its
current definition, whatever that may be.  How do you
do it?
  -->
</project>

In the commented zone above, the following creates a
circular reference:

<selector id="sel">
  <and>
    <selector refid="sel" />
    <contains text="foo" />
  </and>
</selector>

This doesn't yield the desired result either:

<selector id="_sel">
  <and>
    <selector refid="sel" />
    <contains text="foo" />
  </and>
</selector>

<selector id="sel" refid="_sel" />

You should still get a circular reference because of
the way references are resolved.  The only way is:

<copyref refid="sel" to="a.sel" />
<!-- yes, I changed the name -->

<selector id="sel">
  <and>
    <selector refid="a.sel" />
    <contains text="foo" />
  </and>
</selector>

Is there another way, without code (I know, code is
not necessarily the most evil thing in the world...)?

-Matt

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


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: copying references

Posted by Dominique Devienne <dd...@gmail.com>.
On 8/31/06, Matt Benson <gu...@yahoo.com> wrote:
> DD, what was that task you had for doing something
> with references at a different time than Ant normally
> would?  Seems like it is attached to a BZ issue
> someplace...  Do you know what I'm talking about?

Yes, it's called <reference>, and is indeed attached somewhere in BZ.
It postpones adding the reference to runtime instead of parse time.
Additionally, the reference ID is not a string litteral, but a
property-expanded string.

> All: shouldn't Ant have an e.g. <refcopy> task?

I'm not following at all this discussion of <refcopy> ;-)
Would you have a more concrete use case? --DD

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


Re: copying references

Posted by Matt Benson <gu...@yahoo.com>.
--- Stefan Bodewig <bo...@apache.org> wrote:

> On Thu, 31 Aug 2006, Matt Benson
> <gu...@yahoo.com> wrote:
> 
> > All: shouldn't Ant have an e.g. <refcopy> task?
> 
> We probably never felt the need for it, but why not.
>  I'm not sure
> about the name since copy implies cloning to me. 
> Something with
> "alias" in its name?

1) "alias" to me implies a relationship between the
_names_; which is what we have today with <foo id="x"
refid="y" />.  But if we decide to go this route, I'm
sure we can compromise semantically.

Do you (or anyone else) have an opinion on DD's
assertion that the concrete use-case (modifying
imported references) could be better solved by scoping
imported references as targets? [1]

-Matt

[1]
http://marc.theaimsgroup.com/?l=ant-dev&m=115703947632596&w=2

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



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: copying references

Posted by Stefan Bodewig <bo...@apache.org>.
On Thu, 31 Aug 2006, Matt Benson <gu...@yahoo.com> wrote:

> All: shouldn't Ant have an e.g. <refcopy> task?

We probably never felt the need for it, but why not.  I'm not sure
about the name since copy implies cloning to me.  Something with
"alias" in its name?

Stefan

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