Last updated by 5 years ago
Page: Maven Integration, Version:2
The Maven 2 integration for Grails is currently a work in progress. If you would like to try it out, we very much welcome feedback on bugs, improvements that can make, or any other related comments.The current Maven plugin is based on, but effectively supercedes, the version created by the guys at Octo who did a great job.
PreparationIn order to try the new plugin, all you need is Maven 2 installed and set up. In fact, you should unset the GRAILS_HOME environment variable when running Maven with a Grails project. This is because you no longer need to install Grails separately to use it with Maven!One piece of configuration that may help is setting up a plugin group in your Maven settings file (
Also, remove the
<settings> … <pluginGroups> <pluginGroup>org.grails</pluginGroup> </pluginGroups> </settings>
com.octo.mtgplugin group if you have it set up.
Just do it!Without further ado, let's create our Mavenised Grails project:
Choose whichever group ID and artifact ID you want for your application, but everything else must be as written. This will create a new Maven project with a POM and a couple of other files. What you won't see is anything that looks like a Grails application. So, the next step is to create the project structure that you're used to:
mvn archetype:generate -DarchetypeGroupId=org.grails \ -DarchetypeArtifactId=grails-maven-archetype \ -DarchetypeVersion=1.0-SNAPSHOT \ -DarchetypeRepository=http://snapshots.repository.codehaus.org \ -DgroupId=example -DartifactId=my-app
Now we have a Grails application all ready to go. The plugin integrates into the standard build cycle, so you can use the standard Maven phases to build and package your app:
mvn package.You can also take advantage of some of the Grails commands that have been wrapped as Maven goals: