我正在尝试在我的项目中使用Gradle Cargo插件。
这是我的build.gradle:
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'war'
apply plugin: 'jetty'
apply plugin: 'cargo'
sourceCompatibility = 1.7
version = '1.0'
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'org.gradle.api.plugins:gradle-cargo-plugin:1.4'
}
}
ext.springVersion = '4.0.2.RELEASE';
ext.jerseyVersion = '2.6';
ext.jettyVersion = '9.1.3.v20140225';
httpPort = 8099;
def springDependencies = ["org.springframework:spring-core:$springVersion",
"org.springframework:spring-beans:$springVersion",
"org.springframework:spring-context:$springVersion",
"org.springframework:spring-web:$springVersion",
"org.springframework:spring-webmvc:$springVersion"]
def jettyDependencies = ["org.eclipse.jetty:jetty-server:$jettyVersion",
"org.eclipse.jetty:jetty-servlet:$jettyVersion"]
def jerseyDependencies = ["org.glassfish.jersey.containers:jersey-container-servlet:$jerseyVersion",
'javax.ws.rs:javax.ws.rs-api:2.0']
ext.libs = [
springDependencies : springDependencies,
jerseyDependencies : jerseyDependencies,
guava: 'com.google.guava:guava:16.0.1',
junit: 'junit:junit:4.11'
]
dependencies {
compile springDependencies;
compile jerseyDependencies;
compile("org.glassfish.jersey.ext:jersey-spring3:$jerseyVersion"){
exclude group: 'org.springframework'
};
compile libs.guava;
testCompile libs.junit;
}
在刷新依赖项时,我收到以下错误:org.gradle.api.internal.MissingMethodException: Could not find method jcenter() for arguments [] on repository container
。
以下是完整的堆栈跟踪:
FAILURE: Build failed with an exception.
* Where:
Build file 'E:\Workspaces\TestProjects\springjerseygradle\build.gradle' line: 17
* What went wrong:
A problem occurred evaluating root project 'springjerseygradle'.
> Could not find method jcenter() for arguments [] on repository container.
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'springjerseygradle'.
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:54)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:116)
at org.gradle.configuration.BuildScriptProcessor.evaluate(BuildScriptProcessor.java:38)
at org.gradle.configuration.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:44)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:464)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:77)
at org.gradle.configuration.DefaultBuildConfigurer$ConfigureProject.execute(DefaultBuildConfigurer.java:38)
at org.gradle.configuration.DefaultBuildConfigurer$ConfigureProject.execute(DefaultBuildConfigurer.java:36)
at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:440)
at org.gradle.api.internal.project.AbstractProject.allprojects(AbstractProject.java:435)
at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:32)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:142)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
at org.gradle.initialization.DefaultGradleLauncher.getBuildAnalysis(DefaultGradleLauncher.java:92)
at org.gradle.tooling.internal.provider.BuildModelAction.run(BuildModelAction.java:73)
at org.gradle.tooling.internal.provider.DelegatingBuildModelAction.run(DelegatingBuildModelAction.java:44)
at org.gradle.tooling.internal.provider.ConfiguringBuildAction.run(ConfiguringBuildAction.java:103)
at org.gradle.launcher.exec.InProcessGradleLauncherActionExecuter.execute(InProcessGradleLauncherActionExecuter.java:39)
at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:45)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:42)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:33)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnResult.java:34)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:70)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:68)
at org.gradle.util.Swapper.swap(Swapper.java:38)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:68)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:59)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:45)
at org.gradle.launcher.daemon.server.DaemonStateCoordinator.runCommand(DaemonStateCoordinator.java:186)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy.doBuild(StartBuildOrRespondWithBusy.java:49)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
at org.gradle.launcher.daemon.server.exec.HandleStop.execute(HandleStop.java:36)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailure.execute(CatchAndForwardDaemonFailure.java:32)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
at org.gradle.launcher.daemon.server.exec.DefaultDaemonCommandExecuter.executeCommand(DefaultDaemonCommandExecuter.java:48)
at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.handleCommand(DefaultIncomingConnectionHandler.java:155)
at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.receiveAndHandleCommand(DefaultIncomingConnectionHandler.java:128)
at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.run(DefaultIncomingConnectionHandler.java:116)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
Caused by: org.gradle.api.internal.MissingMethodException: Could not find method jcenter() for arguments [] on repository container.
at org.gradle.api.internal.AbstractDynamicObject.methodMissingException(AbstractDynamicObject.java:68)
at org.gradle.api.internal.AbstractDynamicObject.invokeMethod(AbstractDynamicObject.java:56)
at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:172)
at org.gradle.api.internal.artifacts.dsl.DefaultRepositoryHandler_Decorated.invokeMethod(Unknown Source)
at build_5ru6nl8ep0dulqvskgg5mshf5d$_run_closure1_closure2.doCall(E:\Workspaces\TestProjects\springjerseygradle\build.gradle:17)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:58)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:133)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:113)
at org.gradle.api.internal.artifacts.DefaultArtifactRepositoryContainer.configure(DefaultArtifactRepositoryContainer.java:76)
at org.gradle.api.internal.artifacts.DefaultArtifactRepositoryContainer.configure(DefaultArtifactRepositoryContainer.java:44)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:50)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:133)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:94)
at org.gradle.api.internal.initialization.AbstractScriptHandler.repositories(AbstractScriptHandler.java:66)
at build_5ru6nl8ep0dulqvskgg5mshf5d$_run_closure1.doCall(E:\Workspaces\TestProjects\springjerseygradle\build.gradle:15)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:58)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:133)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:94)
at org.gradle.api.internal.project.AbstractProject.buildscript(AbstractProject.java:893)
at org.gradle.api.Project$buildscript.call(Unknown Source)
at org.gradle.api.Project$buildscript.call(Unknown Source)
at org.gradle.api.internal.project.ProjectScript.buildscript(ProjectScript.groovy:42)
at org.gradle.api.Script$buildscript.callCurrent(Unknown Source)
at build_5ru6nl8ep0dulqvskgg5mshf5d.run(E:\Workspaces\TestProjects\springjerseygradle\build.gradle:14)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
... 53 more
BUILD FAILED
Total time: 3.53 secs
以下是环境细节: Eclipse版本:Juno Service Release 2, 已安装的Gradle版本:1.11, 用于Eclipse的Gradle Integration的SpringSource更新站点: Link
在this post中,提到问题在于旧版本的gradle。但我已经在使用最新版本的Gradle。我在这里错过了什么?