Can't install spock to grails 1.3.7 project - grails

I created a simple hello world grails app using Grails 1.3.7:
grails create-app hello
grails create-controller hello
Then I try to install the spock plugin using:
grails install-plugin spock
And I get the following:
Error loading event script from file [/Users/wholladay/.grails/1.3.7/projects/hello/plugins/spock-0.6/scripts/_Events.groovy] startup failed:
Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at jar:file:/Users/wholladay/.ivy2/cache/org.spockframework/spock-core/jars/spock-core-0.6-groovy-1.8.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation because of exception org.spockframework.util.IncompatibleGroovyVersionException: The Spock compiler plugin cannot execute because Spock 0.6.0-groovy-1.8 is not compatible with Groovy 1.7.8. For more information, see http://versioninfo.spockframework.org
Spock location: file:/Users/wholladay/.ivy2/cache/org.spockframework/spock-core/jars/spock-core-0.6-groovy-1.8.jar
Groovy location: file:/usr/local/Cellar/grails/current/lib/groovy-all-1.7.8.jar
So I went to: http://versioninfo.spockframework.org and noticed that there is a version 0.6-groovy-1.7 of spock. So I tried:
grails install-plugin spock 0.6-groovy-1.7
But then I got the following error:
Error resolving plugin [name:spock, group:org.grails.plugins, version:0.6-groovy-1.7].
Plugin not found for name [spock] and version [0.6-groovy-1.7]
Any ideas?

Have you tried using the dependency resolution install instructions on the plugin page?
In your BuildConfig.groovy:
grails.project.dependency.resolution = {
repositories {
grailsCentral()
mavenCentral()
}
dependencies {
test "org.spockframework:spock-grails-support:0.6-groovy-1.7"
}
plugins {
test(":spock:0.6") {
exclude "spock-grails-support"
}
}
}

I think you've made simple mistake. What you want is:
grails install-plugin spock 0.6-groovy-1.7

Related

Grails 3 Cookie plugin not found

I want to use the Grails 3 Cookie plugin (http://plugins.grails.org/plugin/ctoestreich/cookie). In my build.gradle I have these entries here:
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
mavenCentral()
}
dependencies {
[...]
compile 'org.grails.plugins:grails-cookie:2.0.5'
[...]
}
But when running gradle build, he's got problems looking up that dependency:
> Could not resolve all dependencies for configuration ':runtime'.
> Could not find org.grails.plugins:grails-cookie:2.0.5.
Searched in the following locations:
file:/home/marp/.m2/repository/org/grails/plugins/grails-cookie/2.0.5/grails-cookie-2.0.5.pom
file:/home/marp/.m2/repository/org/grails/plugins/grails-cookie/2.0.5/grails-cookie-2.0.5.jar
https://repo.grails.org/grails/core/org/grails/plugins/grails-cookie/2.0.5/grails-cookie-2.0.5.pom
https://repo.grails.org/grails/core/org/grails/plugins/grails-cookie/2.0.5/grails-cookie-2.0.5.jar
https://repo1.maven.org/maven2/org/grails/plugins/grails-cookie/2.0.5/grails-cookie-2.0.5.pom
https://repo1.maven.org/maven2/org/grails/plugins/grails-cookie/2.0.5/grails-cookie-2.0.5.jar
Required by:
project :
Do I need to include an other maven repo? Or is the plugin just gone?
Instead compile 'org.grails.plugins:grails-cookie:2.0.5'
use compile 'org.grails.plugins:cookie:2.0.5'
also you can set cookie expiration configuration in application.yml file
Example-grails.plugins.cookie.cookieage.default: 43200
repo of dependency
Hope it helps you
According to this (at the time of writing), 2.0.3 appears to be the newest version on the repo.grails.org repo:
http://repo.grails.org/grails/core/org/grails/plugins/grails-cookie/
change your dependency to:
compile 'org.grails.plugins:cookie:2.0.3'

Gradle giving ClassNotFoundException while building Grails project

