[GRADLE-1666] ClassCastException in eclipse plugin, BigDecimal to org.gradle.api.JavaVersion Created: 06/Jul/11  Updated: 04/Jan/13  Resolved: 22/Jul/11

Status: Resolved
Project: Gradle
Affects Version/s: 1.0-milestone-3
Fix Version/s: None

Type: Bug
Reporter: Philip Crotwell Assignee: Szczepan Faber
Resolution: Duplicate Votes: 0


 Description   

Looks like the eclipse plugin is havign trouble with my version string. I'll admit it is a bit on the long side, but as far as I know there is not a restriction on the format of the version string.

crotwell$ cat build.gradle
group = "edu.sc.seis"
version = "2.0beta10_localMod"
sourceCompatibility = 1.5

apply plugin: 'java'
apply plugin: 'eclipse'

repositories

{ flatDir name: 'localRepository', dirs: 'lib' mavenRepo urls: "http://www.seis.sc.edu/software/maven2" mavenCentral() }

defaultTasks "clean", "jar"

dependencies

{ compile "org.slf4j:slf4j-log4j12:1.6.1" compile "edu.sc.seis:seisFile:1.2" compile "jython:jython:2.5.1" testCompile "junit:junit:4.8.1" }

crotwell$ gradle --stacktrace eclipse
:eclipseClasspath
:eclipseJdt

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':eclipseJdt'.
    Cause: java.math.BigDecimal cannot be cast to org.gradle.api.JavaVersion
  • Try:
    Run with --info or --debug option to get more log output.
  • Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':eclipseJdt'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:71)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:48)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:34)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:55)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:57)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:41)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:42)
    at org.gradle.api.internal.AbstractTask.execute(AbstractTask.java:237)
    at org.gradle.execution.DefaultTaskGraphExecuter.executeTask(DefaultTaskGraphExecuter.java:167)
    at org.gradle.execution.DefaultTaskGraphExecuter.doExecute(DefaultTaskGraphExecuter.java:160)
    at org.gradle.execution.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:78)
    at org.gradle.execution.TaskNameResolvingBuildExecuter.execute(TaskNameResolvingBuildExecuter.java:113)
    at org.gradle.execution.DelegatingBuildExecuter.execute(DelegatingBuildExecuter.java:54)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:158)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:112)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:80)
    at org.gradle.launcher.RunBuildAction.execute(RunBuildAction.java:41)
    at org.gradle.launcher.RunBuildAction.execute(RunBuildAction.java:27)
    at org.gradle.launcher.ExceptionReportingAction.execute(ExceptionReportingAction.java:32)
    at org.gradle.launcher.ExceptionReportingAction.execute(ExceptionReportingAction.java:21)
    at org.gradle.launcher.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:219)
    at org.gradle.launcher.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:203)
    at org.gradle.launcher.Main.execute(Main.java:55)
    at org.gradle.launcher.Main.main(Main.java:40)
    at org.gradle.launcher.ProcessBootstrap.runNoExit(ProcessBootstrap.java:46)
    at org.gradle.launcher.ProcessBootstrap.run(ProcessBootstrap.java:28)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:24)
    Caused by: java.lang.ClassCastException: java.math.BigDecimal cannot be cast to org.gradle.api.JavaVersion
    at org.gradle.plugins.ide.eclipse.model.EclipseJdt_Decorated.getSourceCompatibility(Unknown Source)
    at org.gradle.api.internal.BeanDynamicObject.getProperty(BeanDynamicObject.java:86)
    at org.gradle.api.internal.CompositeDynamicObject.getProperty(CompositeDynamicObject.java:51)
    at org.gradle.plugins.ide.eclipse.model.EclipseJdt_Decorated.getProperty(Unknown Source)
    at org.gradle.plugins.ide.eclipse.GenerateEclipseJdt$1.configure(GenerateEclipseJdt.groovy:63)
    at org.gradle.plugins.ide.eclipse.GenerateEclipseJdt$1.configure(GenerateEclipseJdt.groovy)
    at org.gradle.plugins.ide.api.GeneratorTask.generate(GeneratorTask.java:69)
    at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:158)
    at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:93)
    at org.gradle.plugins.ide.eclipse.GenerateEclipseJdt_Decorated.invokeMethod(Unknown Source)
    at org.gradle.util.ReflectionUtil.invoke(ReflectionUtil.groovy:23)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$2.execute(AnnotationProcessingTaskFactory.java:129)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$2.execute(AnnotationProcessingTaskFactory.java:127)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:63)
    ... 28 more

BUILD FAILED

Total time: 6.425 secs



 Comments   
Comment by Szczepan Faber [ 22/Jul/11 ]

The reason for the exception is that you're assigning a convention property (sourceCompatibility) before java plugin is applied. At this moment you cannot do it in Gradle, see issue: GRADLE-1350

Therefore I'm closing this issue as a duplicate. Once GRADLE-1350 is fixed your code will work just fine.

Also, you might want to move all the assignments of java plugin convention properties after the plugin is applied.

Hope that helps

Generated at Wed Jun 30 12:01:21 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.