3 Upgrading from Grails 2.2 - Reference Documentation
Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith
Version: 2.3.0
3 Upgrading from Grails 2.2
A number of changes need to considered when upgrading your application from Grails 2.2, including:New Data Binder
There is a new data binding mechanism written from the ground up to meet Grails' needs. If you wish to continue using Spring for data binding then you must set thegrails.databinding.useSpringBinder
property to true
in grails-app/conf/Config.groovy
Dependency Resolution changes
Although dependency resolution using Ivy is still supported, the default for Grails 2.3 is to use Aether and the Ivy support will not be improved upon going forward. You may wish to consider using Aether instead for your existing applications by setting the following ingrails-app/conf/BuildConfig.groovy
:grails.project.dependency.resolver = "maven" // or ivy
Dependency Metadata Changes
In addition, the POM and dependency metadata for Grails 2.3 has been re-arranged and cleaned up so that only direct dependencies are specified for an application and all other dependencies are inherited transitvely. This has implications to the upgrade since, for example, Ehcache is now a transitive dependency of the Hibernate plugin, whilst before it was a direct dependency. If get a compilation error related to Ehcache, it is most likely that you don't have the Hibernate plugin installed and need to directly declare the Ehcache dependency:compile "net.sf.ehcache:ehcache-core:2.4.6"
| Configuring classpath :: problems summary :: :::: WARNINGS :::::::::::::::::::::::::::::::::::::::::::::: :: UNRESOLVED DEPENDENCIES :: :::::::::::::::::::::::::::::::::::::::::::::: :: org.springframework#spring-test;3.2.2.RELEASE: configuration not found in org.springframework#spring-test;3.2.2.RELEASE: 'compile'. It was required from org.grails#grails-plugin-testing;2.3.0.BUILD-SNAPSHOT compile ::::::::::::::::::::::::::::::::::::::::::::::
spring-test
(for example the Mail plugin). To correct this run grails dependency-report
and search for plugins that have a transitive dependency on spring-test
and exclude them. For example:plugins { compile ':mail:1.0', { excludes 'spring-test' } }
grails.project.dependency.resolver="maven"
No initial offline mode with Aether
Aether does not support resolving dependencies from a flat file system. This means that the jars we ship with Grails in GRAILS_HOME/lib are not used for the first resolve, but instead the jars are obtained from Maven central. After they have been obtained from Maven central then Aether operates fine offline.If however you do not have the necessary jars in your local Maven repository, then the only way to get offline execution is to enable Ivy via BuildConfig (see above).Scaffolding moved to a plugin and rewritten
If you have dynamically scaffolded controllers in your application then you will need to configure the 1.0 version of the Scaffolding plugin in BuildConfig:plugins { compile ':scaffolding:1.0.0' }
Forked Execution for Testing
Tests are now by default executed in a forked JVM (although this can be disabled). One implication of this is that tests will be slower to execute when using:grails test-app
$ grails // load interactive mode $ grails -> test-app $ grails -> test-app
forkConfig = [maxMemory: 1024, minMemory: 64, debug: false, maxPerm: 256] grails.project.fork = [ test: false, // disable forked execution for test-app run: forkConfig, // configure settings for the run-app JVM … ]
Forked Execution and the Reloading Agent
In Grails 2.3 the reloading agent is no longer on the build system path unless you pass the-reloading
flag to the grails
command:grails -reloading run-app
-reloading
flag. Alternatively, you can enable forking with the following configuration in BuildConfig
:forkConfig = [maxMemory: 1024, minMemory: 64, debug: false, maxPerm: 256] grails.project.fork = [ test: forkConfig, // configure settings for the test-app JVM run: forkConfig, // configure settings for the run-app JVM war: forkConfig, // configure settings for the run-war JVM console: forkConfig // configure settings for the Swing console JVM ]
Forked Execution and Remote Debugging
Thegrails-debug
command will no longer work with Grails for remote debugging sessions. The reason is the command enabled debugging for the build system JVM, but not the JVM used in forked execution. The solution to this is to use the debug-fork
command line argument:grails --debug-fork run-app
debug
setting to true
in BuildConfig
and use the regular grails
command to execute:forkConfig = [maxMemory: 1024, minMemory: 64, debug: true, maxPerm: 256] grails.project.fork = [ run: forkConfig, // configure settings for the run-app JVM ...
Changes to Core plugin versioning schemes and the Upgrade command
Core plugins liketomcat
and hibernate
are no longer versioned the same as the Grails version, instead they are versioned according to the Tomcat and Hibernate version they target. If you are upgrading from Grails 2.2 you need to manually configure the correct Tomcat and Hibernate plugins in BuildConfig
. The upgrade
command will not do this for you!plugins { // plugins for the build system only build ':tomcat:7.0.40.1' // plugins needed at runtime but not for compilation runtime ':hibernate:3.6.10.M3' }
upgrade
command will be deprecated in 2.3 and replaced with a command named use-current-grails-version
, which will make no attempts to automatically upgrade Grails applications.