我目前正在尝试使用Gradle构建一个Grails项目,以便轻松集成一些存储库。我已经创建了一个新目录,并且从该目录我已经按照此站点的指示创建了以下build.gradle文件:
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'
}
当我尝试使用gradle init
进行构建时,我遇到了这个错误:
失败:构建因异常而失败。
其中: 构建文件'/home/ian/grailsDir/deadness/build.gradle'行:10
出了什么问题: 评估根项目“死亡”时出现问题。
找不到ID'grails'的插件。
如何获取Grails插件?我目前正在运行Grails 2.5.0和Gradle 2.4。我也尝试使用早期版本的Grails。
堆栈跟踪是:
* 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
答案 0 :(得分:3)
请注意以下代码......
dependencies {
'org.grails:grails-gradle-plugin:2.1.0'
}
......应该是:
dependencies {
classpath 'org.grails:grails-gradle-plugin:2.1.0'
}
这必须解决问题。