Quantcast

multiple environments blocks in Config.groovy

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

multiple environments blocks in Config.groovy

rlovtangen
A default Grails application already has this environments block in Config.groovy:

environments {
    production {
        grails.serverURL = "http://www.changeme.com"
    }
    development {
        grails.serverURL = "http://localhost:8080/${appName}"
   }
    test {
        grails.serverURL = "http://localhost:8080/${appName}"
    }

}


If I add some properties, like:

environments {
    production {
        grails.serverURL = "http://www.changeme.com"
    }
    development {
        grails.serverURL = "http://localhost:8080/${appName}"
        grails.mail.port="25"
        my.custom.property = "a"
    }
    test {
        grails.serverURL = "http://localhost:8080/${appName}"
    }

}


then everything works fine.
But if I add a second environments block to Config.groovy:

environments {
    development {
                my.other.propery = "b"
    }
}

then my.custom.property is evicted.
(But grails.mail.port is still available(!))

Is this a bug, or is multiple environments blocks not supported?

Using Grails 1.3.6.


Ronny


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: multiple environments blocks in Config.groovy

gauravchauhan
Works fine for me in 1.3.6

Can you post your Config block and code by which you are reading the prop ?

Are you running the application in same environment in which you are expecting the variable to be present ?

Regards
Gaurav Chauhan
Mobile: +91-88803-97337



On Tue, Feb 8, 2011 at 7:46 PM, Ronny Løvtangen <[hidden email]> wrote:
A default Grails application already has this environments block in Config.groovy:

environments {
   production {
       grails.serverURL = "http://www.changeme.com"
   }
   development {
       grails.serverURL = "http://localhost:8080/${appName}"
  }
   test {
       grails.serverURL = "http://localhost:8080/${appName}"
   }

}


If I add some properties, like:

environments {
   production {
       grails.serverURL = "http://www.changeme.com"
   }
   development {
       grails.serverURL = "http://localhost:8080/${appName}"
       grails.mail.port="25"
       my.custom.property = "a"
   }
   test {
       grails.serverURL = "http://localhost:8080/${appName}"
   }

}


then everything works fine.
But if I add a second environments block to Config.groovy:

environments {
   development {
               my.other.propery = "b"
   }
}

then my.custom.property is evicted.
(But grails.mail.port is still available(!))

Is this a bug, or is multiple environments blocks not supported?

Using Grails 1.3.6.


Ronny


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: multiple environments blocks in Config.groovy

rlovtangen
In my test project I just use the app-info plugin to inspect the properties.

Here are the detailed steps to reproduce:

1) grails create-app environmentstest

2) add app-info plugin to BuildConfig.groovy:

plugins {
runtime ':app-info:0.4.2'
}

3) add app-info config to Config.groovy:

grails.plugins.dynamicController.mixins = [
   'com.burtbeckwith.grails.plugins.appinfo.PropertiesControllerMixin' : 'com.burtbeckwith.appinfo_test.AdminManageController'
]

4) add properties grails.mail.port and my.custom.property to Config.groovy environments block:

environments {
    production {
        grails.serverURL = "http://www.changeme.com"
    }
    development {
        grails.serverURL = "<a href="http://localhost:8080/${appName}">http://localhost:8080/${appName}"
grails.mail.port="25"
my.custom.property = "a"
    }
    test {
        grails.serverURL = "<a href="http://localhost:8080/${appName}">http://localhost:8080/${appName}"
    }

}

5) grails run-app

 --> both properties are present

7) shutdown

8) add environments block to Config.groovy, after the one already present:

environments {
   development {
my.other.propery = "b"
   }
}

9) grails run-app

 --> my.other.propery and grails.mail.port are present, but not my.custom.property


Ronny

On Feb 8, 2011, at 4:41 PM, Gaurav Chauhan wrote:

Works fine for me in 1.3.6

Can you post your Config block and code by which you are reading the prop ?

Are you running the application in same environment in which you are expecting the variable to be present ?

Regards
Gaurav Chauhan
Mobile: +91-88803-97337



On Tue, Feb 8, 2011 at 7:46 PM, Ronny Løvtangen <[hidden email]> wrote:
A default Grails application already has this environments block in Config.groovy:

environments {
   production {
       grails.serverURL = "http://www.changeme.com"
   }
   development {
       grails.serverURL = "http://localhost:8080/${appName}"
  }
   test {
       grails.serverURL = "http://localhost:8080/${appName}"
   }

}