I am trying to use the gradle-grails-plugin to build an existing (small) Grails project. Should this work? What is the relationship between the dependencies in build.gradle and the ones specified in buildConfig.groovy?
In any event, I have two projects, so the topmost build.gradle file is in the parent directory and looks like:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.grails:grails-gradle-plugin:2.2.0.RC1"
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
and then the build.gradle in the Grails project looks like:
apply plugin: "grails"
repositories {
grails.central() //creates a maven repo for the Grails Central repository (Core libraries and plugins)
}
grails {
grailsVersion = '2.4.4'
groovyVersion = '2.3.9'
springLoadedVersion '1.2.0.RELEASE'
}
dependencies {
bootstrap "org.grails.plugins:tomcat:7.0.55.3"
compile 'org.grails.plugins:asset-pipeline:3.0.1'
compile 'org.grails.plugins:scaffolding:2.1.2'
compile 'org.grails.plugins:cache:1.1.8'
runtime 'org.grails.plugins:hibernate4:4.3.1.1'
runtime 'org.grails.plugins:database-migration:1.3.8'
runtime 'org.grails.plugins:jquery:1.11.0'
}
However, when I run ./gradlew war, I get back:
Caused by: java.long.ClassNotFoundException: grails.artefact.Service
Can anyone shed some light on this? There are practically no references to that via Google, it seems to be a Grails 3.x class? Also, I am using Java 1.7.
Class grails.artefact.Service is indeed accessible from v3.0 of grails framework - as can be seen here.
With the following statement grailsVersion = '2.4.4' v2.4.4 is specified to be used and it all looks ok. What spoils the build is the following dependencies entry:
compile 'org.grails.plugins:asset-pipeline:3.0.1'
In this package there is a class asset/pipeline/grails/AssetProcessorService that imports the mentioned grails.artefact.Service which isn't loaded at runtime (probably because of v2.4.4 used).
Unfortunately I can't suggest any solution apart from the trivial like excluding this dependency. I am not a grails developer nor have I set the environment up.
Hopes that helps somehow.

Grails can't load maven-publisher

I am trying to add maven-publisher to a Grails (2.3.6) plugin like so:
dependencies {
compile 'org.mongodb.morphia:morphia:0.107'
compile ":maven-publisher:0.8.1"
}
When I run grails compile I get:
| Error There was an error loading the BuildConfig: Bad artifact coordinates
:maven-publisher:0.8.1, expected format is <groupId>:<artifactId>[:<extension>[
:<classifier>]]:<version> (Use --stacktrace to see the full trace)
What's going on here?
Do not use the maven-publisher plugin. It's old and deprecated. Use the release plugin - it should already be in your plugin's BuildConfig.groovy. If not, here's how it should look (after removing unnecessary cruft):
grails.project.work.dir = 'target'
grails.project.dependency.resolution = {
inherits 'global'
log 'warn'
repositories {
grailsCentral()
mavenLocal()
mavenCentral()
}
dependencies {
compile 'org.mongodb.morphia:morphia:0.107'
}
plugins {
build ':release:3.0.1', ':rest-client-builder:1.0.3', {
export = false
}
}
}
As #dmahapatro said in his comment, jar dependencies go in the dependencies block, and plugin dependencies go in the plugins block.
Note also that you should keep the export = false setting so the plugin is available locally for your use, but doesn't leak into the containing application as an unnecessary transitive dependency.

Grails gradle: How to set System Property

May I know why I'm unable to set the System Property with the systemProperty method when using the grails-gradle-plugin?
My build.gradle as follows:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.grails:grails-gradle-plugin:2.0.0"
}
}
version "0.1"
group "example"
apply plugin: "grails"
repositories {
grails.central() //creates a maven repo for the Grails Central repository (Core libraries and plugins)
}
grails {
grailsVersion = '2.3.5'
groovyVersion = '2.1.9'
springLoadedVersion '1.1.3'
}
dependencies {
bootstrap "org.grails.plugins:tomcat:7.0.50" // No container is deployed by default, so add this
compile 'org.grails.plugins:resources:1.2' // Just an example of adding a Grails plugin
}
test {
println "I'm in the test"
//Could not find method systemProperty() for arguments [geb.env, sauce] on root project
systemProperty 'geb.env', 'sauce'//Fails
}
In the test task, I get the following error when i run $gradle grails-test:
Could not find method systemProperty() for arguments [geb.env, sauce] on root project..."
Is this a problem with the grails-gradle plugin since other plugins like "java" allows me to use setProperty? Thanks.
The error message is correct: there's no systemProperty() method.
As Joshua Moore comments, this should work:
test {
println "I'm in the test"
System.setProperty 'geb.env', 'sauce'
}

Grails 2.0 plugin dependencies

I'm trying to build a Grails 2.0 application using private plugins:
mycompany-frontend = Grails Application
mycompany-core = Grails plugins for domain classes
In the mycompany-core plugin, I created some domain classe and added a joda-time dependency in BuildConfig.groovy:
plugins {
build(":tomcat:$grailsVersion",
":release:1.0.1",
":svn:1.0.2") {
export = false
}
build(":joda-time:1.3.1")
}
in the mycompany-frontend app, I have the following BuildConfig.groovy:
plugins {
runtime ":hibernate:$grailsVersion"
runtime ":resources:1.1.5"
build "mycompany:mycompany-core:0.1-SNAPSHOT"
build ":svn:1.0.2"
build ":spring-security-core:1.2.7"
build ":tomcat:$grailsVersion"
}
I also removed grails.plugins entries from application.properties to avoid confusion.
But at the end, the mycompany-frontend cannot find the model classes from mycompany-core plugin.
What should I look/fix to get this working?
Have you tried to define the dependency to your core-plugin as runtime-/compile-dependency instead of build?

Resources