ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 54940] New: Target rewriting for nested "include" only works when "as" is specified?
Date Wed, 08 May 2013 15:13:36 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=54940

            Bug ID: 54940
           Summary: Target rewriting for nested "include" only works when
                    "as" is specified?
           Product: Ant
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core
          Assignee: notifications@ant.apache.org
          Reporter: cagney@fixmo.com
    Classification: Unclassified

I'm trying to reconcile these bits of the documentation with the tests I've
attached:

"Any target in the included file will be renamed to prefix.name where name is
the original target's name and prefix is either the value of the as attribute
or the name attribute of the project tag of the included file."

I'm assuming this means that:
  foo.xml:
    <project name="foo">...
  bar.xml:
    <include file="foo.xml"/>
and
  foo.xml:
    <project>...
  bar.xml:
    <include file="foo.xml" as="foo"/>
are equivalent.

And trying this for a simple include suggests my understanding is correct.

The documentation then goes on:

"The depends attribute of all included targets is rewritten so that all target
names are prefixed as well. This makes the included file self-contained.
Note that prefixes nest, so if a build file includes a file with prefix "a" and
the included file includes another file with prefix "b", then the targets of
that last build file will be prefixed by "a.b."."

Which I'm interpreting to mean that the above should still work when includes
are nested.  Unfortunately, I'm finding that I need to specify "as=" to make
things work.  For instance, the below which specifies "as=" on nested includes
...

w.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="w">
    <echo>${ant.file.w}</echo>
    <include file="x.xml"/>
    <target name="ww" depends="x.xx, x.y.yy, x.y.z.zz"/>
</project>

x.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="x">
    <echo>${ant.file.x}</echo>
    <include file="y.xml" as="y"/>
    <target name="xx" depends="y.yy, y.z.zz"/>
</project>

y.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="y">
    <echo>${ant.file.y}</echo>
    <include file="z.xml" as="z"/>
    <target name="yy" depends="z.zz"/>
</project>

z.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="z">
    <echo>${ant.file.z}</echo>
    <target name="zz"/>
</project>

... works as I would expect.  Both immediate (e.x.: "ww") and rewritten
included targets work (e.x.: x.y.z.zz) vis:

$ ant -f w.xml ww x.y.z.zz
Buildfile: /home/work/senv/Build/good/w.xml
     [echo] /home/work/senv/Build/good/w.xml
     [echo] /home/work/senv/Build/good/x.xml
     [echo] /home/work/senv/Build/good/y.xml
     [echo] /home/work/senv/Build/good/z.xml
x.y.z.zz:
x.y.yy:
x.xx:
ww:
x.y.z.zz:
BUILD SUCCESSFUL
Total time: 0 seconds

However, when I remove the "as=.." things break down.  For instance, removng
"as="y" from "x.xml"'s include of "y.xml", vis:

x.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="x">
    <echo>${ant.file.x}</echo>
    <include file="y.xml"/>
    <target name="xx" depends="y.yy, y.z.zz"/>
</project>

then I get the error:

$ ant -f w.xml ww
Buildfile: /home/work/senv/Build/good/w.xml
     [echo] /home/work/senv/Build/good/w.xml
     [echo] /home/work/senv/Build/good/x.xml
     [echo] /home/work/senv/Build/good/y.xml
     [echo] /home/work/senv/Build/good/z.xml
BUILD FAILED
Target "x.y.yy" does not exist in the project "w". It is used from target
"x.xx".

-- 
You are receiving this mail because:
You are the assignee for the bug.

Mime
View raw message