If I add some properties, like:

environments {
   production {
       grails.serverURL = "http://www.changeme.com"
   }
   development {
       grails.serverURL = "http://localhost:8080/${appName}"
       grails.mail.port="25"
       my.custom.property = "a"
   }
   test {
       grails.serverURL = "http://localhost:8080/${appName}"
   }

}


then everything works fine.
But if I add a second environments block to Config.groovy:

environments {
   development {
               my.other.propery = "b"
   }
}

then my.custom.property is evicted.
(But grails.mail.port is still available(!))

Is this a bug, or is multiple environments blocks not supported?

Using Grails 1.3.6.


Ronny


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email




Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: multiple environments blocks in Config.groovy

gauravchauhan
Can you share your code with me off the list ? I can't understand the actual problem

Regards
Gaurav Chauhan



On Wed, Feb 9, 2011 at 12:17 AM, Ronny Løvtangen <[hidden email]> wrote:
In my test project I just use the app-info plugin to inspect the properties.

Here are the detailed steps to reproduce:

1) grails create-app environmentstest

2) add app-info plugin to BuildConfig.groovy:

plugins {
runtime ':app-info:0.4.2'
}

3) add app-info config to Config.groovy:

grails.plugins.dynamicController.mixins = [
   'com.burtbeckwith.grails.plugins.appinfo.PropertiesControllerMixin' : 'com.burtbeckwith.appinfo_test.AdminManageController'
]

4) add properties grails.mail.port and my.custom.property to Config.groovy environments block:

environments {
    production {
        grails.serverURL = "http://www.changeme.com"
    }
    development {
        grails.serverURL = "http://localhost:8080/${appName}"
grails.mail.port="25"
my.custom.property = "a"
    }
    test {
        grails.serverURL = "http://localhost:8080/${appName}"
    }

}

5) grails run-app

 --> both properties are present

7) shutdown

8) add environments block to Config.groovy, after the one already present:

environments {
   development {
my.other.propery = "b"
   }
}

9) grails run-app

 --> my.other.propery and grails.mail.port are present, but not my.custom.property


Ronny

On Feb 8, 2011, at 4:41 PM, Gaurav Chauhan wrote:

Works fine for me in 1.3.6

Can you post your Config block and code by which you are reading the prop ?

Are you running the application in same environment in which you are expecting the variable to be present ?

Regards
Gaurav Chauhan
Mobile: +91-88803-97337



On Tue, Feb 8, 2011 at 7:46 PM, Ronny Løvtangen <[hidden email]> wrote:
A default Grails application already has this environments block in Config.groovy:

environments {
   production {
       grails.serverURL = "http://www.changeme.com"
   }
   development {
       grails.serverURL = "http://localhost:8080/${appName}"
  }
   test {
       grails.serverURL = "http://localhost:8080/${appName}"
   }

}


If I add some properties, like:

environments {
   production {
       grails.serverURL = "http://www.changeme.com"
   }
   development {
       grails.serverURL = "http://localhost:8080/${appName}"
       grails.mail.port="25"
       my.custom.property = "a"
   }
   test {
       grails.serverURL = "http://localhost:8080/${appName}"
   }

}


then everything works fine.
But if I add a second environments block to Config.groovy:

environments {
   development {
               my.other.propery = "b"
   }
}

then my.custom.property is evicted.
(But grails.mail.port is still available(!))

Is this a bug, or is multiple environments blocks not supported?

Using Grails 1.3.6.


Ronny


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email





Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: multiple environments blocks in Config.groovy

rlovtangen
The problem is that the second block removes some properties set in the first block.

Added the example code to Github:  https://github.com/rlovtangen/grails-environments-test
As you can see, the property grails.mail.port is set, but not the property my.custom.property

Ronny


On Feb 8, 2011, at 8:23 PM, Gaurav Chauhan wrote:

Can you share your code with me off the list ? I can't understand the actual problem

Regards
Gaurav Chauhan



On Wed, Feb 9, 2011 at 12:17 AM, Ronny Løvtangen <[hidden email]> wrote:
In my test project I just use the app-info plugin to inspect the properties.

Here are the detailed steps to reproduce:

1) grails create-app environmentstest

2) add app-info plugin to BuildConfig.groovy:

plugins {
runtime ':app-info:0.4.2'
}

3) add app-info config to Config.groovy:

grails.plugins.dynamicController.mixins = [
   'com.burtbeckwith.grails.plugins.appinfo.PropertiesControllerMixin' : 'com.burtbeckwith.appinfo_test.AdminManageController'
]

