Javaexec class cast exception


(Sean McCauliff) #1

I’m trying to run a Java program that is compiled in buildSrc.

When I do this I get the following exception. I’m probably doing something wrong, but I can’t see it.

Any help would be appreciated.

Thanks, Sean

Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object ‘gov.nasa.spiffy.adb.storage’ with class ‘java.lang.String’ to class ‘int’

at build_6krosm9dmir4n4qsdh7r0boie2$_run_closure14_closure24.doCall(/home/smccauli/TESS/gitroot/tess/spoc/code/spiffy/build.gradle:209)

at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:59)

at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:130)

at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:91)

at org.gradle.api.internal.file.DefaultFileOperations.javaexec(DefaultFileOperations.java:158)

at org.gradle.api.internal.project.AbstractProject.javaexec(AbstractProject.java:749)

at org.gradle.groovy.scripts.DefaultScript.javaexec(DefaultScript.java:182)

at build_6krosm9dmir4n4qsdh7r0boie2$_run_closure14.doCall(/home/smccauli/TESS/gitroot/tess/spoc/code/spiffy/build.gradle:204)

at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:539)

at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:520)

at org.gradle.api.internal.tasks.TaskMutator$1.execute(TaskMutator.java:77)

at org.gradle.api.internal.tasks.TaskMutator$1.execute(TaskMutator.java:73)

at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)

at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61) pi.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:502) [stack trace truncated]

compileJava <<
{
      javaexec {
        println("XML SCHEMA!")
                  main "gov.nasa.tess.buildutil.JaxbSchemaGenerator"
        classpath "$projectDir/../../buildSrc/build/classes/main"
        args ["gov.nasa.spiffy.adb.storage","$buildDir/classes/main/fsidlocator.xsd"]
    }
}

Gradle version information: Gradle 2.0 ------------------------------------------------------------

Build time:

2014-07-01 07:45:34 UTC Build number: none Revision:

b6ead6fa452dfdadec484059191eb641d817226c

Groovy:

2.3.3 Ant:

Apache Ant™ version 1.9.3 compiled on December 23 2013 JVM:

1.8.0 (Oracle Corporation 25.0-b70) OS:

Linux 2.6.32-431.3.1.el6.x86_64 amd64 This is CentOS 6.5


(Sean McCauliff) #2

It’s not clear to me when different forms of assignment (spaces, =, or :slight_smile: and which types are required.

I was only able to figure this out by looking at the gradle source code. Thanks for making that available.

compileJava <<
{
      javaexec {
                  main = "gov.nasa.tess.buildutil.JaxbSchemaGenerator"
        classpath = files("$projectDir/../../buildSrc/build/classes/main")
        args = ["gov.nasa.spiffy.adb.storage","$buildDir/classes/main/fsidlocator.xsd"]
    }
}

(Peter Niederwieser) #3

It’s ‘args = [“foo”, “bar”]’, or ‘args “foo”, “bar”’, but not ‘args [“foo”, “bar”]’. The latter will try to index into the value returned by ‘args’.