Grails 3 Code Coverage - grails

I am using Grails version 3.0.4 on Windows 7. Does anyone know of a code coverage plugin or coverage tool that works for Grails 3? Thank you for your time.

I use Cobertura. It works fine for me.
My build.gradle entries for Cobertura:
// in buildScript
maven {
url "https://repo.grails.org/grails/core"
}
// in dependencies block
classpath "net.saliman:gradle-cobertura-plugin:2.3.0"
// in plugins
id "net.saliman.cobertura" version "2.3.0"
and then
apply plugin: "net.saliman.cobertura".

Since Grails 3.0 has migrated to Gradle for its build you should be able to use code coverage plugins available there. We have been using the Cobertura Gradle Plugin with good success where I work.

Related

How to install plugins in grails-3.2.0 which i have used in grails-2.4.4 while upgrading application

I am trying to upgrade my application from Grails 2.4.4 to Grails 3.2.0. I am having problems installing plugins used in previous version. Following Questions did gave me some clarification :
1) First one
2) Second one
Now I have few plugins like tomcat, jquery,etc which are not available at https://bintray.com/grails/plugins as described in First one question.
So can you tell me how do I add plugins which are not in this directory on plugins at bintray.
There is some problem as well I am using database-migration plugin. There is listing available at bintray and says to use it as
compile 'org.grails.plugins:database-migration:3.0.0'
as I added same in build.gradle file in my project under dependencies section. Project gets compiled successfully but does not run. Shows long exception but starting is as follows :
org.gradle.api.tasks.TaskExecutionException: Execution failed for task
':bootRun'.
Please help to resolve this errors while installing plugin in Grails 3.2.0
You need an extra configuration for that plugin as its doc says.
Add in build.gradle
buildscript {
dependencies {
...
classpath 'org.grails.plugins:database-migration:3.0.0'
}
}
dependencies {
...
compile 'org.grails.plugins:database-migration:3.0.0'
}
It is also recommended to add a direct dependency to liquibase because Spring Boot overrides the one provided by this plugin
dependencies {
...
compile 'org.liquibase:liquibase-core:3.5.3'
}
You should also tell Gradle about the migrations folder
sourceSets {
main {
resources {
srcDir 'grails-app/migrations'
}
}
}
Maybe plugins are no longer necessary and don't have direct replacements. The tomcat plugin is not needed because Grails 3 is built on Spring Boot and the dependency:
compile "org.springframework.boot:spring-boot-starter-tomcat"
Provides tomcat already. The jQuery plugin is not needed either because you can simply declare a dependency on the jquery.js file directly using asset pipeline which is just as simple. See How to Use jQuery in Grails 3.0

How to use Gradle Cobertura plugin with Grails 3

I am trying to integrate the Gradle Cobertura plugin with my Grails application, but i seem to stuck in how i can hookup the plugin with my grails test-app runs.
I added the needed dependencies to the build.gradle file. So how can i use the plugin in the Grails application?
You can run Cobertura as Gradle Task as follows :
gradle cobertura
For more details on tasks provided by the Plugin, you may go through https://github.com/stevesaliman/gradle-cobertura-plugin/blob/master/usage.md

Grails war produces JAR file in version 3.1

We're using Grails 3.1 and I'm trying to build a WAR to be run on an external Tomcat container, but when I run grails war, it creates a JAR file in the <project_dir>\build\libs directory. How do I configure Grails to produce a WAR file?
Grails 3.1.2 was released earlier today and includes a bug fix for your issue: https://github.com/grails/grails-core/issues/9736.
Upgrading to 3.1.2 didn't solve the problem. I'm using the web-api profile, so I'm not sure if things are different from the default profile.
However, I did solve this by applying the Gradle war plugin in build.gradle. Note: originally I had the war plugin last, after the other Grails plugins; and it did not work. It worked fine after moving it before them.
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: "war"
apply plugin: "org.grails.grails-web"
apply plugin: "org.grails.plugins.views-json"
Grails 3 is using gradle.
gradle war
And make sure you are using Tomcat 8 and above. For tomcat 7 you need to remove internal tomcat8 jars from war in the config file.

publishing Grails plugins

I'm trying to follow the new process for publishing Grails plugins. I've installed the latest version of the release plugin by adding the following to BuildConfig.groovy
plugins {
build(":tomcat:$grailsVersion", ":release:1.0.1") {
export = false
}
}
But when I try and execute the publish-plugin script, it tells me no such command exists:
c:\workspace\grails-flash-helper>grails publish-plugin
| Script 'PublishPlugin' not found, did you mean:
1) ListPlugins_
2) ListPluginUpdates
3) PluginInfo_
4) InstallPlugin
5) UninstallPlugin
The source code of the plugin is here, in case anyone wants to take a look.
That simply means the plugin hasn't been installed yet. Run grails compile or grails refresh-dependencies first.
BTW, to follow the new mechanism for publishing plugins, you need to use version 2.0.0.BUILD-SNAPSHOT (or 2.0.0 when that's released) of the Release plugin. Version 1.0.1 won't work.

Grails Plugin Maven Integration

I'm trying to create Mavenized Grails application. Everything works fine but as I understood all the dependencies (all .jars like mysql-connector and also all grails (public) plugins like spring-security-core plugin) should be listed in pom.xml.
The thing is that I don't know how to include public grails plugins (is there any Maven repository for that, or should I include used plugins into my local repo?). Or is the proper way how to handle grails plugin to list them in "application.properties" and let the grails to manage these plugins?
Thank you for any comment.:-)
Mateo
You can specify your plugin dependencies in grails-app/conf/BuildConfig.groovy, for example:
grails.project.dependency.resolution = {
plugins {
runtime ':hibernate:1.2.1'
}
}
Update
In response to your comments below, a plugin dependency specified in BuildConfig.groovy (or application.properties) will still be resolved by Grails rather than Maven. I don't think there's any way that you can get Maven to resolve a Grails plugin dependency, because Maven can only work with JAR dependencies in Maven repositories. Remember, Grails plugins are not (typically) available from Maven repositories.
If you want to hand as much control as possible over to Maven, you can try excluding the JARs from your plugin dependencies, e.g.
plugins {
runtime( "org.grails.plugins:hibernate:1.2.1" ) {
excludes "javassist"
}
}
and add them to your pom.xml instead. Here be dragons (see below).
Editorializing
FWIW, unless you really have to build your Grails project with Maven (e.g. because another Maven project depends on it), my advice would be don't. I say this because Maven is very much a second-class citizen in the world of Grails build tools. The usual way to build a Grails app is using the built-in GAnt commands. Future versions of Grails will move towards Gradle as the default build tool, so it seems that Maven will be an afterthought for the forseeable future
By default, Grails plugins are included at the source level. A plugin zip is expanded, and the plugin source is compiled as part of the grails build process.
Since 2.0, grails can use binary plugins. You can depend on plain old JARS if those jars represent binary grails plugins.
Binary grails plugins can be referenced by normal maven coordinates.
Your project's BuildConfig.groovy is where you specify maven repositories and binary plugins.

Resources