I am getting a java.lang.ClassCastException on an imported Ant build when upgrading to milestone6

I am importing an existing Ant build into Gradle. Using milestone5 the build works without any issues but using milestone6 I get a ClassCastException (stack trace below).


  • What went wrong:

Execution failed for task ‘:caplin-js-test-driver:test’.

Cause: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

  • Exception is:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ‘:caplin-js-test-driver:test’.

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.executeWithoutThrowingTaskFailure(AbstractTask.java:243)

at org.gradle.execution.DefaultTaskGraphExecuter.executeTask(DefaultTaskGraphExecuter.java:192)

at org.gradle.execution.DefaultTaskGraphExecuter.doExecute(DefaultTaskGraphExecuter.java:177)

at org.gradle.execution.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:83)

at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:36)

at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:70)

at org.gradle.execution.DefaultBuildExecuter.access$300(DefaultBuildExecuter.java:23)

at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:80)

at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)

at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:70)

at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:63)

at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:157)

at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:112)

at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:80)

at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:42)

at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:28)

at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:32)

at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:21)

at org.gradle.launcher.cli.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:233)

at org.gradle.launcher.cli.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:217)

at org.gradle.launcher.Main.doAction(Main.java:48)

at org.gradle.launcher.exec.EntryPoint$1.execute(EntryPoint.java:53)

at org.gradle.launcher.exec.EntryPoint$1.execute(EntryPoint.java:51)

at org.gradle.launcher.exec.Execution.execute(Execution.java:28)

at org.gradle.launcher.exec.EntryPoint.run(EntryPoint.java:39)

at org.gradle.launcher.Main.main(Main.java:39)

at org.gradle.launcher.ProcessBootstrap.runNoExit(ProcessBootstrap.java:51)

at org.gradle.launcher.ProcessBootstrap.run(ProcessBootstrap.java:33)

at org.gradle.launcher.GradleMain.main(GradleMain.java:24)

at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)

at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:124)

at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:53)

Caused by: /Users/andy/Documents/Caplin/Development/CT3/cutlass/caplin-js-test-driver/build.xml:409: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:116)

at org.apache.tools.ant.Task.perform(Task.java:348)

at org.apache.tools.ant.Target.execute(Target.java:390)

at org.apache.tools.ant.Target.performTasks(Target.java:411)

at org.gradle.api.tasks.ant.AntTarget.executeAntTarget(AntTarget.java:59)

at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:158)

at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:93)

at org.gradle.api.tasks.ant.AntTarget_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)

… 40 more

Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeAsForked(JUnitTask.java:1025)

at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:851)

at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeOrQueue(JUnitTask.java:1899)

at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:800)

at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)

at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)

… 51 more

BUILD FAILED --------------------------------------

The offending line, build.xml:409, and the body of the build.xml element, is:

<junit printsummary="true" haltonfailure="true" fork="true" dir="${junitWorkingDir}">
      <classpath>
        <pathelement location="${emma-bin.dir}" />
      </classpath>
      <classpath refid="emma" />
      <classpath refid="classpath" />
      <classpath refid="classpath-test" />
      <classpath>
        <pathelement location="${obj-debug.dir}" />
        <pathelement location="${obj-test.dir}" />
      </classpath>
      <jvmarg value="-Demma.coverage.out.file=${emma.dir}/test.emma" />
      <jvmarg value="-Demma.coverage.out.merge=true" />
      <formatter type="xml" usefile="true" />
      <batchtest fork="true" haltonfailure="true" todir="${junit.reports.dir}">
        <fileset dir="${src-test.dir}">
          <include name="**/*Test.java" />
        </fileset>
      </batchtest>
    </junit>

I have had a look at the breaking changes for milestone6 and havent seen anything relating to importing Ant builds. Have I missed something in the docs or has anyone else seen this exception?

Cheers, Andy

Which line is 409?

<junit printsummary="true" haltonfailure="true" fork="true" dir="${junitWorkingDir}">

I have tried removing parts of the target one at a time to figure out which bit is causing the problem.

If i remove the ‘batchtest’ part I dont see any exception - but no tests run. If I then replace this section with a single test I see the exception again. Removing any of the other arguments doesn’t make a difference.

I am also seeing the same issue when using milestone7.

Same issue with milestone8. Am I able to raise this as a bug or does someone need to do that for me?

I have a similar issue w/ 1.9-rc-3 ant version 1.9.2. Surely this is operator error or a sort?

Looking for pointers on why this occurs.

Hello same problem when trying to call [ant:junit] from gradle

java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

It does not seem to come from my ant properties passde to the junit target.

I’m using gradle 1.11