Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails environments

Tags:

grails

I couldn't find an answer in the documentation so I'm asking here.

In Grails when you create an app you get the Production, Development etc environments by default.

If you want to build a WAR for Production you can run either of these commands:

grails war

OR

grails -Dgrails.env=prod war

If you want to create a WAR for the development environment you use the command:

grails -Dgrails.env=dev war

My questions;

1) Can I use the word 'production' instead of 'prod' and use 'development' instead of 'dev'? I assume that 'prod' and 'dev' are just shorthand for 'production' and 'development', so I should be able to use either?

2) If so, if I introduce my own environment called 'Stage' can I create a shorthand for use in setting -Dgrails.env? Something like 'stg' for example.

Thanks.

like image 605
C0deAttack Avatar asked May 04 '11 09:05

C0deAttack


People also ask

What are the default environments in Grails?

Grails supports different environments for configuring properties. Default we get a development, test and production environment, but we are free to add our own environments.

What is Grails framework used for?

Grails is Java and Groovy framework used when developing agile web applications. Grails implements the MVCS (Model, View, and Controller) design pattern. Grails is superb because it allows developers to concentrate more on actual application requirements and spend less time configuring the framework.

Is Grails built on Spring?

The Grails framework is built on top of Spring Boot and leverages Spring Boot's time-saving features, such as Spring-powered dependency injection.

Is Grails a spring boot?

Grails (more precisely it's latest major version) is a framework built on top of the Spring Boot project and uses the Apache Groovy language to develop web apps. It's inspired by the Rails Framework for Ruby and is built around the convention-over-configuration philosophy which allows reducing boilerplate code.


1 Answers

1) Can I use the word 'production' instead of 'prod' and use 'development' instead of 'dev'? I assume that 'prod' and 'dev' are just shorthand for 'production' and 'development', so I should be able to use either?

The short answer is yes. You can use either the short name or full name of an environment to the grails.env parameter. The short and full names of the environments defined by Grails are shown below

short name|full name
prod      |PRODUCTION
dev       |DEVELOPMENT
test      |TEST

The value provided for grails.env is matched case-insensitively against the short and full name of all environments.

2) If so, if I introduce my own environment called 'Stage' can I create a shorthand for use in setting -Dgrails.env? Something like 'stg' for example.

No, the short names are stored within a private static field of grails.util.Environment, which you should not access

like image 67
Dónal Avatar answered Sep 20 '22 13:09

Dónal