Assaf Arkin wrote:
On Wed, Jul 16, 2008 at 9:01 PM, Ittay Dror <[EMAIL PROTECTED]> wrote:

Assaf Arkin wrote:

On Wed, Jul 16, 2008 at 4:40 AM, Ittay Dror <[EMAIL PROTECTED]> wrote:



Hi,

I have the following build file:
define 'proj' do
 define 'A' do
 project('B')
 end

 define 'B' do
 project('A')
 end
end


running buildr, i get the message:
Circular dependency detected: TOP => proj:A => proj:B => proj:A

this is done (i think) because the 'project' method invokes the project
task. project('B') invokes 'B' which then has 'project('A')' which
invokes
A.

is there a way to avoid this? (I actually need it to get properties from
the project, it doesn't need to take any action)


If the properties of that project are unknown until it's defined, then you
have a classical circular dependency: the definition of A depends on the
definition of B which depends on the definition of A.


they each depend on the *act* of definition, that is, that a task is
invoked. if 'define' was just analogous to 'new', things would work. putting
the properties outside will break the nice modularization.


If define worked like new, then A couldn't reference B because B doesn't
exist when define('A') is called.  So what Buildr is doing is holding on to
the definition under proj, but not running it (equivalent to constructor)
until absolutely necessary.

You can rewrite it as:

a = define('a')
b = define('b') do
  a.invoke
here a.already_invoked is set to true
end
a.enhance do
  b.invoke
end
this action is never called since task a (the project) is already invoked


Assaf


 If the properties are not decided by the definition, then you can put the
outside, e.g. define a constant and access it from either definition.

Assaf




thank you,
ittay

--
--
Ittay Dror <[EMAIL PROTECTED]>






--
--

Ittay Dror <[EMAIL PROTECTED]>




--
--
Ittay Dror <[EMAIL PROTECTED]>

Reply via email to