Upgrading to Grails 1.2 with maven

Update your pom.xml

Set your maven-grails-plugin to version 1.2.0.

Update the grails components (grails-crud and grails-gorm) to 1.2.0.

Update other dependencies (theoretically it shouldn't be a requirement):

  • hsqldb -> 1.8.0.10
  • Grails' hibernate cache now defaults to ehcache,
      • hibernate-ehcache -> 3.3.1.GA
      • ehcache-core -> 1.7.1
      • slf4j -> 1.5.8
...
    <dependencies>
        <dependency>
            <groupId>org.grails</groupId>
            <artifactId>grails-crud</artifactId>
            <version>1.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.grails</groupId>
            <artifactId>grails-gorm</artifactId>
            <version>1.2.0</version>
        </dependency>
    <!-- Grails defaults to Ehache for the second-level Hibernate cache. -->
        <dependency>
          <groupId>org.hibernate</groupId>
          <artifactId>hibernate-ehcache</artifactId>
          <version>3.3.1.GA</version>
        </dependency>
 
        <dependency>
          <groupId>net.sf.ehcache</groupId>
          <artifactId>ehcache-core</artifactId>
          <version>1.7.1</version>
      <exclusions>
          <exclusion>
              <artifactId>jms</artifactId>
          </exclusion>
          <exclusion>
              <artifactId>servlet-api</artifactId>
          </exclusion>
          <!-- We have JCL-over-SLF4J instead. -->
          <exclusion>
              <artifactId>commons-logging</artifactId>
          </exclusion>
      </exclusions>
        </dependency>
        <!--
            Use Log4J for logging. This artifact also pulls in the Log4J JAR.
        -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.5.8</version>
            <scope>runtime</scope>
        </dependency>
    </dependencies>
...

After the updating the pom.xml a clean install will fail because of dependency resolution failure:

...

[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

Missing:
----------
1) org.grails:grails-scripts:jar:1.2.0

  Try downloading the file manually from the project website.

  Then, install it using the command: 
      mvn install:install-file -DgroupId=org.grails -DartifactId=grails-scripts -Dversion=1.2.0 -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file there: 
      mvn deploy:deploy-file -DgroupId=org.grails -DartifactId=grails-scripts -Dversion=1.2.0 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency: 
      1) org.grails:grails-maven-plugin:maven-plugin:1.2.0
      2) org.grails:grails-scripts:jar:1.2.0

2) org.slf4j:jcl-over-slf4j:jar:1.5.8

  Try downloading the file manually from the project website.

  Then, install it using the command: 
      mvn install:install-file -DgroupId=org.slf4j -DartifactId=jcl-over-slf4j -Dversion=1.5.8 -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file there: 
      mvn deploy:deploy-file -DgroupId=org.slf4j -DartifactId=jcl-over-slf4j -Dversion=1.5.8 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency: 
      1) org.grails:grails-maven-plugin:maven-plugin:1.2.0
      2) org.grails:grails-bootstrap:jar:1.2.0
      3) org.slf4j:jcl-over-slf4j:jar:1.5.8

3) org.gparallelizer:GParallelizer:jar:0.8.3

  Try downloading the file manually from the project website.

  Then, install it using the command: 
      mvn install:install-file -DgroupId=org.gparallelizer -DartifactId=GParallelizer -Dversion=0.8.3 -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file there: 
      mvn deploy:deploy-file -DgroupId=org.gparallelizer -DartifactId=GParallelizer -Dversion=0.8.3 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency: 
      1) org.grails:grails-maven-plugin:maven-plugin:1.2.0
      2) org.grails:grails-bootstrap:jar:1.2.0
      3) org.gparallelizer:GParallelizer:jar:0.8.3

4) org.tmatesoft.svnkit:svnkit:jar:1.2.3.5521

  Try downloading the file manually from: 
      http://svnkit.com/download/index.php

  Then, install it using the command: 
      mvn install:install-file -DgroupId=org.tmatesoft.svnkit -DartifactId=svnkit -Dversion=1.2.3.5521 -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file there: 
      mvn deploy:deploy-file -DgroupId=org.tmatesoft.svnkit -DartifactId=svnkit -Dversion=1.2.3.5521 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency: 
      1) org.grails:grails-maven-plugin:maven-plugin:1.2.0
      2) org.grails:grails-scripts:jar:1.2.0
      3) org.tmatesoft.svnkit:svnkit:jar:1.2.3.5521