4) add properties grails.mail.port and my.custom.property to Config.groovy environments block:

environments {
    production {
        grails.serverURL = "http://www.changeme.com"
    }
    development {
        grails.serverURL = "http://localhost:8080/${appName}"
grails.mail.port="25"
my.custom.property = "a"
    }
    test {
        grails.serverURL = "http://localhost:8080/${appName}"
    }

}

5) grails run-app

 --> both properties are present

7) shutdown

8) add environments block to Config.groovy, after the one already present:

environments {
   development {
my.other.propery = "b"
   }
}

9) grails run-app

 --> my.other.propery and grails.mail.port are present, but not my.custom.property


Ronny

On Feb 8, 2011, at 4:41 PM, Gaurav Chauhan wrote:

Works fine for me in 1.3.6

Can you post your Config block and code by which you are reading the prop ?

Are you running the application in same environment in which you are expecting the variable to be present ?

Regards
Gaurav Chauhan
Mobile: +91-88803-97337



On Tue, Feb 8, 2011 at 7:46 PM, Ronny Løvtangen <[hidden email]> wrote:
A default Grails application already has this environments block in Config.groovy:

environments {
   production {
       grails.serverURL = "http://www.changeme.com"
   }
   development {
       grails.serverURL = "http://localhost:8080/${appName}"
  }
   test {
       grails.serverURL = "http://localhost:8080/${appName}"
   }

}


If I add some properties, like:

environments {
   production {
       grails.serverURL = "http://www.changeme.com"
   }
   development {
       grails.serverURL = "http://localhost:8080/${appName}"
       grails.mail.port="25"
       my.custom.property = "a"
   }
   test {
       grails.serverURL = "http://localhost:8080/${appName}"
   }

}


then everything works fine.
But if I add a second environments block to Config.groovy:

environments {
   development {
               my.other.propery = "b"
   }
}

then my.custom.property is evicted.
(But grails.mail.port is still available(!))

Is this a bug, or is multiple environments blocks not supported?

Using Grails 1.3.6.


Ronny


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email






Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: multiple environments blocks in Config.groovy

gauravchauhan
Was this thing ever supported in grails ? I never tested it myself..... You are repeating whole "environments" block again with same "environment name".....

Do you have any specific scenario which insists you to proceed like this ?

I would have created another environment say "foo" and set the props there......

Regards
Gaurav Chauhan




On Wed, Feb 9, 2011 at 1:26 AM, Ronny Løvtangen <[hidden email]> wrote:
The problem is that the second block removes some properties set in the first block.

Added the example code to Github:  https://github.com/rlovtangen/grails-environments-test
As you can see, the property grails.mail.port is set, but not the property my.custom.property

Ronny


On Feb 8, 2011, at 8:23 PM, Gaurav Chauhan wrote:

Can you share your code with me off the list ? I can't understand the actual problem

Regards
Gaurav Chauhan



On Wed, Feb 9, 2011 at 12:17 AM, Ronny Løvtangen <[hidden email]> wrote:
In my test project I just use the app-info plugin to inspect the properties.

Here are the detailed steps to reproduce:

1) grails create-app environmentstest

2) add app-info plugin to BuildConfig.groovy:

plugins {
runtime ':app-info:0.4.2'
}

3) add app-info config to Config.groovy:

grails.plugins.dynamicController.mixins = [
   'com.burtbeckwith.grails.plugins.appinfo.PropertiesControllerMixin' : 'com.burtbeckwith.appinfo_test.AdminManageController'
]

4) add properties grails.mail.port and my.custom.property to Config.groovy environments block:

environments {
    production {
        grails.serverURL = "http://www.changeme.com"
    }
    development {
        grails.serverURL = "http://localhost:8080/${appName}"
grails.mail.port="25"
my.custom.property = "a"
    }
    test {
        grails.serverURL = "http://localhost:8080/${appName}"
    }

}

5) grails run-app

 --> both properties are present

7) shutdown

8) add environments block to Config.groovy, after the one already present:

environments {
   development {
my.other.propery = "b"
   }
}

9) grails run-app

 --> my.other.propery and grails.mail.port are present, but not my.custom.property


Ronny

On Feb 8, 2011, at 4:41 PM, Gaurav Chauhan wrote:

Works fine for me in 1.3.6

Can you post your Config block and code by which you are reading the prop ?

