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

Leave a Response

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

  • August 2010
  • June 2010
  • 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

  • Nice Java Decompiler tool: JD
  • VMware Player: The virtual machine is busy.
  • Adding a maven repository for installing features to ServiceMix
  • Upgrade Apache Camel in ServiceMix to version 2.3.0
  • A composite Rest service using Apache Camel

Categories

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

Recent Comments

  • Buddhika on Using google talk from java example
  • Anonymous on A composite Rest service using Apache Camel
  • Guest on How to find true cause of com.sun.star.uno.RuntimeException?
  • Absent Code attribute in method that is not native or abstract « Gooder Code - web development blog, php, java, asp.net, html, javascript on Absent Code attribute in method that is not native or abstract
  • Rmfume on Oracle best thing that could happen to JavaFX?
Buzz
andrkoel: RT @monkchips: James Governor's Monkchips » Day of The Dead: Web Drives Strong Demand for Java Skills http://monk.ly/d4UlND
1 hours ago, comment
andrkoel: RT @monkchips: In which my business partner @sogrady explains Why You Should Pay Attention to Node.Js http://monk.ly/a4aGIP serverside # ...
8 hours ago, comment
andrkoel: RT @stilkov: http://bit.ly/cDdqgl - AWS Identity and Access Management — I'd hate to have to compete against Amazon's Cloud offerings
14 hours ago, comment
andrkoel: Twitter for ipad is nice, but i still think i need a tool to summarize all info, something like feedly or flipboard is the future
8:36 AM Sep 02, 2010, comment
andrkoel: Trying out the new twitter for ipad... Curious how the panels work.
8:32 AM Sep 02, 2010, comment
 


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