How should I setup my environment to use the grails plugin ?

Pre-requisites :

  • GRAILS must be installed locally and the environment variable GRAILS_HOME set.
  • This plugin is compatible with maven 2.0.5+.
  • This plugin is compatible with grails 0.5.6+.

Setup to use a released version

Because our groupId isn't referenced by maven to be a plugin groupId (by default maven knows only org.apache.maven.plugins and org.codehaus.mojo) you have to add it in your user's settings (~/.m2/settings.xml) :

<settings>
  ...  
  <pluginGroups>
    <pluginGroup>com.octo.mtg</pluginGroup>
  </pluginGroups>
  ...
</settings>

To use the plugin you just have to launch :

  mvn grails:<a goal>

Setup to use a snapshot version

To use a snapshot version of the plugin, in addition of the settings explained on top you also have to had in your settings a profile with our repositories to download the plugin and its dependencies.

<settings>
  ...  
  <profiles>
    <profile>
      <id>mtg</id>
      <repositories>
        <repository>
          <id>mtg.snapshots</id>
          <name>Forge Snapshot Repository</name>
          <url>http://forge.octo.com/archiva/repository/mtg-snapshots</url>
          <releases>
            <enabled>false</enabled>
          </releases>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>mtg.snapshots</id>
          <name>Forge Snapshot Repository</name>
          <url>http://forge.octo.com/archiva/repository/mtg-snapshots</url>
          <releases>
            <enabled>false</enabled>
          </releases>
        </pluginRepository>
      </pluginRepositories>
    </profile>
   </profiles>  
  ...
</settings>

You can activate this profile permanently in your settings

<settings>
  ...
  <activeProfiles>
    <activeProfile>mtg</activeProfile>
  </activeProfiles>
  ...
</settings>

Or just when necessary with the command line parameter

  mvn -Pmtg <A goal|A phase>

To use the snapshot version of the plugin you can declare it in your project POM or you can use the long syntax to call the plugin :

  mvn com.octo.mtg:grails-maven-plugin:<x.x>-SNAPSHOT:<A Goal>