Upgrading Grails application to use Maven

If you want to upgrade Grails project to use Maven, all you need is Maven 2 installed.
Go to your project root and follow the steps:

export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=256m"

If you are a Windows user, run

set MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=256m

This is need because default maven options are not enough to run Grails environment.
2. run

mvn org.grails:grails-maven-plugin:x.x.x:create-pom -DgroupId=com.mycompany

Here instead of grails-maven-plugin:x.x.x specify your Grails version and in -DgroupId parameter write your identifier of group. For me it looks like:

mvn org.grails:grails-maven-plugin:2.0.3:create-pom -DgroupId=com.softteco.test

As the result pom.xml  and src/main/webapp/WEB_INF/web.xml will be created.

3. change target JDK version to 1.6


4. run

mvn -Dgrails.env=prod install

or set environment in pom.xml like this:


If you try to run without -Dgrails.env=prod or grails.env property is not set in pom.xml your build will be created with development environment(default).

This command will build a war file in target/. Try it on your webapp container.

All done.

See more info about Grails+Maven here.