Using Grails Gradle plugin on Ubuntu: Grails not found - grails

I am currently trying to build a Grails project using Gradle to easily integrate some repositories. I have created a new directory, and from said directory I have created the following build.gradle file as instructed from this site:
http://grails.github.io/grails-gradle-plugin/docs/manual/guide/introduction.html
buildscript {
repositories {
jcenter()
}
dependencies {
'org.grails:grails-gradle-plugin:2.1.0'
}
}
apply plugin: 'grails'
grails {
grailsVersion = '2.4.0' // Specifies the Grails version to use
groovyVersion = '2.3.1' // Specify the Groovy version to use (should match the version that ships with the above Grails version)
springLoadedVersion = '1.2.0.RELEASE' // Specify the Spring Loaded version to use
}
repositories {
jcenter()
grails.central() //Adds the Grails Central Repository for resolving Grails plugins (replaces grailsPlugins(), grailsCentral() from BuildConfig.groovy)
}
dependencies {
bootstrap 'org.grails.plugins:tomcat:7.0.50.1'
compile 'org.grails.plugins:scaffolding:2.0.2'
compile 'org.grails.plugins:cache:1.1.1'
runtime 'org.grails.plugins:hibernate:3.6.10.8' //or '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'
runtime 'org.grails.plugins:resources:1.2.2'
//runtime 'mysql:mysql-connector-java:5.1.24'
//runtime 'org.postgresql:postgresql:9.3.1100-jdbc41'
//Additional resources capabilities
//runtime 'org.grails.plugins:zipped-resources:1.0.1'
//runtime 'org.grails.plugins:cached-resources:1.1'
//runtime 'org.grails.plugins:yui-minify-resources:0.1.5'
//Alternate to the resources plugin
//compile 'org.grails.plugins:asset-pipeline:1.5.0'
//Additional asset-pipeline capabilities
//compile 'org.grails.plugins:sass-asset-pipeline:1.5.1'
//compile 'org.grails.plugins:less-asset-pipeline:1.5.0'
//compile 'org.grails.plugins:coffee-asset-pipeline:1.5.0'
//compile 'org.grails.plugins:handlebars-asset-pipeline:1.0.0.3'
}
When I try to build using gradle init, I am confronted with this error:
FAILURE: Build failed with an exception.
Where:
Build file '/home/ian/grailsDir/deadness/build.gradle' line: 10
What went wrong:
A problem occurred evaluating root project 'deadness'.
Plugin with id 'grails' not found.
How can I get the Grails plugin? I am currently running Grails 2.5.0 and Gradle 2.4. I tried it with an earlier version of Grails as well.
The stacktrace is:
* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'deadness'.
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:76)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$1.run(DefaultScriptPluginFactory.java:148)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:156)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:39)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:487)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:85)
at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42)
at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:129)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:90)
at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:50)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:27)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:40)
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:169)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: org.gradle.api.plugins.UnknownPluginException: Plugin with id 'grails' not found.
at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:110)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:113)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:36)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:80)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:136)
at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:46)
at org.gradle.api.plugins.PluginAware$apply.call(Unknown Source)
at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.groovy:34)
at org.gradle.api.Script$apply$0.callCurrent(Unknown Source)
at build_cgy5iob1jp300dugadkqvpnyl.run(/home/ian/grailsDir/deadness/build.gradle:10)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:74)
... 35 more

Please, note that the following code...
dependencies {
'org.grails:grails-gradle-plugin:2.1.0'
}
...should be:
dependencies {
classpath 'org.grails:grails-gradle-plugin:2.1.0'
}
This must solve the issue.

Related

how to get GWT work with Grails 3

I am using Grails latest version i.e 3.1.3, and GWT
I have gone through the gwt/grails plugin and their tutorials , but All of this is for old version of grails , where we had "BuildConfig.groovy" and the format looks different.
Now as we have build.gradle , I cant find a way to put gwt plugin there
What i have tried is : adding
compile "org.grails.plugins:gwt:1.0.2"
now when i run command:
grails create-gwt-module
I get the exception:
Could not resolve all dependencies for configuration ':runtime'.
> Could not find org.grails.plugins:resources:1.2.
Searched in the following locations:
file:/C:/Users/Junaid/.m2/repository/org/grails/plugins/resources/1.2/r
sources-1.2.pom
file:/C:/Users/Junaid/.m2/repository/org/grails/plugins/resources/1.2/r
sources-1.2.zip
https://repo.grails.org/grails/core/org/grails/plugins/resources/1.2/re
ources-1.2.pom
https://repo.grails.org/grails/core/org/grails/plugins/resources/1.2/re
ources-1.2.zip
Required by:
helloworld2:helloworld2:0.1 > org.grails.plugins:gwt:1.0.2
this is my build.gradle:
buildscript {
ext {
grailsVersion = project.grailsVersion
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.5.0"
classpath "org.grails.plugins:hibernate4:5.0.2"
}
}
version "0.1"
group "helloworld2"
apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"org.grails.grails-gsp"
apply plugin:"asset-pipeline"
ext {
grailsVersion = project.grailsVersion
gradleWrapperVersion = project.gradleWrapperVersion
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencyManagement {
imports {
mavenBom "org.grails:grails-bom:$grailsVersion"
}
applyMavenExclusions false
}
dependencies {
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"
compile "org.grails.plugins:cache"
compile "org.grails.plugins:scaffolding"
compile "org.grails.plugins:hibernate4"
compile "org.hibernate:hibernate-ehcache"
compile "org.grails.plugins:gwt:2.6.0"
console "org.grails:grails-console"
profile "org.grails.profiles:web:3.1.3"
runtime "org.grails.plugins:asset-pipeline"
runtime "com.h2database:h2"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
}
task wrapper(type: Wrapper) {
gradleVersion = gradleWrapperVersion
}
assets {
minifyJs = true
minifyCss = true
}
Did you try to get compile "org.grails.plugins:gwt:1.0.3", the latest version of plugin?
And if it can't be downloaded automatically to download it manually from repo and put in one of searched locations in your local maven repository?
In official plugin docs you can read:
In Grails 2.x plugins were packaged as ZIP files, however in Grails
3.x plugins are simple JAR files that can be added to the classpath of the IDE.
So try to pack plugin to jar according to official deployment docs:
Another way to deploy in Grails 3.0 or above is to use the new
support for runnable JAR or WAR files. To create runnable archives,
run grails package:
grails package

Grails 3.0 and Spring Security Error

In my build.gradle I added this line of code
dependencies {
compile "org.grails.plugins:spring-security-core:3.0.3"
}
Then when I try to use it
import grails.plugin.springsecurity.annotation.Secured
#Secured('ROLE_ADMIN')
class SecureController {
def index() {
render 'Secure access only'
}
It "cannot resolve the symbol springsecurity"
I get the error
Error:(5, 1) Groovyc: unable to resolve class Secured , unable to find class for annotation
Any help would be much appreciated.
Build.gradle **** EDIT
This is the whole build.gradle file
buildscript {
ext {
grailsVersion = project.grailsVersion
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath 'com.bertramlabs.plugins:asset-pipeline-gradle:2.5.0'
classpath "org.grails.plugins:hibernate:4.3.10.5"
}
}
plugins {
id "io.spring.dependency-management" version "0.5.4.RELEASE"
}
version "0.1"
group "securityrolesspring"
apply plugin: "spring-boot"
apply plugin: "war"
apply plugin: "asset-pipeline"
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: "org.grails.grails-web"
apply plugin: "org.grails.grails-gsp"
ext {
grailsVersion = project.grailsVersion
gradleWrapperVersion = project.gradleWrapperVersion
}
assets {
minifyJs = true
minifyCss = true
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencyManagement {
imports {
mavenBom "org.grails:grails-bom:$grailsVersion"
}
applyMavenExclusions false
}
dependencies {
compile "org.grails.plugins:spring-security-core:3.0.3"
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"
compile "org.grails.plugins:hibernate"
compile "org.grails.plugins:cache"
compile "org.hibernate:hibernate-ehcache"
compile "org.grails.plugins:scaffolding"
runtime "org.grails.plugins:asset-pipeline"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
// Note: It is recommended to update to a more robust driver (Chrome, Firefox etc.)
testRuntime 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.44.0'
console "org.grails:grails-console"
}
task wrapper(type: Wrapper) {
gradleVersion = gradleWrapperVersion
}
after 'apply plugin: "war"' add a line that says:
apply plugin: "maven"
in your repositories section, after "mavenLocal()" add a line that says:
mavenCentral()
this last recommendation is just cosmetic, but I would move your line:
compile "org.grails.plugins:spring-security-core:3.0.3"
and place it after the
compile "org.grails.plugins:scaffolding" line. it's good form to keep the initial set of grails dependencies pretty much as they are from the initial 'grails create-app' command. the exception to this rule is if you want to replace the logback logging with something else, but that's another story.
finally, you could also change your spring-security-core dependency to version 3.0.4 which is out now.
Spring security core has been updated the package location for #Secured Annotations. I use Grails 3.2.3 and Spring Security Core 3.1.1 int my project and works well. The following is the configuration the I used and is working as was in previos version of spring security core and Grails (2.X).
For installation, you have to add the entry in the dependencies block if your build.gradle file. Details in the oficial documentation for installation section for Spring Security Core
dependencies {
...
compile 'org.grails.plugins:spring-security-core:3.1.1'
...
To use the secured annotations in your controller, there were updates on the import (org.springframework.security.access.annotation.Secured) package and the #Secure annotation you have to assign to "value" the security statement you want to do. For example the annotation for #Secured('ROLE_ADMIN'), have to change like in the following example.
import org.springframework.security.access.annotation.Secured
#Secured(value=["hasRole('ROLE_ADMIN')"])
class SecureController {
def index() {
render 'Secure access only'
}
Detailed configuration are in the oficial documentation page, updates for secured annotation in version 3, and how to define secured annotations.
By importing
import grails.plugin.springsecurity.annotation.Secured
you will be able to resolve your problem.
It will again say that it cannot resolve symbol "Secured" but you need to ignore it because the code will run completely according to your expectation.

Failed to apply gradle grails plugin after migrating Grails from 2.x to 3.x

My build.gradle file fails with below error after migrating from Grails 2.x to 3.x.
Failed to apply plugin [id 'grails']
Could not find method create() for arguments [main] on [Java source 'main:j
ava', JVM resources 'main:resources', Java source 'test:java', JVM resources 'te
st:resources'].
The apply plugin: 'grails' is defined within the subprojects task.
Build.gradle
buildscript {
repositories {
mavenLocal()
jcenter()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE")
classpath 'org.grails:grails-gradle-plugin:2.1.1'
}
}
version = projectVersion
/*
* Subprojects configuration and its tasks
*/
subprojects {
repositories {
mavenLocal()
jcenter()
maven { url "https://repo.grails.org/grails/core" }
}
/*
* Applying Plugins at subproject level
*/
apply plugin: "spring-boot"
apply plugin: 'grails'
apply plugin: "war"
apply plugin: 'eclipse'
apply plugin: 'idea'
Stacktrace
org.gradle.api.GradleScriptException: A problem occurred evaluating root project
'sample'.
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptR
unnerImpl.run(DefaultScriptRunnerFactory.java:93)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$
1.run(DefaultScriptPluginFactory.java:148)
at org.gradle.configuration.ProjectScriptTarget.addConfiguration(Project
ScriptTarget.java:72)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.
apply(DefaultScriptPluginFactory.java:153)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildSc
riptProcessor.java:38)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildSc
riptProcessor.java:25)
at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.eva
luate(ConfigureActionsProjectEvaluator.java:34)
at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(L
ifecycleProjectEvaluator.java:55)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProj
ect.java:491)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProj
ect.java:89)
at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(Task
PathProjectEvaluator.java:42)
at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuil
dConfigurer.java:35)
at org.gradle.initialization.DefaultGradleLauncher$2.run(DefaultGradleLa
uncher.java:126)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
tBuildOperationExecutor.java:90)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
tBuildOperationExecutor.java:52)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(Default
GradleLauncher.java:123)
at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGra
dleLauncher.java:33)
at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradl
eLauncher.java:100)
at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradl
eLauncher.java:94)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
tBuildOperationExecutor.java:90)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
tBuildOperationExecutor.java:62)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradle
Launcher.java:94)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLaun
cher.java:83)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildCon
troller.run(InProcessBuildActionExecuter.java:94)
at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(Exe
cuteBuildActionRunner.java:28)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildA
ctionRunner.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProce
ssBuildActionExecuter.java:43)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProce
ssBuildActionExecuter.java:28)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(Contin
uousBuildActionExecuter.java:77)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(Contin
uousBuildActionExecuter.java:47)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.exe
cute(DaemonUsageSuggestingBuildActionExecuter.java:51)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.exe
cute(DaemonUsageSuggestingBuildActionExecuter.java:28)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.jav
a:170)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.
execute(CommandLineActionFactory.java:237)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.
execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRunti
meValidationAction.java:35)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRunti
meValidationAction.java:24)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(
CommandLineActionFactory.java:206)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(
CommandLineActionFactory.java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionRep
ortingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionRep
ortingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBoots
trap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.j
ava:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to
apply plugin [id 'grails']
at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultP
luginManager.java:160)
at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPlu
ginManager.java:112)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.appl
yType(DefaultObjectConfigurationAction.java:112)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.acce
ss$200(DefaultObjectConfigurationAction.java:35)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.ru
n(DefaultObjectConfigurationAction.java:79)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.exec
ute(DefaultObjectConfigurationAction.java:135)
at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPlu
ginAware.java:46)
at build_76213vzvbmfxlviw96kj1e2w5$_run_closure2.doCall(C:\build.gradle:73)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedActi
on.java:67)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:130)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:91)
at org.gradle.api.internal.project.AbstractProject.configure(AbstractPro
ject.java:827)
at org.gradle.api.internal.project.AbstractProject.configure(AbstractPro
ject.java:832)
at org.gradle.api.internal.project.AbstractProject.subprojects(AbstractP
roject.java:815)
at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMeth
od(BeanDynamicObject.java:232)
at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObj
ect.java:127)
at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(Composite
DynamicObject.java:150)
at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:
79)
at build_76213vzvbmfxlviw96kj1e2w5.run(C:\build.gradle:
58)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptR
unnerImpl.run(DefaultScriptRunnerFactory.java:91)
... 47 more
Caused by: org.gradle.api.internal.MissingMethodException: Could not find method
create() for arguments [main] on [Java source 'main:java', JVM resources 'main:
resources', Java source 'test:java', JVM resources 'test:resources'].
at org.gradle.api.internal.AbstractDynamicObject.methodMissingException(
AbstractDynamicObject.java:68)
at org.gradle.api.internal.AbstractDynamicObject.invokeMethod(AbstractDy
namicObject.java:56)
at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(Composite
DynamicObject.java:175)
at org.gradle.language.base.internal.DefaultProjectSourceSet_Decorated.i
nvokeMethod(Unknown Source)
at org.grails.gradle.plugin.GrailsSourceSetConfigurator$1.execute(Grails
SourceSetConfigurator.groovy:36)
at org.grails.gradle.plugin.GrailsSourceSetConfigurator$1.execute(Grails
SourceSetConfigurator.groovy)
at org.gradle.listener.ActionBroadcast.execute(ActionBroadcast.java:39)
at org.gradle.api.internal.DefaultDomainObjectCollection.doAdd(DefaultDo
mainObjectCollection.java:165)
at org.gradle.api.internal.DefaultDomainObjectCollection.add(DefaultDoma
inObjectCollection.java:159)
at org.gradle.api.internal.DefaultNamedDomainObjectCollection.add(Defaul
tNamedDomainObjectCollection.java:81)
at org.gradle.api.internal.AbstractNamedDomainObjectContainer.create(Abs
tractNamedDomainObjectContainer.java:58)
at org.gradle.api.internal.AbstractNamedDomainObjectContainer.create(Abs
tractNamedDomainObjectContainer.java:52)
at org.gradle.api.internal.NamedDomainObjectContainerConfigureDelegate._
configure(NamedDomainObjectContainerConfigureDelegate.java:39)
at org.gradle.api.internal.ConfigureDelegate.invokeMethod(ConfigureDeleg
ate.java:73)
at org.grails.gradle.plugin.GrailsSourceSetConfigurator$_createMainSourc
eSet_closure1.doCall(GrailsSourceSetConfigurator.groovy:59)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedActi
on.java:67)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:130)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:91)
at org.gradle.api.internal.AbstractNamedDomainObjectContainer.configure(
AbstractNamedDomainObjectContainer.java:68)
at org.gradle.api.internal.AbstractNamedDomainObjectContainer.configure(
AbstractNamedDomainObjectContainer.java:24)
at org.gradle.api.NamedDomainObjectContainer$configure$0.call(Unknown So
urce)
at org.grails.gradle.plugin.internal.DefaultGrailsProject.sourceSets(Def
aultGrailsProject.groovy:68)
at org.grails.gradle.plugin.GrailsProject$sourceSets.call(Unknown Source
)
at org.grails.gradle.plugin.GrailsSourceSetConfigurator.createMainSource
Set(GrailsSourceSetConfigurator.groovy:58)
at org.grails.gradle.plugin.GrailsSourceSetConfigurator$createMainSource
Set$0.callCurrent(Unknown Source)
at org.grails.gradle.plugin.GrailsSourceSetConfigurator.configure(Grails
SourceSetConfigurator.groovy:50)
at org.grails.gradle.plugin.GrailsSourceSetConfigurator$configure.call(U
nknown Source)
at org.grails.gradle.plugin.GrailsPlugin.configureSourceSets(GrailsPlugi
n.groovy:154)
at org.grails.gradle.plugin.GrailsPlugin$configureSourceSets$0.callCurre
nt(Unknown Source)
at org.grails.gradle.plugin.GrailsPlugin.apply(GrailsPlugin.groovy:105)
at org.grails.gradle.plugin.GrailsPlugin.apply(GrailsPlugin.groovy)
at org.gradle.api.internal.plugins.ImperativeOnlyPluginApplicator.applyI
mperative(ImperativeOnlyPluginApplicator.java:35)
at org.gradle.api.internal.plugins.RuleBasedPluginApplicator.applyImpera
tive(RuleBasedPluginApplicator.java:43)
at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultP
luginManager.java:144)
... 66 more
Try changing (or adding) your Maven repo to:
maven { url "https://repo.grails.org/grails/repo" } (repo instead of core).
The apply plugin: 'grails' does not work with latest grails gradle plugin versions

Audit Trail Plugin installed using BuildConfig is not creating the audit columns

I am using Grails 2.2.4 and audit-trail plugin 2.0.3.
I previously installed the plugin using the deprecated "grails install-plugin" and it works. But now I try using BuildConfig. I have this configuration:
plugins {
runtime ":hibernate:$grailsVersion"
runtime ":jquery:1.8.3"
runtime ":resources:1.2"
build ":tomcat:$grailsVersion"
runtime ":database-migration:1.3.2"
compile ':cache:1.0.1'
runtime ":audit-trail:2.0.3"
runtime ":spring-security-core:1.2.7.3"
}
But now the columns for createdBy, editedBy, createdDate and editedDate are not created in the database for domain with annotation #gorm.AuditStamp
My Config.groovy has this:
grails {
plugin{
audittrail{
createdBy.field = "createdBy"
editedBy.field = "editedBy"
createdDate.field = "createdDate"
editedDate.field = "editedDate"
}
}
}
Thank you
You need to add the plugin in compile scope
compile ":audit-trail:2.0.3"
so that the AST transformation would kick in at compile time to add the configured fields to the domain class.

Where is the dependency to the jar file being set?

Sorry Grails noob here.
I am looking at a project which has some references to JUnit in its test code. I am trying to figure out how JUnit is being added to the classpath. I go to the BuildConfig.groovy file and I see no explicit reference to JUnit.
The dependencies are:
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
test "org.spockframework:spock-grails-support:0.7-groovy-2.0"
runtime 'postgresql:postgresql:9.0-801.jdbc4'
compile 'com.thoughtworks.xstream:xstream:1.4.2'
compile 'spy:spymemcached:2.8.9'
compile "org.grails:grails-webflow:$grailsVersion"
compile 'org.infinispan:infinispan-core:5.1.0.CR2'
}
The plugin dependencies are:
plugins {
test(":spock:0.7") {
exclude "spock-grails-support"
}
runtime ":jquery:1.7.2"
runtime ":resources:1.1.6"
// Uncomment these (or add new ones) to enable additional resources capabilities
//runtime ":zipped-resources:1.0"
//runtime ":cached-resources:1.0"
//runtime ":yui-minify-resources:0.1.4"
build ":tomcat:$grailsVersion"
compile ":geoip:0.2"
compile ':cache:1.0.0'
compile ":quartz:1.0-RC9"
//compile ":quartz-monitor:0.3-RC2"
compile ":grails-melody:1.45"
compile ':webflow:2.0.0', {
exclude 'grails-webflow'
}
}
So any ideas on what could be bringing in the Junit jar or how I'd find out what it is?
Thanks.
JUnit is part of the grails packaging by default. You should be able to find junit jar in lib of grails bundle which you would have downloaded from grails.org in
GRAILS_HOME\lib\junit\junit\jars
You can also verify how it is added to the project by running grails dependency-report on the project and looking for junit jar in test scope.
The latest version of junit shipped with Grails 2.2.3 is junit-4.10.

Resources