This is the part 2 of Walk through Grails. In this post we can see how Maven can be integrated with Grails. You can see the part-1 here.

Why I like Maven
I like maven because of its dependency management and build on top of typical build life cycle. So it is easy to manage the dependency lib files as well as manage the entire build life cycle. The profile based configuration is another important feature where you can manage your dependency and build process as different for each environments.

How to use Maven advantage in Grails?
As we saw in the first post of Grails introduction, the conventional over configuration makes Grails application development fast and reliable. The power of Maven could be a significant advantage on Grails based application. There are two stages of a Grails project we can integrate Maven.

  • Existing Grails Project
  • Grails project from scratch

Existing Grails Project
Grails comes with pretty good command line tool that makes easier your job. Just typing the below command on your Grails Project Home will add maven support.

grails create-pom <group-id> 

create-pom command will expect your group id of the project.

Grails Project from the scratch
The traditional archtype command will do the job for you.

mvn archetype:generate -DarchetypeGroupId=org.grails \
    -DarchetypeArtifactId=grails-maven-archetype \
    -DarchetypeVersion=1.0 \
    -DgroupId=grails-app -DartifactId=grails

once you generated pom.xml, you need to change


in to


The go to the project home and issue

mvn initialize

Job done. You have integrated maven with Grails application. You can still use all the Grails commands as maven goals. All you need to do is to add the Grails commands in to Maven goals. Some of the commands I have integrated like,


So if you want to run the application with in-build server all you need to do,

mvn grails run-app 

One thought on “A WALK THROUGH OF GRAILS-PART 2- Maven Integration

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s