Are you running the application in same environment in which you are expecting the variable to be present ?

Regards
Gaurav Chauhan
Mobile: +91-88803-97337



On Tue, Feb 8, 2011 at 7:46 PM, Ronny Løvtangen <[hidden email]> wrote:
A default Grails application already has this environments block in Config.groovy:

environments {
   production {
       grails.serverURL = "http://www.changeme.com"
   }
   development {
       grails.serverURL = "http://localhost:8080/${appName}"
  }
   test {
       grails.serverURL = "http://localhost:8080/${appName}"
   }

}


If I add some properties, like:

environments {
   production {
       grails.serverURL = "http://www.changeme.com"
   }
   development {
       grails.serverURL = "http://localhost:8080/${appName}"
       grails.mail.port="25"
       my.custom.property = "a"
   }
   test {
       grails.serverURL = "http://localhost:8080/${appName}"
   }

}


then everything works fine.
But if I add a second environments block to Config.groovy:

environments {
   development {
               my.other.propery = "b"
   }
}

then my.custom.property is evicted.
(But grails.mail.port is still available(!))

Is this a bug, or is multiple environments blocks not supported?

Using Grails 1.3.6.


Ronny


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email







Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: multiple environments blocks in Config.groovy

rlovtangen
I don't have to create a new environments block, I can put all properties in the already existing environments block if that's required. Except I would like to keep my custom properties separate from the frameworks properties, if possible.
The problem was the unexpected result. There's nothing telling me I can't have a second environments block, so I created one. And introduced a bug in our application.
Also, the comment above the existing block (// set per-environment serverURL stem for creating absolute links) indicated that this block was for a single purpose only, and that also led me to create a separate environments block for my custom properties.

Is this a bug, or a not supported case?

Ronny

On Feb 8, 2011, at 9:13 PM, Gaurav Chauhan wrote:

Was this thing ever supported in grails ? I never tested it myself..... You are repeating whole "environments" block again with same "environment name".....

Do you have any specific scenario which insists you to proceed like this ?

I would have created another environment say "foo" and set the props there......

Regards
Gaurav Chauhan




On Wed, Feb 9, 2011 at 1:26 AM, Ronny Løvtangen <[hidden email]> wrote:
The problem is that the second block removes some properties set in the first block.

Added the example code to Github:  https://github.com/rlovtangen/grails-environments-test
As you can see, the property grails.mail.port is set, but not the property my.custom.property

Ronny


On Feb 8, 2011, at 8:23 PM, Gaurav Chauhan wrote:

Can you share your code with me off the list ? I can't understand the actual problem

Regards
Gaurav Chauhan



On Wed, Feb 9, 2011 at 12:17 AM, Ronny Løvtangen <[hidden email]> wrote:
In my test project I just use the app-info plugin to inspect the properties.

Here are the detailed steps to reproduce:

1) grails create-app environmentstest

2) add app-info plugin to BuildConfig.groovy:

plugins {
runtime ':app-info:0.4.2'
}

3) add app-info config to Config.groovy:

grails.plugins.dynamicController.mixins = [
   'com.burtbeckwith.grails.plugins.appinfo.PropertiesControllerMixin' : 'com.burtbeckwith.appinfo_test.AdminManageController'
]

4) add properties grails.mail.port and my.custom.property to Config.groovy environments block:

environments {
    production {
        grails.serverURL = "http://www.changeme.com"
    }
    development {
        grails.serverURL = "http://localhost:8080/${appName}"
grails.mail.port="25"
my.custom.property = "a"
    }
    test {
        grails.serverURL = "http://localhost:8080/${appName}"
    }

}

5) grails run-app

 --> both properties are present

7) shutdown

8) add environments block to Config.groovy, after the one already present:

environments {
   development {
my.other.propery = "b"
   }
}

9) grails run-app

 --> my.other.propery and grails.mail.port are present, but not my.custom.property


Ronny

On Feb 8, 2011, at 4:41 PM, Gaurav Chauhan wrote:

Works fine for me in 1.3.6

Can you post your Config block and code by which you are reading the prop ?

Are you running the application in same environment in which you are expecting the variable to be present ?

Regards
Gaurav Chauhan
Mobile: +91-88803-97337



On Tue, Feb 8, 2011 at 7:46 PM, Ronny Løvtangen <[hidden email]> wrote:
A default Grails application already has this environments block in Config.groovy:

