Gradle
  1. Gradle
  2. GRADLE-2620

Eclipse classpath.file.whenMerged hook breaks confusingly for non-java projects

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None

      Description

      subprojects {
        apply plugin: 'eclipse'
        eclipse.classpath.file.whenMerged { }
      }
      

      Above only works if the subproject has a JavaBase plugin applied. If not various script compile time errors occur, for example:

      Could not find method whenMerged() for arguments [build_22ci319j0o3fipj4dom75lr8dj$_run_closure2_closure4_closure5@71dd95c]

      We should look into ways of improving the dsl / error message and perhaps review the samples / docs that mention classpath.file.whenMerged feature.

      Workarounds:

      1. Apply java plugin (or some other plugin, that also applies JavaBase plugin) before applying the eclipse plugin.
      2. Use plugins.withType:

      subprojects {
        apply plugin: 'eclipse'
        plugins.withType(JavaBase) {
          //now we can manipulate the .classpath file:
          eclipse.classpath.file.whenMerged {}
        }
      }
      

        Activity

        Hide
        Gradle Forums
        added a comment -

        Can you please provide the full error message. There's a section about which object the `whenMerged()` method is actually being called on missing.

        If in doubt, please just provide the whole output.

        Show
        Gradle Forums
        added a comment - Can you please provide the full error message. There's a section about which object the `whenMerged()` method is actually being called on missing. If in doubt, please just provide the whole output.
        Hide
        Gradle Forums
        added a comment -

        Hi Luke. Here is the entire output including stack trace.

        nathan@deadveal:~/Development/Code/juzidian$ gradle eclipse --stacktrace

        FAILURE: Build failed with an exception.

        • Where:
          Build file '/home/nathan/Development/Code/juzidian/build.gradle' line: 28
        • What went wrong:
          A problem occurred evaluating root project 'juzidian'.
          > Could not find method whenMerged() for arguments [build_22ci319j0o3fipj4dom75lr8dj$_run_closure2_closure5_closure6@12d91987] on root project 'juzidian'.
        • Try:
          Run with --info or --debug option to get more log output.
        • Exception is:
          org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'juzidian'.
          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:463)
          at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:75)
          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:439)
          at org.gradle.api.internal.project.AbstractProject.allprojects(AbstractProject.java:434)
          at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
          at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:142)
          at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
          at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
          at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:38)
          at org.gradle.launcher.exec.InProcessGradleLauncherActionExecuter.execute(InProcessGradleLauncherActionExecuter.java:39)
          at org.gradle.launcher.exec.InProcessGradleLauncherActionExecuter.execute(InProcessGradleLauncherActionExecuter.java:25)
          at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
          at org.gradle.launcher.cli.ActionAdapter.execute(ActionAdapter.java:30)
          at org.gradle.launcher.cli.ActionAdapter.execute(ActionAdapter.java:22)
          at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:200)
          at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:173)
          at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
          at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:138)
          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:48)
          at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
          at org.gradle.launcher.Main.main(Main.java:39)
          at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
          at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
          at org.gradle.launcher.GradleMain.main(GradleMain.java:26)
          Caused by: org.gradle.api.internal.MissingMethodException: Could not find method whenMerged() for arguments [build_22ci319j0o3fipj4dom75lr8dj$_run_closure2_closure5_closure6@12d91987] on root project 'juzidian'.
          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.groovy.scripts.BasicScript.methodMissing(BasicScript.java:83)
          at build_22ci319j0o3fipj4dom75lr8dj$_run_closure2_closure5.doCall(/home/nathan/Development/Code/juzidian/build.gradle:28)
          at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:141)
          at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:90)
          at org.gradle.util.ConfigureUtil$configure.call(Unknown Source)
          at org.gradle.plugins.ide.eclipse.model.EclipseClasspath.file(EclipseClasspath.groovy:189)
          at org.gradle.plugins.ide.eclipse.model.EclipseClasspath_Decorated.file(Unknown Source)
          at org.gradle.plugins.ide.eclipse.model.EclipseClasspath_Decorated$file.call(Unknown Source)
          at build_22ci319j0o3fipj4dom75lr8dj$_run_closure2.doCall(/home/nathan/Development/Code/juzidian/build.gradle:27)
          at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:141)
          at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:90)
          at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:861)
          at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:866)
          at org.gradle.api.internal.project.AbstractProject.subprojects(AbstractProject.java:849)
          at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:216)
          at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:122)
          at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)
          at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:83)
          at build_22ci319j0o3fipj4dom75lr8dj.run(/home/nathan/Development/Code/juzidian/build.gradle:15)
          at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
          ... 33 more

        BUILD FAILED

        Total time: 4.847 secs

        Show
        Gradle Forums
        added a comment - Hi Luke. Here is the entire output including stack trace. nathan@deadveal:~/Development/Code/juzidian$ gradle eclipse --stacktrace FAILURE: Build failed with an exception. Where: Build file '/home/nathan/Development/Code/juzidian/build.gradle' line: 28 What went wrong: A problem occurred evaluating root project 'juzidian'. > Could not find method whenMerged() for arguments [build_22ci319j0o3fipj4dom75lr8dj$_run_closure2_closure5_closure6@12d91987] on root project 'juzidian'. Try: Run with --info or --debug option to get more log output. Exception is: org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'juzidian'. 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:463) at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:75) 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:439) at org.gradle.api.internal.project.AbstractProject.allprojects(AbstractProject.java:434) at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35) at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:142) at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113) at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81) at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:38) at org.gradle.launcher.exec.InProcessGradleLauncherActionExecuter.execute(InProcessGradleLauncherActionExecuter.java:39) at org.gradle.launcher.exec.InProcessGradleLauncherActionExecuter.execute(InProcessGradleLauncherActionExecuter.java:25) at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50) at org.gradle.launcher.cli.ActionAdapter.execute(ActionAdapter.java:30) at org.gradle.launcher.cli.ActionAdapter.execute(ActionAdapter.java:22) at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:200) at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:173) at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169) at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:138) 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:48) at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45) at org.gradle.launcher.Main.main(Main.java:39) at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50) at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32) at org.gradle.launcher.GradleMain.main(GradleMain.java:26) Caused by: org.gradle.api.internal.MissingMethodException: Could not find method whenMerged() for arguments [build_22ci319j0o3fipj4dom75lr8dj$_run_closure2_closure5_closure6@12d91987] on root project 'juzidian'. 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.groovy.scripts.BasicScript.methodMissing(BasicScript.java:83) at build_22ci319j0o3fipj4dom75lr8dj$_run_closure2_closure5.doCall(/home/nathan/Development/Code/juzidian/build.gradle:28) at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:141) at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:90) at org.gradle.util.ConfigureUtil$configure.call(Unknown Source) at org.gradle.plugins.ide.eclipse.model.EclipseClasspath.file(EclipseClasspath.groovy:189) at org.gradle.plugins.ide.eclipse.model.EclipseClasspath_Decorated.file(Unknown Source) at org.gradle.plugins.ide.eclipse.model.EclipseClasspath_Decorated$file.call(Unknown Source) at build_22ci319j0o3fipj4dom75lr8dj$_run_closure2.doCall(/home/nathan/Development/Code/juzidian/build.gradle:27) at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:141) at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:90) at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:861) at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:866) at org.gradle.api.internal.project.AbstractProject.subprojects(AbstractProject.java:849) at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:216) at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:122) at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147) at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:83) at build_22ci319j0o3fipj4dom75lr8dj.run(/home/nathan/Development/Code/juzidian/build.gradle:15) at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52) ... 33 more BUILD FAILED Total time: 4.847 secs
        Hide
        Gradle Forums
        added a comment -

        The problem is because classpath file is not generated for all projects but only for projects that have the java plugin (strictly speaking: the JavaBase plugin). To fix the problem you can:

        subprojects {
        plugins.withType(JavaBase) {
        eclipse.classpath.file {
        ...
        }
        }
        }

        The exception is not great. We should definitely improve Gradle's bahavior in this scenario. I'll create a jira ticket for it.

        Hope that helps!

        Show
        Gradle Forums
        added a comment - The problem is because classpath file is not generated for all projects but only for projects that have the java plugin (strictly speaking: the JavaBase plugin). To fix the problem you can: subprojects { plugins.withType(JavaBase) { eclipse.classpath.file { ... } } } The exception is not great. We should definitely improve Gradle's bahavior in this scenario. I'll create a jira ticket for it. Hope that helps!

          People

          • Assignee:
            Unassigned
            Reporter:
            Gradle Forums
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: