ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Solonchuk <s...@ibis.ua>
Subject Re[2]: import question
Date Tue, 22 Feb 2005 09:34:28 GMT

> Andrew, from my not so extensive usage of <import> I
> know that targets in the importee overload targets in
> imported. It is like extending a class in Java and
> calling a method defined in the base class results in
> a call to a method in the child class. (The imported
> is like a base class and the importee is like a child
> class).

> You can however do what you want. You have to rewrite
> project name="imported-test" like this:
> <project name="imported-test" default="imported"
basedir=".">>
>  <target name="imported" depends="imported-test.test"
>>
>     <echo message="In imported target" />
>   </target>
>   <target name="test">
>      <echo message="target 'test' in imported-test
progect" />>
>   </target>
> </project>
Yes, I tried this and it's work, but if I want to use project
"imported-test" as standalone project it say
"Target `imported-test.test' does not exist in this project. It is
used from target `imported'." I think it's not good and maybe a bug.

And i dont want switch off target overriding, but I think if some
project has target depends on another target it must be from the same
project.

I have N small build files(projects) and one common. In common project
I call <ant buildfile="xxx" target="all">

in small projects i have target
 <target name="all" depends="target1,target2,target2"/>

and in describing by you behaviour of ANT I need look thru all
importing projects to find if they have some target with the same name,
and I think this is not logically. (In c++ or java I have keywords as
"virtual" or "protect" or "abstract" ) to avoid those
misunderstandings in _runtime_. So I dont agree with you that
importing look like extends in java, It more look like include in @c@.

> Please, note the depends clause of target
> name="imported". It states that it depends on target
> test in a project named imported-test, i.e. on "test"
> target in imported.xml. You could read this in [1],
> section Target Overriding.

> I am curious why you want to switch off target
> overriding. I am writing some ant scripts for our
> project and use it quite a lot to reuse code.

> HTH Ivan

> [1]http://ant.apache.org/manual/CoreTasks/import.html
> --- Andrew Solonchuk <solo@ibis.ua> wrote:

>> 
>> Hi I've tested <import> for using in my build file
>> and don't
>> understood some thing
>> 
>> if i have
>> <project name="import-test" default="main"
>> basedir=".">
>>   <import file="imported.xml"/>
>>   <target name="main">
>>     <echo message="In main"/>
>>     <antcall target="imported"/>
>>   </target>
>>   <target name="test">
>>      <echo message="target 'test' in import-test
>> progect" />
>>   </target>
>> </project>
>> 
>> <project name="imported-test" default="imported"
>> basedir=".">
>>   <target name="imported" depends="test" >
>>     <echo message="In imported target" />
>>   </target>
>>   <target name="test">
>>      <echo message="target 'test' in imported-test
>> progect" />
>>   </target>
>> </project>
>> 
>> I have output
>> Buildfile: import.xml
>> main:
>>      [echo] In main
>> test:
>>      [echo] target 'test' in import-test progect
>> imported:
>>      [echo] In imported target
>> 
>> 
>> But I need if target name="imported" depends="test"
>> to be executed
>> "test" from file where demends where declared,...
>> not having
>> overloading target.
>> 
>> How to do that? or import is simply include and not
>> more?


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


Mime
View raw message