title: Gradle "Could not find method compile() for arguments" for Guava
body: <p>Iv'e looked at the other "Could not find method compile() for arguments" questions here but found nothing to help me.</p>
  
  <p>I'm using the Buildship plugin for eclipse to import a Gradle project. This is <code>build.gradle</code>:</p>
  
  <pre><code>repositories {
      mavenCentral()
  }
  
  dependencies {
      compile group: 'com.google.guava', name: 'guava', version: '20.0'
  }
  </code></pre>
  
  <p>as described in <a href="https://github.com/google/guava/wiki/UseGuavaInYourBuild" rel="nofollow noreferrer">https://github.com/google/guava/wiki/UseGuavaInYourBuild</a>. I use the wizard to import the project and get the following error (full stack trace here):</p>
  
  <pre><code> Loading Gradle project preview failed due to an error in the referenced Gradle build. Could not fetch model of type 'GradleBuild' using Gradle distribution
   'https://services.gradle.org/distributions/gradle-3.1-bin.zip'.
  
   Build file 'C:\Path\To\Project\ProjectName\build.gradle'
   line: 6 A problem occurred evaluating root project 'ProjectName'.
   Could not find method compile() for arguments
   [{group=com.google.guava, name=guava, version=20.0}] on object of type
   org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
   org.gradle.tooling.BuildException: Could not fetch model of type
   'GradleBuild' using Gradle distribution
   'https://services.gradle.org/distributions/gradle-3.1-bin.zip'.    at
   org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:51)
      at
   org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:29)
      at
   org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:41)
      at
   org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
      at
   org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
      at
   org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)     at
   org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
      at
   org.gradle.tooling.internal.consumer.DefaultModelBuilder.get(DefaultModelBuilder.java:51)
      at
   com.gradleware.tooling.toolingclient.internal.DefaultToolingClient.executeAndWait(DefaultToolingClient.java:106)
      at
   com.gradleware.tooling.toolingclient.internal.DefaultModelRequest.executeAndWait(DefaultModelRequest.java:79)
      at
   com.gradleware.tooling.toolingmodel.repository.internal.BaseModelRepository$1.get(BaseModelRepository.java:95)
      at
   com.gradleware.tooling.toolingmodel.repository.internal.BaseModelRepository.executeAndWait(BaseModelRepository.java:163)
      at
   com.gradleware.tooling.toolingmodel.repository.internal.BaseModelRepository.access$000(BaseModelRepository.java:41)
      at
   com.gradleware.tooling.toolingmodel.repository.internal.BaseModelRepository$2.call(BaseModelRepository.java:121)
      at
   com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4724)
      at
   com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3522)
      at
   com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2315)
      at
   com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2278)
      at
   com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2193)
      at com.google.common.cache.LocalCache.get(LocalCache.java:3932)     at
   com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4721)
      at
   com.gradleware.tooling.toolingmodel.repository.internal.BaseModelRepository.getFromCache(BaseModelRepository.java:138)
      at
  com.gradleware.tooling.toolingmodel.repository.internal.BaseModelRepository.executeRequest(BaseModelRepository.java:117)
      at
   com.gradleware.tooling.toolingmodel.repository.internal.BaseModelRepository.executeRequest(BaseModelRepository.java:88)
      at
   com.gradleware.tooling.toolingmodel.repository.internal.DefaultSingleBuildModelRepository.fetchGradleBuildStructure(DefaultSingleBuildModelRepository.java:132)
      at
   org.eclipse.buildship.core.projectimport.ProjectPreviewJob.fetchGradleBuildStructure(ProjectPreviewJob.java:94)
      at
   org.eclipse.buildship.core.projectimport.ProjectPreviewJob.runToolingApiJobInWorkspace(ProjectPreviewJob.java:83)
      at
   org.eclipse.buildship.core.util.progress.ToolingApiWorkspaceJob$1.run(ToolingApiWorkspaceJob.java:79)
      at
   org.eclipse.buildship.core.util.progress.ToolingApiInvoker.invoke(ToolingApiInvoker.java:63)
      at
   org.eclipse.buildship.core.util.progress.ToolingApiWorkspaceJob.runInWorkspace(ToolingApiWorkspaceJob.java:76)
      at
   org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:39)
      at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55) Caused
   by: org.gradle.internal.exceptions.LocationAwareException: Build file
   'C:\Users\Nir\git\Sanctorum\GameClientLogic\build.gradle' line: 6 A
   problem occurred evaluating root project 'GameClientLogic'.    at
   org.gradle.initialization.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:74)
      at
   org.gradle.initialization.MultipleBuildFailuresExceptionAnalyser.transform(MultipleBuildFailuresExceptionAnalyser.java:47)
      at
   org.gradle.initialization.StackTraceSanitizingExceptionAnalyser.transform(StackTraceSanitizingExceptionAnalyser.java:30)
      at
   org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:114)
      at
   org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:106)
      at
   org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
      at
  org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63)
      at
   org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
      at
   org.gradle.initialization.DefaultGradleLauncher.getBuildAnalysis(DefaultGradleLauncher.java:97)
      at
   org.gradle.launcher.exec.GradleBuildController.configure(GradleBuildController.java:74)
      at
   org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:48)
      at
   org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
      at
   org.gradle.tooling.internal.provider.runner.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:58)
      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:26)
      at
   org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:79)
      at
   org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:51)
      at
   org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:59)
      at
   org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
      at
   org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
      at
   org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:47)
      at
   org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
      at
   org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
      at
   org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
      at
   org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
      at
   org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
      at
   org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
      at
   org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
      at org.gradle.util.Swapper.swap(Swapper.java:38)    at
   org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
      at
   org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
      at
   org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
      at
   org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
      at
   org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
      at
   org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
      at
   org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
      at
   org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
      at
   org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
      at
   org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
      at
   org.gradle.launcher.daemon.server.exec.HintGCAfterBuild.execute(HintGCAfterBuild.java:44)
      at
   org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
      at
   org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
      at
   org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:293)
      at
   org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
      at
   org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
   Caused by: org.gradle.api.GradleScriptException: A problem occurred
   evaluating root project 'GameClientLogic'.     at
   org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:92)
      at
   org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$2.run(DefaultScriptPluginFactory.java:176)
      at
   org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:77)
      at
   org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:181)
      at
   org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:38)
      at
   org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:25)
      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.DefaultProject.evaluate(DefaultProject.java:573)
      at
   org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:125)
      at
   org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42)
      at
   org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:38)
      at
   org.gradle.initialization.DefaultGradleLauncher$2.run(DefaultGradleLauncher.java:151)
      at org.gradle.internal.Factories$1.create(Factories.java:22)    at
   org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
      at
   org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:53)
      at
   org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:148)
      at
   org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:33)
      at
   org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:112)
      ... 42 more Caused by:
   org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException:
   Could not find method compile() for arguments
   [{group=com.google.guava, name=guava, version=19.0}] on object of type
   org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
      at
   org.gradle.internal.metaobject.AbstractDynamicObject.methodMissingException(AbstractDynamicObject.java:182)
      at
   org.gradle.internal.metaobject.ConfigureDelegate.invokeMethod(ConfigureDelegate.java:89)
      at
   build_7qq3tniyxfzuiosj6471fjclb$_run_closure2.doCall(C:\Users\Nir\git\Sanctorum\GameClientLogic\build.gradle:6)
      at
   org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:70)
      at
   org.gradle.util.ConfigureUtil.configureTarget(ConfigureUtil.java:160)
      at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:106)
      at
   org.gradle.api.internal.project.DefaultProject.dependencies(DefaultProject.java:940)
      at
   org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:382)
      at
   org.gradle.internal.metaobject.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:170)
      at
   org.gradle.internal.metaobject.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:96)
      at
   org.gradle.internal.metaobject.MixInClosurePropertiesAsMethodsDynamicObject.invokeMethod(MixInClosurePropertiesAsMethodsDynamicObject.java:30)
      at
   org.gradle.internal.metaobject.AbstractDynamicObject.invokeMethod(AbstractDynamicObject.java:163)
      at
   org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:83)
      at
   build_7qq3tniyxfzuiosj6471fjclb.run(C:\Users\Nir\git\Sanctorum\GameClientLogic\build.gradle:5)
      at
   org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:90)
  </code></pre>
  
  <hr>
  
  <pre><code>... 60 more
  </code></pre>
  
  <p>I don't understand what's the problem. I just copy-pasted the lines and this is a simple Java project. Currently I am using Eclipse to add the Guava jar to the Java build path and use it this way. But because this project will add another project dependency and itself be a dependency I rather let Gradle handle the transitive dependencies as described in its user guide.</p>