NOTE: this post updates an earlier blog post written for version 0.8 of the Karma test runner.
For my current project we are using Maven to build our AngularJS application.
Furthermore we use Sonar (recently renamed to SonarCube) to monitor our code standards / best practices and unit test coverage.
Since Grails 2.2 by default the
run-app command will launch the Grails application in a separate Java Virtual Machine. This is called forked Tomcat execution in Grails. This way the class path of the Grails build system and the application will not intervene and also both processes will have their own memory settings. We can see the settings in
grails-app/conf/BuildConfig.groovy where we find the configuration property
grails.project.fork.run. When we want to debug our application in an IDE like IntelliJ IDEA we cannot use the Debug command, because this will only allow us to debug the Grails build system. We will not reach breakpoints in our source code. But Grails 2.3 introduces an extra argument for the
--debug-fork. If we use this extra argument the JVM running the Grails application will stop and listen for a debug session to be attached and then continue. We can configure a Debug configuration in IntelliJ IDEA (or another IDE) to attach to the waiting Grails application and use breakpoints and other debugging tools like we are used to.
To generate an HTML
select we can use the Grails tag
<g:select .../>. We use the
optionValue attribute to specify a specific property we want to be used as the value. But we can also define a closure for the
optionValue attribute to further customize the value that is shown to the user.
Grails 2.3 added a lot of support for RESTful services. For example we can now use a
respond() method in our controllers to automatically render resources. The
respond() method accepts a resource instance as argument and a map of attributes that can be passed. We can use the
excludes keys of the map to pass which fields of our resources need to be included or excluded in the response. This way we can render partial responses based on a request parameter value.