You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Gopala Krishna <go...@applabs.com> on 2010/02/23 13:18:06 UTC

Nested import task problem / anttask problem

Hi,

 

I am trying to execute an ant target through program. I have used import
task and those are nested in each build file. This is working fine when
executed via command line and throwing error when I execute target-a using
ProjectHelper.

 

The below are my ant build files. Has anyone tried these kind of import
tasks. Please let me know where exactly I am going wrong with this.

 

a.xml:

======

<project name="project-a" basedir="." Default="target-b">

 <import file="b.xml"/>

  <target name="target-a">

    <echo file="/tmp/project-a.txt">This is target a</echo>

  </target>

</project>

 

b.xml:

======

<project name="project-b" basedir="." default="">

  <import file="c.xml"/>

    <target name="target-b">

            <echo file="/tmp/project-b.txt">This is target b</echo>

            <antcall target="_warnExists"/>

  </target>

  <target name="target-b1">

                        <antcall target="_warnExists"/>

  </target>

            <target name="_warnExists">

                        <echo>Appears to already exist</echo>

            </target>

</project>

 

c.xml:

======

<project name="project-c" basedir="." default="">

  <target name="target-c" depends=" target-b,target-a">

    <echo file="/tmp/project-c.txt">This is target c</echo>

  </target>

</project>

 

I am getting the error  ""C:\build\test\test\b.xml:5: The following error
occurred while executing this line:

Target "target-a" does not exist in the project "project-b". It is used from
target "target-c".""

 

Your help is more appreciate.

 

Thanks

Gopal

 

 

 


Re: Nested import task problem / anttask problem

Posted by Brian Repko <br...@fastmail.us>.
Gopal,

What do you mean by "execute target-a using ProjectHelper"?

I get "execute target-a using Launcher or Main" but not ProjectHelper.

Do you mean with a custom ProjectHelper?  That won't necessarily work,
as per the documentation for import (that the import functionality is
built into ProjectHelper2).

This works in Ant 1.8 (via command line) as you get the following steps:

target-a defined
import of b.xml
target-b defined
target-b1 defined
_warnExists defined
import of c.xml
target-c defined (and target-b and target-a both are there)

Brian

----- Original message -----
From: "Gopala Krishna" <go...@applabs.com>
To: user@ant.apache.org
Date: Tue, 23 Feb 2010 17:48:06 +0530
Subject: Nested import task problem / anttask problem

Hi,

 

I am trying to execute an ant target through program. I have used import
task and those are nested in each build file. This is working fine when
executed via command line and throwing error when I execute target-a using
ProjectHelper.

 

The below are my ant build files. Has anyone tried these kind of import
tasks. Please let me know where exactly I am going wrong with this.

 

a.xml:

======

<project name="project-a" basedir="." Default="target-b">

 <import file="b.xml"/>

  <target name="target-a">

    <echo file="/tmp/project-a.txt">This is target a</echo>

  </target>

</project>

 

b.xml:

======

<project name="project-b" basedir="." default="">

  <import file="c.xml"/>

    <target name="target-b">

            <echo file="/tmp/project-b.txt">This is target b</echo>

            <antcall target="_warnExists"/>

  </target>

  <target name="target-b1">

                        <antcall target="_warnExists"/>

  </target>

            <target name="_warnExists">

                        <echo>Appears to already exist</echo>

            </target>

</project>

 

c.xml:

======

<project name="project-c" basedir="." default="">

  <target name="target-c" depends=" target-b,target-a">

    <echo file="/tmp/project-c.txt">This is target c</echo>

  </target>

</project>

 

I am getting the error  ""C:\build\test\test\b.xml:5: The following error
occurred while executing this line:

Target "target-a" does not exist in the project "project-b". It is used from
target "target-c".""

 

Your help is more appreciate.

 

Thanks

Gopal

 

 

 



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


Re: AW: Nested import task problem / anttask problem

Posted by Brian Repko <br...@fastmail.us>.
Just want to correct this...

The execution of Ant is always

1. parse
2. execute-implicit-targets (which includes the include/import)

When the import target is executed, it uses the same ProjectHelper
but not the same Handlers.  And the Project information is the same.
It calls parse on that handler, which increases the import stack.

Not sure how import and ProjectHelper for a specific build file
would work - that sounds ugly - but the documentation states that
import/include will only work with ProjectHelper2 so that's fine.

These files work (via command line) with Ant 1.8.

Brian

----- Original message -----
From: "Brian Repko" <br...@fastmail.us>
To: "Ant Users List" <us...@ant.apache.org>
Date: Tue, 23 Feb 2010 07:03:11 -0600
Subject: Re: AW: Nested import task problem / anttask problem


I'm in the process of fixing a similar bug related to imports
and extensionOf/extension-point.

The import mechanism creates a ProjectHelper for each import
and the ProjectHelper holds the list of targets so that the
design of Ant import looks to be that you can only depend on
targets "below" you and not in the importing xml.

I'm not sure if that is the intended design of import or if
that is considered a bug...I'm going to look at 1.7.1 and 
see how import worked there.  It might be a few days to get
back to this but just wanted to communicate that...

Brian


----- Original message -----
From: Jan.Materne@rzf.fin-nrw.de
To: user@ant.apache.org
Date: Tue, 23 Feb 2010 13:53:40 +0100
Subject: AW: Nested import task problem / anttask problem

Not sure about the <project default=""> in b.xml ...


Jan 

>-----Ursprüngliche Nachricht-----
>Von: Gopala Krishna [mailto:gopalakrishna.taninki@applabs.com] 
>Gesendet: Dienstag, 23. Februar 2010 13:18
>An: user@ant.apache.org
>Betreff: Nested import task problem / anttask problem
>
>Hi,
>
> 
>
>I am trying to execute an ant target through program. I have 
>used import task and those are nested in each build file. This 
>is working fine when executed via command line and throwing 
>error when I execute target-a using ProjectHelper.
>
> 
>
>The below are my ant build files. Has anyone tried these kind 
>of import tasks. Please let me know where exactly I am going 
>wrong with this.
>
> 
>
>a.xml:
>
>======
>
><project name="project-a" basedir="." Default="target-b">
>
> <import file="b.xml"/>
>
>  <target name="target-a">
>
>    <echo file="/tmp/project-a.txt">This is target a</echo>
>
>  </target>
>
></project>
>
> 
>
>b.xml:
>
>======
>
><project name="project-b" basedir="." default="">
>
>  <import file="c.xml"/>
>
>    <target name="target-b">
>
>            <echo file="/tmp/project-b.txt">This is target b</echo>
>
>            <antcall target="_warnExists"/>
>
>  </target>
>
>  <target name="target-b1">
>
>                        <antcall target="_warnExists"/>
>
>  </target>
>
>            <target name="_warnExists">
>
>                        <echo>Appears to already exist</echo>
>
>            </target>
>
></project>
>
> 
>
>c.xml:
>
>======
>
><project name="project-c" basedir="." default="">
>
>  <target name="target-c" depends=" target-b,target-a">
>
>    <echo file="/tmp/project-c.txt">This is target c</echo>
>
>  </target>
>
></project>
>
> 
>
>I am getting the error  ""C:\build\test\test\b.xml:5: The 
>following error occurred while executing this line:
>
>Target "target-a" does not exist in the project "project-b". 
>It is used from target "target-c".""
>
> 
>
>Your help is more appreciate.
>
> 
>
>Thanks
>
>Gopal
>
> 
>
> 
>
> 
>
>

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


Re: AW: Nested import task problem / anttask problem

Posted by Brian Repko <br...@fastmail.us>.
I'm in the process of fixing a similar bug related to imports
and extensionOf/extension-point.

The import mechanism creates a ProjectHelper for each import
and the ProjectHelper holds the list of targets so that the
design of Ant import looks to be that you can only depend on
targets "below" you and not in the importing xml.

I'm not sure if that is the intended design of import or if
that is considered a bug...I'm going to look at 1.7.1 and 
see how import worked there.  It might be a few days to get
back to this but just wanted to communicate that...

Brian


----- Original message -----
From: Jan.Materne@rzf.fin-nrw.de
To: user@ant.apache.org
Date: Tue, 23 Feb 2010 13:53:40 +0100
Subject: AW: Nested import task problem / anttask problem

Not sure about the <project default=""> in b.xml ...


Jan 

>-----Ursprüngliche Nachricht-----
>Von: Gopala Krishna [mailto:gopalakrishna.taninki@applabs.com] 
>Gesendet: Dienstag, 23. Februar 2010 13:18
>An: user@ant.apache.org
>Betreff: Nested import task problem / anttask problem
>
>Hi,
>
> 
>
>I am trying to execute an ant target through program. I have 
>used import task and those are nested in each build file. This 
>is working fine when executed via command line and throwing 
>error when I execute target-a using ProjectHelper.
>
> 
>
>The below are my ant build files. Has anyone tried these kind 
>of import tasks. Please let me know where exactly I am going 
>wrong with this.
>
> 
>
>a.xml:
>
>======
>
><project name="project-a" basedir="." Default="target-b">
>
> <import file="b.xml"/>
>
>  <target name="target-a">
>
>    <echo file="/tmp/project-a.txt">This is target a</echo>
>
>  </target>
>
></project>
>
> 
>
>b.xml:
>
>======
>
><project name="project-b" basedir="." default="">
>
>  <import file="c.xml"/>
>
>    <target name="target-b">
>
>            <echo file="/tmp/project-b.txt">This is target b</echo>
>
>            <antcall target="_warnExists"/>
>
>  </target>
>
>  <target name="target-b1">
>
>                        <antcall target="_warnExists"/>
>
>  </target>
>
>            <target name="_warnExists">
>
>                        <echo>Appears to already exist</echo>
>
>            </target>
>
></project>
>
> 
>
>c.xml:
>
>======
>
><project name="project-c" basedir="." default="">
>
>  <target name="target-c" depends=" target-b,target-a">
>
>    <echo file="/tmp/project-c.txt">This is target c</echo>
>
>  </target>
>
></project>
>
> 
>
>I am getting the error  ""C:\build\test\test\b.xml:5: The 
>following error occurred while executing this line:
>
>Target "target-a" does not exist in the project "project-b". 
>It is used from target "target-c".""
>
> 
>
>Your help is more appreciate.
>
> 
>
>Thanks
>
>Gopal
>
> 
>
> 
>
> 
>
>

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


AW: Nested import task problem / anttask problem

Posted by Ja...@rzf.fin-nrw.de.
Not sure about the <project default=""> in b.xml ...


Jan 

>-----Ursprüngliche Nachricht-----
>Von: Gopala Krishna [mailto:gopalakrishna.taninki@applabs.com] 
>Gesendet: Dienstag, 23. Februar 2010 13:18
>An: user@ant.apache.org
>Betreff: Nested import task problem / anttask problem
>
>Hi,
>
> 
>
>I am trying to execute an ant target through program. I have 
>used import task and those are nested in each build file. This 
>is working fine when executed via command line and throwing 
>error when I execute target-a using ProjectHelper.
>
> 
>
>The below are my ant build files. Has anyone tried these kind 
>of import tasks. Please let me know where exactly I am going 
>wrong with this.
>
> 
>
>a.xml:
>
>======
>
><project name="project-a" basedir="." Default="target-b">
>
> <import file="b.xml"/>
>
>  <target name="target-a">
>
>    <echo file="/tmp/project-a.txt">This is target a</echo>
>
>  </target>
>
></project>
>
> 
>
>b.xml:
>
>======
>
><project name="project-b" basedir="." default="">
>
>  <import file="c.xml"/>
>
>    <target name="target-b">
>
>            <echo file="/tmp/project-b.txt">This is target b</echo>
>
>            <antcall target="_warnExists"/>
>
>  </target>
>
>  <target name="target-b1">
>
>                        <antcall target="_warnExists"/>
>
>  </target>
>
>            <target name="_warnExists">
>
>                        <echo>Appears to already exist</echo>
>
>            </target>
>
></project>
>
> 
>
>c.xml:
>
>======
>
><project name="project-c" basedir="." default="">
>
>  <target name="target-c" depends=" target-b,target-a">
>
>    <echo file="/tmp/project-c.txt">This is target c</echo>
>
>  </target>
>
></project>
>
> 
>
>I am getting the error  ""C:\build\test\test\b.xml:5: The 
>following error occurred while executing this line:
>
>Target "target-a" does not exist in the project "project-b". 
>It is used from target "target-c".""
>
> 
>
>Your help is more appreciate.
>
> 
>
>Thanks
>
>Gopal
>
> 
>
> 
>
> 
>
>

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