Groovy Libraries allow custom Groovy functions and helpers to be shared and reused across all Groovy scripts in FlexDeploy
Table of Contents | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...
Lets look at what happens when FlexDeploy compiles and creates instances of your custom libraries that will be added to for other Groovy scripts to use.
FlexDeploy will iterate through all your Groovy Libraries and create instances an instance of each.
A new instance of
LIB_ONE
is created.During initialization of
LIB_ONE
it will create a new instance ofLIB_TWO
as declared on line 1 ofLIB_ONE
An instance of
LIB_TWO
is created during step 3. This in turn creates an instance ofLIB_ONE
as declared on line 1 ofLIB_TWO
.We are now stuck in a loop between steps 3 and 4, infinitely creating new instances. This is what is known as a circular dependency and will result in an error being thrown.
Tip | ||||
---|---|---|---|---|
If it is absolutely necessary to have a circular dependency between libraries, then the creation of library instances should be done within a function scope.
|