Eclipse Plugin: task "eclipseProject" not overwritable

eclipse
plugins
not-a-bug

(Mike Meessen) #1

Gradle Version: 3.0
Operating System: Windows 7
Is this a regression? If yes, which version of Gradle do you know it last worked for? Not sure, this used to work at one point.

According to the Gradle documentation, it looks as if it should be possible to overwrite (or “replace”) any task: https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:replacing_tasks

However, it looks like it’s impossible to overwrite the eclipseProject task.

If I create a basic buildfile like this:

apply plugin: 'eclipse'

task eclipseProject(overwrite:true) {
    description = "Disabled."
}

and just execute gradle tasks, I immediately get the following error:

FAILURE: Build failed with an exception.

* What went wrong:
Cannot cast object 'task ':eclipseProject'' with class 'org.gradle.api.DefaultTask_Decorated' to class 'org.gradle.p
lugins.ide.eclipse.GenerateEclipseProject'

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'task ':eclipseProject'' with class
 'org.gradle.api.DefaultTask_Decorated' to class 'org.gradle.plugins.ide.eclipse.GenerateEclipseProject'
        at org.gradle.plugins.ide.eclipse.internal.EclipseNameDeduper$_configureRoot_closure2.doCall(EclipseNameDeduper.groovy:32)
        at org.gradle.plugins.ide.internal.configurer.ProjectDeduper$_dedupe_closure2.doCall(ProjectDeduper.groovy:33)
        at org.gradle.plugins.ide.internal.configurer.ProjectDeduper$_dedupe_closure2.call(ProjectDeduper.groovy)
        at org.gradle.plugins.ide.internal.configurer.ProjectDeduper.dedupe(ProjectDeduper.groovy:33)
        at org.gradle.plugins.ide.eclipse.internal.EclipseNameDeduper.configureRoot(EclipseNameDeduper.groovy:30)
        at org.gradle.plugins.ide.eclipse.EclipsePlugin.makeSureProjectNamesAreUnique(EclipsePlugin.groovy:101)
        at org.gradle.plugins.ide.eclipse.EclipsePlugin$1.doCall(EclipsePlugin.groovy:94)
        at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:40)
        at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25)
        at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:44)
        at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:79)
        at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:30)
        at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
        at com.sun.proxy.$Proxy11.projectsEvaluated(Unknown Source)
        at org.gradle.initialization.DefaultGradleLauncher$2.run(DefaultGradleLauncher.java:127)
        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:121)
        at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
        at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:98)
        at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:92)
        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:92)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:83)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:99)
        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:48)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:30)
        at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:81)
        at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:46)
        at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51)
        at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28)
        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
        at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:173)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:239)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:212)
        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.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:205)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
        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:55)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:36)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:23)


BUILD FAILED

(Stefan Wolf) #2

Hi Mike,

thanks you for reporting. You did overwrite the task, but now the eclipse plugin tries to use it and it assumes the task with this name is of type GenerateEclipseProject. This is why the build fails.

Cheers,
Stefan