Andrej Koelewijn

  • Home
  • About
  • Departments
    • cloud
    • java
    • mobile
    • open standards
    • oracle
    • oss
    • other
    • soa
    • software development
    • tablet
    • Uncategorized
    • web
  • Subscribe via RSS

Targetting different environments with Grails

February 4th, 2009  |  Published in java

Mainly as a reminder to myself, here’s how you target different environments with grails.

Grails knows about three environments out of the box: development, test, production. When you create a war file you can specify the environment after the grails command:

grails test war

Sometimes, (actually quite often), you have more environments. For example a user acceptance testing environment. You can easily add configuration information for a new environement in your grails apps. Here are some lines of code from DataSource.groovy, to define the datasource for the acceptance environment:

	acceptance {
		dataSource {
			dbCreate = "update"
			jndiName = "jdbc/myAppPool"
		}
	}

If you want to create a war file for this environment, you need to run grails as follows:

grails -Dgrails.env=acceptance war

Btw, if you want to write code for a specific environment, for example to automatically create some test data in your development environment, you can do this as follows. In BootStrap.groovy you’d write:

class BootStrap {
  def init = { servletContext ->
    if (GrailsUtil.environment == "development"){
      def employee = new Employee(...)
      employee.save()
    }
  }
}

One last remark: i really don’t like targetting different environments when building the software. I think you should be able to ship one and the same war file to 100 customers, without having to change the war file. I also think you should be able to install one and the same war file on all your environments without rebuilding the file. Otherwise your build might introduce bugs that you though you’d fixed.

Share and Enjoy:
  • del.icio.us
  • Google Bookmarks
  • DZone
  • SphereIt
  • StumbleUpon
  • Technorati
  • LinkedIn
  • HackerNews
  • PDF
  • Digg
  • Facebook
  • FriendFeed
  • Posterous
  • Tumblr
  • Twitter
  • RSS
blog comments powered by Disqus

Tags

bi bpel camel cep css dsl esb esper google governance grails groovy gtalk html5 innovation internet ipad ivy java javascript jaxrs jersey jigsaw jquery linkeddata linux maven middleware mule noiv openoffice openweb oracle osgi oss plsql rdbms rest soa sql sun tablet web 2.0 xmpp yql

Archives

  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • October 2008

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

Recent Posts

  • Getting started with Nexus maven repository manager
  • JEE CDI tip: Target Unreachable, identifier resolved to null
  • Absent Code attribute in method that is not native or abstract
  • Prezi presentation software needs to add visual
  • So you think it’s the iPad that’s missing features?

Categories

  • cloud
  • java
  • mobile
  • open standards
  • oracle
  • oss
  • other
  • soa
  • software development
  • tablet
  • Uncategorized
  • web

Recent Comments

  • andrej on So you think it’s the iPad that’s missing features?
  • Dave on So you think it’s the iPad that’s missing features?
  • andrej on So you think it’s the iPad that’s missing features?
  • Fernando on So you think it’s the iPad that’s missing features?
  • andrej on So you think it’s the iPad that’s missing features?

RSS Friendfeed

  • Improving the Testability of Java EE With Arquillian; 1.0.0 Alpha 1 Released March 11, 2010
    andrej koelewijn Improving the Testability of Java EE With Arquillian; 1.0.0 Alpha 1 Released - http://feeds.dzone.com/~r... 3 hours ago from Google Reader - Comment - Like […]
    FriendFeed
  • Nice set of svg demos: http://bit.ly/cLLECf No it's not flash: http://svg-wow.org/audio/animated-lyrics.svg Bring up to date browser March 11, 2010
    andrej koelewijn Nice set of svg demos: http://svg-wow.org/ No it's not flash: http://svg-wow.org/audio... Bring up to date browser 3 hours ago from Twitter - Comment - Like […]
    FriendFeed
  • SVG Wow! March 11, 2010
    andrej koelewijn SVG Wow! - http://feedproxy.google.com/~r... 3 hours ago from Google Reader - Comment - Like […]
    FriendFeed
  • Google’s Chief Economist: “Newspapers Have Never Made Much Money From News” March 10, 2010
    andrej koelewijn Google’s Chief Economist: “Newspapers Have Never Made Much Money From News” - http://techcrunch.com/2010... yesterday from Google Reader - Comment - Like […]
    FriendFeed
  • Researching differences between Mule and Oracle OSB, any chance of reusing mule code in osb... March 10, 2010
    andrej koelewijn Researching differences between Mule and Oracle OSB, any chance of reusing mule code in osb... yesterday from Twitter - Comment - Like […]
    FriendFeed
  • RT @monkchips: DHS: Smartphones to Sniff Out Suspicious Substances http://bit.ly/cq2JRD March 10, 2010
    andrej koelewijn RT @monkchips: DHS: Smartphones to Sniff Out Suspicious Substances http://www.dhs.gov/files... yesterday from Twitter - Comment - Like […]
    FriendFeed
  • Amerikanen rangschikken Rotterdams MVRDV in top 50 March 9, 2010
    andrej koelewijn Amerikanen rangschikken Rotterdams MVRDV in top 50 - http://www.idealize.nl/2010... Tuesday from Google Reader - Comment - Like […]
    FriendFeed
  • Getting started with Nexus maven repository manager March 9, 2010
    andrej koelewijn Getting started with Nexus maven repository manager - http://www.andrejkoelewijn.com/wp... Tuesday from Google Reader - Comment - Like […]
    FriendFeed
  • @eelzinga Did you add the remote repository to the correct reposutory group in nexus? http://bit.ly/a2gTmZ March 9, 2010
    andrej koelewijn @eelzinga Did you add the remote repository to the correct reposutory group in nexus? http://www.andrejkoelewijn.com/wp... Tuesday from Twitter - Comment - Like […]
    FriendFeed
  • Getting started with Nexus maven repository manager March 9, 2010
    andrej koelewijn Getting started with Nexus maven repository manager - http://www.andrejkoelewijn.com/wp... Tuesday from Andrej Koelewijn - Comment - Like […]
    FriendFeed


©2010 Andrej Koelewijn
Powered by WordPress using the Gridline Lite theme by Graph Paper Press.