environments {
   production {
       grails.serverURL = "http://www.changeme.com"
   }
   development {
       grails.serverURL = "http://localhost:8080/${appName}"
  }
   test {
       grails.serverURL = "http://localhost:8080/${appName}"
   }

}


If I add some properties, like:

environments {
   production {
       grails.serverURL = "http://www.changeme.com"
   }
   development {
       grails.serverURL = "http://localhost:8080/${appName}"
       grails.mail.port="25"
       my.custom.property = "a"
   }
   test {
       grails.serverURL = "http://localhost:8080/${appName}"
   }

}


then everything works fine.
But if I add a second environments block to Config.groovy:

environments {
   development {
               my.other.propery = "b"
   }
}

then my.custom.property is evicted.
(But grails.mail.port is still available(!))

Is this a bug, or is multiple environments blocks not supported?

Using Grails 1.3.6.


Ronny


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email








Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: multiple environments blocks in Config.groovy

Roshan Dawrani
I think (guess) it may be more of a Groovy issue rather than Grails.


I have defined 2 config blocks there to simulate what you are doing in Config.groovy.

While individually both config objects look fine, when they are merged, you will see that my.custom.property loses its real parent.

============================Config1========================
[development:[grails:[serverURL:http://localhost:8080/x, mail:[port:25]], my:[custom:[property:a]]]] /* correct - my.custom.property is correctly under development*/
============================Config2========================
[development:[my:[other:[propery:b]]]] /* correct - my.other.property is correctly under development*/
============================Config1.merge(Config2)==============
[development:[grails:[serverURL:http://localhost:8080/x, mail:[port:25]], my:[custom:[property:a], other:[propery:b]]]] /* messed-up - my.custom.property is no more under development*/
===========================================================

I personally find the behavior of ConfigSlurper among the most erratic ones once it goes beyond very simple usages.

May be worth a Groovy JIRA, but I will let the ConfigSlurper experts decide.
-- 
Roshan
Blog: http://roshandawrani.wordpress.com/
Twitter: @roshandawrani
Skype: roshandawrani


On Wed, Feb 9, 2011 at 2:05 AM, Ronny Løvtangen <[hidden email]> wrote:
I don't have to create a new environments block, I can put all properties in the already existing environments block if that's required. Except I would like to keep my custom properties separate from the frameworks properties, if possible.
The problem was the unexpected result. There's nothing telling me I can't have a second environments block, so I created one. And introduced a bug in our application.
Also, the comment above the existing block (// set per-environment serverURL stem for creating absolute links) indicated that this block was for a single purpose only, and that also led me to create a separate environments block for my custom properties.

Is this a bug, or a not supported case?

Ronny

On Feb 8, 2011, at 9:13 PM, Gaurav Chauhan wrote:

Was this thing ever supported in grails ? I never tested it myself..... You are repeating whole "environments" block again with same "environment name".....

Do you have any specific scenario which insists you to proceed like this ?

I would have created another environment say "foo" and set the props there......

Regards
Gaurav Chauhan




On Wed, Feb 9, 2011 at 1:26 AM, Ronny Løvtangen <[hidden email]> wrote:
The problem is that the second block removes some properties set in the first block.

Added the example code to Github:  https://github.com/rlovtangen/grails-environments-test
As you can see, the property grails.mail.port is set, but not the property my.custom.property

Ronny


On Feb 8, 2011, at 8:23 PM, Gaurav Chauhan wrote:

Can you share your code with me off the list ? I can't understand the actual problem

Regards
Gaurav Chauhan



On Wed, Feb 9, 2011 at 12:17 AM, Ronny Løvtangen <[hidden email]> wrote:
In my test project I just use the app-info plugin to inspect the properties.

Here are the detailed steps to reproduce:

1) grails create-app environmentstest

2) add app-info plugin to BuildConfig.groovy:

plugins {
runtime ':app-info:0.4.2'
}

3) add app-info config to Config.groovy:

grails.plugins.dynamicController.mixins = [
   'com.burtbeckwith.grails.plugins.appinfo.PropertiesControllerMixin' : 'com.burtbeckwith.appinfo_test.AdminManageController'
]

4) add properties grails.mail.port and my.custom.property to Config.groovy environments block:

environments {
    production {
        grails.serverURL = "http://www.changeme.com"
    }
    development {
        grails.serverURL = "http://localhost:8080/${appName}"
grails.mail.port="25"
my.custom.property = "a"
    }
    test {
        grails.serverURL = "http://localhost:8080/${appName}"
    }

}

5) grails run-app

 --> both properties are present

7) shutdown

8) add environments block to Config.groovy, after the one already present:

