2.2. Updating the Main Project

There is no Groovy code in the main project, but what we do here is to define the version, and where necessary configuration, of dependencies used by the application's submodules. We have classpath dependencies and build dependencies, so both are defined.

There are three things to specify:

To start with, we specify the versions of these different components, by adding the following to the pom.xml:

<properties>
    <groovy.version>1.7.2</groovy.version>
    <gmaven.version>1.2</gmaven.version>
    <gmaven.runtime>1.7</gmaven.runtime>
    <groovyobjects.version>0.1-SNAPSHOT</groovyobjects.version>
</properties>

The gmaven.runtime must be compatible with the groovy.version. Typically, if the groovy.version is x.y.z, then the gmaven.runtime will be simply x.y. The documentation on GMaven providers for further details; running mvn groovy:providers is a good place to start.

Note: Groovy Objects also has a dependency on the Groovy runtime, albeit in a very minor way. This dependency is marked optional in order to allow your application to specify its own Groovy runtime version which if needed can be different from that needed by Groovy Objects.

Next, we define how we to compile Groovy code, using the GMaven plugin. We specify the plugin, the version, and its configuration; this goes in <build>/<pluginManagement>:

<build>
    <pluginManagement>
        <plugins>
            ...

            <plugin>
                <groupId>org.codehaus.gmaven</groupId>
                <artifactId>gmaven-plugin</artifactId>
                <version>${gmaven.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <providerSelection>${gmaven.runtime}</providerSelection>
                </configuration>
            </plugin>

        </plugins>
    </pluginManagement>
</build>

Finally, we define the dependencies to Groovy Objects and to Groovy. This goes in <dependencyManagement>/<dependencies>:

<dependencyManagement>
    <dependencies>
        ...

        <!-- Groovy Objects -->
        <dependency>
            <groupId>org.starobjects.groovy</groupId>
            <artifactId>gapplib</artifactId>
            <version>${groovyobjects.version}</version>
        </dependency>

        <dependency>
            <groupId>org.starobjects.groovy</groupId>
            <artifactId>gmetamodel</artifactId>
            <version>${groovyobjects.version}</version>
        </dependency>

        <!-- Groovy -->
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>${groovy.version}</version>
        </dependency>

    </dependencies>
</dependencyManagement>