5) aopalliance:aopalliance:jar:1.0

  Try downloading the file manually from the project website.

  Then, install it using the command: 
      mvn install:install-file -DgroupId=aopalliance -DartifactId=aopalliance -Dversion=1.0 -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file there: 
      mvn deploy:deploy-file -DgroupId=aopalliance -DartifactId=aopalliance -Dversion=1.0 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency: 
      1) org.grails:grails-maven-plugin:maven-plugin:1.2.0
      2) org.grails:grails-scripts:jar:1.2.0
      3) org.grails:grails-core:jar:1.2.0
      4) org.springframework:spring-aop:jar:3.0.0.RELEASE
      5) aopalliance:aopalliance:jar:1.0

6) org.slf4j:slf4j-api:jar:1.5.8

  Try downloading the file manually from the project website.

  Then, install it using the command: 
      mvn install:install-file -DgroupId=org.slf4j -DartifactId=slf4j-api -Dversion=1.5.8 -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file there: 
      mvn deploy:deploy-file -DgroupId=org.slf4j -DartifactId=slf4j-api -Dversion=1.5.8 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency: 
      1) org.grails:grails-maven-plugin:maven-plugin:1.2.0
      2) org.grails:grails-bootstrap:jar:1.2.0
      3) org.slf4j:slf4j-api:jar:1.5.8

----------
6 required artifacts are missing.

for artifact: 
  org.grails:grails-maven-plugin:maven-plugin:1.2.0

from the specified remote repositories:
  nexus (http://192.168.223.217:8081/nexus/content/groups/public)

[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Fri Jan 15 15:29:08 CET 2010
[INFO] Final Memory: 10M/547M
[INFO] ------------------------------------------------------------------------

Either download it and do a manual install or configure your Nexus repository properly

The adding of http://repo1.maven.org/maven2/ as a Nexus proxy repository resulted in the lack of 17 new dependencies. But then I added the http://maven.springframework.org/milestone respository to Nexus

Can't grails:upgrade

At this point grails:upgrade is not working:

oliver@oliver-desktop:~/prog/groovy/factory/salons$ mvn grails:exec -Dcommand=upgrade
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Events Web
[INFO]    task-segment: [grails:exec] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [grails:exec {execution: default-cli}]
[INFO] Using Grails 1.2.0
Running pre-compiled script
Environment set to development

        WARNING: This target will upgrade an older Grails application to 1.2.0.
        However, tag libraries provided by earlier versions of Grails found in grails-app/taglib will be removed. 
        The target will not, however, delete tag libraries developed by yourself.
        Are you sure you want to continue? 
                    (y, n)
y
   [delete] Deleting directory /home/oliver/prog/groovy/factory/salons/target/resources
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Unable to start Grails

Embedded error: java.lang.reflect.InvocationTargetException
/home/oliver/prog/groovy/factory/salons/null/src/war not found.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11 seconds
[INFO] Finished at: Fri Jan 22 17:02:25 CET 2010
[INFO] Final Memory: 36M/554M
[INFO] ------------------------------------------------------------------------

Create your BuildConfig.groovy

The solution seems to be in the BuildConfig.groovy. With this configuration..

grails.project.dependency.resolution = {
    inherits "global" // inherit Grails' default dependencies
    log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
    repositories {
    }
 
    dependencies {
        // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
        runtime 'org.hibernate:hibernate-core:3.3.1.GA'
   }
}

.. the problem is solved and you can go to the next step.

At this point, in the probable case that you are persisting enums, you'll be blocked by bug GRAILS-5760 which causes "Hibernate MappingException using enums in domain persistence with Maven and Grails".
It is planned to be solved for Grails 1.2.1 so maven users have 2 options at this point:

  1. wait until 1.2.1 is released
  2. migrate the maven configuration to the new Grails dependency resolution system.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License