[GRADLE-2049] Tooling API: Provide support for 'allpojects' processing Created: 16/Jan/12 Updated: 04/Jan/13 Resolved: 16/Jan/12 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | 1.0-milestone-7 |
Fix Version/s: | None |
Type: | Bug | ||
Reporter: | Denis Zhdanov | Assignee: | Unassigned |
Resolution: | Not A Bug | Votes: | 0 |
Description |
#Change '$GRADLE_HOME/samples/java/multiproject/build.gradle' as follows subprojects { apply plugin: 'java' apply plugin: 'eclipse-wtp' repositories { mavenCentral() } version = '1.0' jar { manifest.attributes provider: 'gradle' } } allprojects { dependencies { testCompile group: 'junit', name: 'junit', version: '4.+' testCompile group: 'org.mockito', name: 'mockito-core', version: '1.9.0' } } Run the program below: package org.jetbrains.plugins.gradle; import org.gradle.tooling.GradleConnector; import org.gradle.tooling.ModelBuilder; import org.gradle.tooling.ProjectConnection; import org.gradle.tooling.model.idea.IdeaDependency; import org.gradle.tooling.model.idea.IdeaModule; import org.gradle.tooling.model.idea.IdeaProject; import java.io.File; /** * @author Denis Zhdanov * @since 12/8/11 5:07 PM */ public class GradleStartClass { private static final String GRADLE_TO_USE = "/home/denis/dev/gradle/gradle-1.0-milestone-7"; private static final String GRADLE_PROJECT_PATH = "/home/denis/dev/gradle/gradle-1.0-milestone-7/samples/java/multiproject"; public static void main(String[] args) { showDependencies(); } private static void showDependencies() { GradleConnector connector = GradleConnector.newConnector(); connector.useInstallation(new File(GRADLE_TO_USE)); connector.forProjectDirectory(new File(GRADLE_PROJECT_PATH)); ProjectConnection connection = connector.connect(); ModelBuilder<? extends IdeaProject> modelBuilder = connection.model(IdeaProject.class); IdeaProject project = modelBuilder.get(); System.out.println("-----------------> Listing modules <----------------"); for (IdeaModule module : project.getModules()) { System.out.printf(" -----------------> Module %s <----------------%n", module.getName()); for (IdeaDependency dependency : module.getDependencies()) { System.out.printf("Dependency: %s, scope: %s%n", dependency, dependency.getScope()); } } System.out.println("-----------------> Finishing <----------------"); } } Expected: get the dependencies correctly listed Exception in thread "main" org.gradle.tooling.BuildException: Could not fetch model of type 'IdeaProject' using Gradle installation '/home/denis/dev/gradle/gradle-1.0-milestone-7'. at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:44) at org.gradle.tooling.internal.consumer.DefaultAsyncConnection$3.run(DefaultAsyncConnection.java:73) at org.gradle.messaging.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) Caused by: org.gradle.api.LocationAwareException: Build file '/home/denis/dev/gradle/gradle-1.0-milestone-7/samples/java/multiproject/build.gradle' line: 18 A problem occurred evaluating root project 'multiproject'. at org.gradle.initialization.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:85) at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:110) at org.gradle.initialization.DefaultGradleLauncher.getBuildAnalysis(DefaultGradleLauncher.java:87) at org.gradle.tooling.internal.provider.BuildModelAction.run(BuildModelAction.java:46) at org.gradle.tooling.internal.provider.DelegatingBuildModelAction.run(DelegatingBuildModelAction.java:42) at org.gradle.tooling.internal.provider.ConfiguringBuildAction.run(ConfiguringBuildAction.java:63) at org.gradle.launcher.daemon.protocol.Build.run(Build.java:67) at org.gradle.launcher.daemon.protocol.Build.run(Build.java:63) 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:122) at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:45) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailureAsResult.execute(CatchAndForwardDaemonFailureAsResult.java:24) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnResult.java:32) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.ForwardClientInput$4.call(ForwardClientInput.java:112) at org.gradle.launcher.daemon.server.exec.ForwardClientInput$4.call(ForwardClientInput.java:110) at org.gradle.util.Swapper.swap(Swapper.java:38) at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:110) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:47) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:48) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy.doBuild(StartBuildOrRespondWithBusy.java:37) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.HandleStop.execute(HandleStop.java:34) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailure.execute(CatchAndForwardDaemonFailure.java:34) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.HandleClientDisconnectBeforeSendingCommand.execute(HandleClientDisconnectBeforeSendingCommand.java:21) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.StopConnectionAfterExecution.execute(StopConnectionAfterExecution.java:22) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.DefaultDaemonCommandExecuter.executeCommand(DefaultDaemonCommandExecuter.java:49) at org.gradle.launcher.daemon.server.Daemon$1$1.run(Daemon.java:113) ... 4 more Caused by: org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'multiproject'. at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:54) at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:127) at org.gradle.configuration.BuildScriptProcessor.evaluate(BuildScriptProcessor.java:38) at org.gradle.configuration.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:43) at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:475) at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:74) at org.gradle.configuration.ProjectEvaluationConfigurer.execute(ProjectEvaluationConfigurer.java:23) at org.gradle.configuration.ProjectEvaluationConfigurer.execute(ProjectEvaluationConfigurer.java:21) at org.gradle.configuration.DefaultBuildConfigurer$1.execute(DefaultBuildConfigurer.java:38) at org.gradle.configuration.DefaultBuildConfigurer$1.execute(DefaultBuildConfigurer.java:35) at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:451) at org.gradle.api.internal.project.AbstractProject.allprojects(AbstractProject.java:446) at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35) at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:137) at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:108) at org.gradle.initialization.DefaultGradleLauncher.getBuildAnalysis(DefaultGradleLauncher.java:87) at org.gradle.tooling.internal.provider.BuildModelAction.run(BuildModelAction.java:46) at org.gradle.tooling.internal.provider.DelegatingBuildModelAction.run(DelegatingBuildModelAction.java:42) at org.gradle.tooling.internal.provider.ConfiguringBuildAction.run(ConfiguringBuildAction.java:63) at org.gradle.launcher.daemon.protocol.Build.run(Build.java:67) at org.gradle.launcher.daemon.protocol.Build.run(Build.java:63) 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:122) at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:45) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailureAsResult.execute(CatchAndForwardDaemonFailureAsResult.java:24) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnResult.java:32) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.ForwardClientInput$4.call(ForwardClientInput.java:112) at org.gradle.launcher.daemon.server.exec.ForwardClientInput$4.call(ForwardClientInput.java:110) at org.gradle.util.Swapper.swap(Swapper.java:38) at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:110) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:47) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:48) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy.doBuild(StartBuildOrRespondWithBusy.java:37) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.HandleStop.execute(HandleStop.java:34) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailure.execute(CatchAndForwardDaemonFailure.java:34) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.HandleClientDisconnectBeforeSendingCommand.execute(HandleClientDisconnectBeforeSendingCommand.java:21) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.StopConnectionAfterExecution.execute(StopConnectionAfterExecution.java:22) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.DefaultDaemonCommandExecuter.executeCommand(DefaultDaemonCommandExecuter.java:49) at org.gradle.launcher.daemon.server.Daemon$1$1.run(Daemon.java:113) at org.gradle.messaging.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64) Caused by: groovy.lang.MissingMethodException: No signature of method: org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.testCompile() is applicable for argument types: (java.util.LinkedHashMap) values: [[group:junit, name:junit, version:4.+]] at org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.methodMissing(DefaultDependencyHandler.groovy:94) at org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.invokeMethod(DefaultDependencyHandler.groovy) at build_ksff4bq5ve7pr0j5c7ardgfs4$_run_closure2_closure5.doCall(/home/denis/dev/gradle/gradle-1.0-milestone-7/samples/java/multiproject/build.gradle:18) at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:136) at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:85) at org.gradle.api.internal.project.AbstractProject.dependencies(AbstractProject.java:885) at build_ksff4bq5ve7pr0j5c7ardgfs4$_run_closure2.doCall(/home/denis/dev/gradle/gradle-1.0-milestone-7/samples/java/multiproject/build.gradle:17) at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:136) at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:85) at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:866) at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:871) at org.gradle.api.internal.project.AbstractProject.allprojects(AbstractProject.java:858) at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:158) at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:93) at org.gradle.api.internal.project.DefaultProject_Decorated.invokeMethod(Unknown Source) at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.groovy:72) at build_ksff4bq5ve7pr0j5c7ardgfs4.run(/home/denis/dev/gradle/gradle-1.0-milestone-7/samples/java/multiproject/build.gradle:16) at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52) ... 56 more |
Comments |
Comment by Adam Murdoch [ 16/Jan/12 ] |
This build will also fail if you run it with 'gradle' from the command-line. That is, it's not a problem with the tooling API. It's failing because allprojects is applied to the root project in addition to the subprojects, however the root project does not have the java plugin applied to it, and so does not have a testCompile configuration defined. You might, for example, change the 'subprojects' to 'allprojects' in your example. |
Comment by Szczepan Faber [ 16/Jan/12 ] |
Though, the error message should say something like "xxx configuration not found. You forgot to declare it or you didn't apply the plugin that declares this configuration", etc. Denis, I closed this bug but let us know if there's something we're missing. |
Comment by Denis Zhdanov [ 16/Jan/12 ] |
Cool, sorry, forgot to check that from the command line. |