Grails
  1. Grails
  2. GRAILS-4260

BuildConfig has no environment support

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.1
    • Fix Version/s: 2.3-RC1
    • Component/s: None
    • Labels:
      None

      Description

      The BuildConfig.groovy file is loaded without an environment. This is by design because the environment is not know when it's first loaded. However, we should reload it once the environment is known.

        Activity

        Hide
        Rodrigo Rosenfeld Rosas added a comment -

        Any news on this issue? Will it ever be possible to specify some plugin (like console) just for my development environment?

        Show
        Rodrigo Rosenfeld Rosas added a comment - Any news on this issue? Will it ever be possible to specify some plugin (like console) just for my development environment?
        Hide
        Peter Ledbrook added a comment -

        @Rodrigo That's already possible by declaring the dependency inside an 'if (Environment.current == Environment.PRODUCTION)' condition. This issue relates to the settings outside of such closures.

        Show
        Peter Ledbrook added a comment - @Rodrigo That's already possible by declaring the dependency inside an 'if (Environment.current == Environment.PRODUCTION)' condition. This issue relates to the settings outside of such closures.
        Hide
        Pavel Vlasov added a comment -

        I was unlucky with 'Environment.current' but testing System.getProperty('grails.env') == 'production' just works for my Grails 2.2.0.

        Show
        Pavel Vlasov added a comment - I was unlucky with 'Environment.current' but testing System.getProperty('grails.env') == 'production' just works for my Grails 2.2.0.
        Hide
        Martín Caballero added a comment -

        Same case as @Pavel Vlasov in Grails 2.2.1

        Show
        Martín Caballero added a comment - Same case as @Pavel Vlasov in Grails 2.2.1
        Hide
        Jonathan Pearlin added a comment -

        I ran into a similar issue attempting to access Environment.current in BuildConfig.groovy in Grails 2.2.3. Turns out the issue is that if you do not have an explicit import for grails.util.Environment at the top of BuildConfig.groovy, the DSL treats Environment like an empty map and therefore Environment.current resolves to [:]. Adding the import made Environment.current resolve as expected when called inside any of the DSL's in the file.

        Show
        Jonathan Pearlin added a comment - I ran into a similar issue attempting to access Environment.current in BuildConfig.groovy in Grails 2.2.3. Turns out the issue is that if you do not have an explicit import for grails.util.Environment at the top of BuildConfig.groovy , the DSL treats Environment like an empty map and therefore Environment.current resolves to [:] . Adding the import made Environment.current resolve as expected when called inside any of the DSL's in the file.

          People

          • Assignee:
            Graeme Rocher
            Reporter:
            Peter Ledbrook
          • Votes:
            36 Vote for this issue
            Watchers:
            36 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Last Reviewed:

              Development