Upgrading to grails 1.1 with maven

Grails 1.1

Upgrading & creating apps

Creating apps with the maven archetype

Find the information here: http://www.grails.org/Maven+Integration
Just take care to use the last available version of the archetype which at the moment is 1.0-RC2, not 1.0-SNAPSHOT:

mvn archetype:generate -DarchetypeGroupId=org.grails \
    -DarchetypeArtifactId=grails-maven-archetype \
    -DarchetypeVersion=1.0-RC2 \
    -DarchetypeRepository=http://snapshots.repository.codehaus.org \
    -DgroupId=example -DartifactId=my-app

When doing

mvn initialize

you will get a build error like this one:
....
Running pre-compiled script
Environment set to development
   [mkdir] Created dir: /home/oliver/tmp/deleteme/my-app/src/java
   [mkdir] Created dir: /home/oliver/tmp/deleteme/my-app/src/groovy
   [mkdir] Created dir: /home/oliver/tmp/deleteme/my-app/grails-app
   [mkdir] Created dir: /home/oliver/tmp/deleteme/my-app/grails-app/controllers
   [mkdir] Created dir: /home/oliver/tmp/deleteme/my-app/grails-app/services
   [mkdir] Created dir: /home/oliver/tmp/deleteme/my-app/grails-app/domain
   [mkdir] Created dir: /home/oliver/tmp/deleteme/my-app/grails-app/taglib
   [mkdir] Created dir: /home/oliver/tmp/deleteme/my-app/grails-app/utils
   [mkdir] Created dir: /home/oliver/tmp/deleteme/my-app/grails-app/views
   [mkdir] Created dir:
/home/oliver/tmp/deleteme/my-app/grails-app/views/layouts
   [mkdir] Created dir: /home/oliver/tmp/deleteme/my-app/grails-app/i18n
   [mkdir] Created dir: /home/oliver/tmp/deleteme/my-app/grails-app/conf
   [mkdir] Created dir: /home/oliver/tmp/deleteme/my-app/test
   [mkdir] Created dir: /home/oliver/tmp/deleteme/my-app/test/unit
   [mkdir] Created dir: /home/oliver/tmp/deleteme/my-app/test/integration
   [mkdir] Created dir: /home/oliver/tmp/deleteme/my-app/scripts
   [mkdir] Created dir: /home/oliver/tmp/deleteme/my-app/web-app
   [mkdir] Created dir: /home/oliver/tmp/deleteme/my-app/web-app/js
   [mkdir] Created dir: /home/oliver/tmp/deleteme/my-app/web-app/css
   [mkdir] Created dir: /home/oliver/tmp/deleteme/my-app/web-app/images
   [mkdir] Created dir: /home/oliver/tmp/deleteme/my-app/web-app/META-INF
   [mkdir] Created dir: /home/oliver/tmp/deleteme/my-app/lib
   [mkdir] Created dir: /home/oliver/tmp/deleteme/my-app/grails-app/conf/spring
   [mkdir] Created dir:
/home/oliver/tmp/deleteme/my-app/grails-app/conf/hibernate
[propertyfile] Creating new property file:
/home/oliver/tmp/deleteme/my-app/application.properties
    [copy] Copying 1 resource to /home/oliver/tmp/deleteme/my-app
   [unjar] Expanding:
/home/oliver/tmp/deleteme/my-app/grails-shared-files.jar into
/home/oliver/tmp/deleteme/my-app
  [delete] Deleting: /home/oliver/tmp/deleteme/my-app/grails-shared-files.jar
    [copy] Copying 1 resource to /home/oliver/tmp/deleteme/my-app
   [unjar] Expanding:
/home/oliver/tmp/deleteme/my-app/grails-app-files.jar into
/home/oliver/tmp/deleteme/my-app
  [delete] Deleting: /home/oliver/tmp/deleteme/my-app/grails-app-files.jar
    [move] Moving 1 file to /home/oliver/tmp/deleteme/my-app
    [move] Moving 1 file to /home/oliver/tmp/deleteme/my-app
Unable to load script 'CreateApp' (error: java.lang.NullPointerException)
Run 'grails help' for a complete list of available scripts.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Grails returned non-zero value: 1
....

The cause is that the archetype is not adding the hibernate plugin so you'll have to do it manually in order to make your application work.
$ mvn grails:install-plugin -DpluginName=hibernate -DpluginVersion=1.1-RC1

Internationalized messages are not showing properly (RC1)

There's an issue at jira: GRAILS-4090. Already corrected on RC2

/test/unit/**/*Test.java files are ignored

There's also an issue at jira: GRAILS-4099. Please, also vote for it!!!

Integration tests can't see unit tests

Running tests of type 'integration'
  [groovyc] Compiling 1 source file to /home/oliver/tmp/deleteme/my/target/test-classes/integration
  [groovyc] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, /home/oliver/tmp/deleteme/my/test/integration/AuthorItTests.groovy: 14: unable to resolve class AuthorTests 
  [groovyc]  @ line 14, column 16.
  [groovyc]        assertNotNull(new AuthorTests())
  [groovyc]                   ^
  [groovyc] 
  [groovyc] 1 error
Compilation Error: Compilation Failed
Error running integration tests: java.lang.ClassNotFoundException: AuthorItTests
java.lang.ClassNotFoundException: AuthorItTests

This has been reported at GRAILS-4168. Vote for it!!!

Integration tests should use a plural suffix (*Tests.groovy)

Only tests using *Tests suffix are detected to be run. The solution is to rename your integration classes from *Test to *Tests.

Packaged integration tests don't have acces to domain classes

Integration tests located into a package won't compile if they are referencing domain classes.

This has been reported at GRAILS-4168. Vote for it!!!

war:war fails

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'war'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Callcenter web
[INFO]    task-segment: [war:war]
[INFO] ------------------------------------------------------------------------
[INFO] [war:war]
[INFO] Packaging webapp
[INFO] Assembling webapp[callcenter] in [/home/oliver/prog/groovy/factory/callcenter/target/callcenter-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Webapp assembled in[180 msecs]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error assembling WAR: Deployment descriptor: /home/oliver/prog/groovy/factory/callcenter/target/callcenter-0.0.1-SNAPSHOT/WEB-INF/web.xml does not exist.

This is caused because the grails maven plugin requires an empty src/main/webapp/WEB-INF/web.xml file. I solved the issue this way:

$ mkdir src/main/webapp/WEB-INF -p
$ touch src/main/webapp/WEB-INF/web.xml
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License