environments {
   development {
my.other.propery = "b"
   }
}

9) grails run-app

 --> my.other.propery and grails.mail.port are present, but not my.custom.property


Ronny

On Feb 8, 2011, at 4:41 PM, Gaurav Chauhan wrote:

Works fine for me in 1.3.6

Can you post your Config block and code by which you are reading the prop ?

Are you running the application in same environment in which you are expecting the variable to be present ?

Regards
Gaurav Chauhan
Mobile: +91-88803-97337



On Tue, Feb 8, 2011 at 7:46 PM, Ronny Løvtangen <[hidden email]> wrote:
A default Grails application already has this environments block in Config.groovy:

environments {
   production {
       grails.serverURL = "http://www.changeme.com"
   }
   development {
       grails.serverURL = "http://localhost:8080/${appName}"
  }
   test {
       grails.serverURL = "http://localhost:8080/${appName}"
   }

}


If I add some properties, like:

environments {
   production {
       grails.serverURL = "http://www.changeme.com"
   }
   development {
       grails.serverURL = "http://localhost:8080/${appName}"
       grails.mail.port="25"
       my.custom.property = "a"
   }
   test {
       grails.serverURL = "http://localhost:8080/${appName}"
   }

}


then everything works fine.
But if I add a second environments block to Config.groovy:

environments {
   development {
               my.other.propery = "b"
   }
}

then my.custom.property is evicted.
(But grails.mail.port is still available(!))

Is this a bug, or is multiple environments blocks not supported?

Using Grails 1.3.6.


Ronny


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email









Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: multiple environments blocks in Config.groovy

Roshan Dawrani
Any way I can revoke this mail? :-)

3 AM is not the right time to match brackets. 

Sorry!

Although I do still believe ConfigSlurper is one of the buggiest / most fragile pieces of Groovy code :-) 

# of open Groovy JIRAs against it will confirm.


On Wed, Feb 9, 2011 at 2:34 AM, Roshan Dawrani <[hidden email]> wrote:
I think (guess) it may be more of a Groovy issue rather than Grails.


I have defined 2 config blocks there to simulate what you are doing in Config.groovy.

While individually both config objects look fine, when they are merged, you will see that my.custom.property loses its real parent.

============================Config1========================
[development:[grails:[serverURL:http://localhost:8080/x, mail:[port:25]], my:[custom:[property:a]]]] /* correct - my.custom.property is correctly under development*/
============================Config2========================
[development:[my:[other:[propery:b]]]] /* correct - my.other.property is correctly under development*/
============================Config1.merge(Config2)==============
[development:[grails:[serverURL:http://localhost:8080/x, mail:[port:25]], my:[custom:[property:a], other:[propery:b]]]] /* messed-up - my.custom.property is no more under development*/
===========================================================

I personally find the behavior of ConfigSlurper among the most erratic ones once it goes beyond very simple usages.

May be worth a Groovy JIRA, but I will let the ConfigSlurper experts decide.
-- 
Roshan
Blog: http://roshandawrani.wordpress.com/
Twitter: @roshandawrani
Skype: roshandawrani


On Wed, Feb 9, 2011 at 2:05 AM, Ronny Løvtangen <[hidden email]> wrote:
I don't have to create a new environments block, I can put all properties in the already existing environments block if that's required. Except I would like to keep my custom properties separate from the frameworks properties, if possible.
The problem was the unexpected result. There's nothing telling me I can't have a second environments block, so I created one. And introduced a bug in our application.
Also, the comment above the existing block (// set per-environment serverURL stem for creating absolute links) indicated that this block was for a single purpose only, and that also led me to create a separate environments block for my custom properties.

Is this a bug, or a not supported case?

Ronny

On Feb 8, 2011, at 9:13 PM, Gaurav Chauhan wrote:

Was this thing ever supported in grails ? I never tested it myself..... You are repeating whole "environments" block again with same "environment name".....

Do you have any specific scenario which insists you to proceed like this ?

I would have created another environment say "foo" and set the props there......

Regards
Gaurav Chauhan




On Wed, Feb 9, 2011 at 1:26 AM, Ronny Løvtangen <[hidden email]> wrote:
The problem is that the second block removes some properties set in the first block.

Added the example code to Github:  https://github.com/rlovtangen/grails-environments-test
As you can see, the property grails.mail.port is set, but not the property my.custom.property

Ronny


On Feb 8, 2011, at 8:23 PM, Gaurav Chauhan wrote:

Can you share your code with me off the list ? I can't understand the actual problem

Regards
Gaurav Chauhan



On Wed, Feb 9, 2011 at 12:17 AM, Ronny Løvtangen <[hidden email]> wrote:
In my test project I just use the app-info plugin to inspect the properties.

Here are the detailed steps to reproduce:

1) grails create-app environmentstest

2) add app-info plugin to BuildConfig.groovy:

plugins {
runtime ':app-info:0.4.2'
}

3) add app-info config to Config.groovy:

grails.plugins.dynamicController.mixins = [
   'com.burtbeckwith.grails.plugins.appinfo.PropertiesControllerMixin' : 'com.burtbeckwith.appinfo_test.AdminManageController'
]

4) add properties grails.mail.port and my.custom.property to Config.groovy environments block:

environments {
    production {
        grails.serverURL = "http://www.changeme.com"
    }
    development {
        grails.serverURL = "http://localhost:8080/${appName}"
grails.mail.port="25"
my.custom.property = "a"
    }
    test {
        grails.serverURL = "http://localhost:8080/${appName}"
    }

}

5) grails run-app

 --> both properties are present

7) shutdown

8) add environments block to Config.groovy, after the one already present:

environments {
   development {
my.other.propery = "b"
   }
}

9) grails run-app

 --> my.other.propery and grails.mail.port are present, but not my.custom.property


Ronny

On Feb 8, 2011, at 4:41 PM, Gaurav Chauhan wrote:

Works fine for me in 1.3.6

Can you post your Config block and code by which you are reading the prop ?

Are you running the application in same environment in which you are expecting the variable to be present ?

Regards
Gaurav Chauhan
Mobile: +91-88803-97337



On Tue, Feb 8, 2011 at 7:46 PM, Ronny Løvtangen <[hidden email]> wrote:
A default Grails application already has this environments block in Config.groovy:

environments {
   production {
       grails.serverURL = "http://www.changeme.com"
   }
   development {
       grails.serverURL = "http://localhost:8080/${appName}"
  }
   test {
       grails.serverURL = "http://localhost:8080/${appName}"
   }

}


If I add some properties, like:

environments {
   production {
       grails.serverURL = "http://www.changeme.com"
   }
   development {
       grails.serverURL = "http://localhost:8080/${appName}"
       grails.mail.port="25"
       my.custom.property = "a"
   }
   test {
       grails.serverURL = "http://localhost:8080/${appName}"
   }

}


then everything works fine.
But if I add a second environments block to Config.groovy:

environments {
   development {
               my.other.propery = "b"
   }
}

then my.custom.property is evicted.
(But grails.mail.port is still available(!))

Is this a bug, or is multiple environments blocks not supported?

Using Grails 1.3.6.


Ronny


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email










Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: multiple environments blocks in Config.groovy

prabugp
I remember vaguely about reading something like my.x.y = a will be overridden by my.y.z and to avoid this, you should do something like my.'x.y' = a and my.'y.z' = b.. (right now i am not sure whether it is like what i said or the otherway.. I think mixing DSL with . notation could be tricky)

Try using only the DSL notation and not the '.' notation. try having it as
my{
    x{
     y{
       }
     }
    }

rather than my.x.y and see if that works.
GP
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: multiple environments blocks in Config.groovy

rlovtangen
In reply to this post by rlovtangen
No one knows if multiple environments blocks in Config.groovy is supposed to work or not?
I will file a jira, but depending on the question above, it will be a fix to either Grails core or the documentation.

Ronny

On Feb 8, 2011, at 9:35 PM, Ronny Løvtangen wrote:

I don't have to create a new environments block, I can put all properties in the already existing environments block if that's required. Except I would like to keep my custom properties separate from the frameworks properties, if possible.
The problem was the unexpected result. There's nothing telling me I can't have a second environments block, so I created one. And introduced a bug in our application.
Also, the comment above the existing block (// set per-environment serverURL stem for creating absolute links) indicated that this block was for a single purpose only, and that also led me to create a separate environments block for my custom properties.

Is this a bug, or a not supported case?

Ronny

On Feb 8, 2011, at 9:13 PM, Gaurav Chauhan wrote:

Was this thing ever supported in grails ? I never tested it myself..... You are repeating whole "environments" block again with same "environment name".....

Do you have any specific scenario which insists you to proceed like this ?

I would have created another environment say "foo" and set the props there......

Regards
Gaurav Chauhan




On Wed, Feb 9, 2011 at 1:26 AM, Ronny Løvtangen <[hidden email]> wrote:
The problem is that the second block removes some properties set in the first block.

Added the example code to Github:  https://github.com/rlovtangen/grails-environments-test
As you can see, the property grails.mail.port is set, but not the property my.custom.property

Ronny


On Feb 8, 2011, at 8:23 PM, Gaurav Chauhan wrote:

Can you share your code with me off the list ? I can't understand the actual problem

Regards
Gaurav Chauhan



On Wed, Feb 9, 2011 at 12:17 AM, Ronny Løvtangen <[hidden email]> wrote:
In my test project I just use the app-info plugin to inspect the properties.

Here are the detailed steps to reproduce:

1) grails create-app environmentstest

2) add app-info plugin to BuildConfig.groovy:

plugins {
runtime ':app-info:0.4.2'
}

3) add app-info config to Config.groovy:

grails.plugins.dynamicController.mixins = [
   'com.burtbeckwith.grails.plugins.appinfo.PropertiesControllerMixin' : 'com.burtbeckwith.appinfo_test.AdminManageController'
]

4) add properties grails.mail.port and my.custom.property to Config.groovy environments block:

environments {
    production {
        grails.serverURL = "http://www.changeme.com"
    }
    development {
        grails.serverURL = "http://localhost:8080/${appName}"
grails.mail.port="25"
my.custom.property = "a"
    }
    test {
        grails.serverURL = "http://localhost:8080/${appName}"
    }

}

5) grails run-app

 --> both properties are present

7) shutdown

8) add environments block to Config.groovy, after the one already present:

environments {
   development {
my.other.propery = "b"
   }
}

9) grails run-app

 --> my.other.propery and grails.mail.port are present, but not my.custom.property


Ronny

On Feb 8, 2011, at 4:41 PM, Gaurav Chauhan wrote:

Works fine for me in 1.3.6

Can you post your Config block and code by which you are reading the prop ?

Are you running the application in same environment in which you are expecting the variable to be present ?

Regards
Gaurav Chauhan
Mobile: +91-88803-97337



On Tue, Feb 8, 2011 at 7:46 PM, Ronny Løvtangen <[hidden email]> wrote:
A default Grails application already has this environments block in Config.groovy:

environments {
   production {
       grails.serverURL = "http://www.changeme.com"
   }
   development {
       grails.serverURL = "http://localhost:8080/${appName}"
  }
   test {
       grails.serverURL = "http://localhost:8080/${appName}"
   }

}


If I add some properties, like:

environments {
   production {
       grails.serverURL = "http://www.changeme.com"
   }
   development {
       grails.serverURL = "http://localhost:8080/${appName}"
       grails.mail.port="25"
       my.custom.property = "a"
   }
   test {
       grails.serverURL = "http://localhost:8080/${appName}"
   }

}


then everything works fine.
But if I add a second environments block to Config.groovy:

environments {
   development {
               my.other.propery = "b"
   }
}

then my.custom.property is evicted.
(But grails.mail.port is still available(!))

Is this a bug, or is multiple environments blocks not supported?

Using Grails 1.3.6.


Ronny


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email









Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: multiple environments blocks in Config.groovy

pledbrook
> No one knows if multiple environments blocks in Config.groovy is supposed to
> work or not?
> I will file a jira, but depending on the question above, it will be a fix to
> either Grails core or the documentation.

I think that would require a Groovy JIRA rather than a Grails once,
since ConfigSlurper is in Groovy core.

In my view, it's a reasonable request for ConfigSlurper to support
multiple environment blocks.

Peter

--
Peter Ledbrook
Grails Advocate
SpringSource - A Division of VMware

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: multiple environments blocks in Config.groovy

rlovtangen

On Feb 10, 2011, at 6:47 PM, Peter Ledbrook wrote:

>> No one knows if multiple environments blocks in Config.groovy is supposed to
>> work or not?
>> I will file a jira, but depending on the question above, it will be a fix to
>> either Grails core or the documentation.
>
> I think that would require a Groovy JIRA rather than a Grails once,
> since ConfigSlurper is in Groovy core.
>
> In my view, it's a reasonable request for ConfigSlurper to support
> multiple environment blocks.
>

Thanks Peter, I'll add a Groovy jira improvement ticket over the weekend.

Ronny



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Loading...