I have just created a grails script to create database, but the code is in Java and I thought I could use that in grails script.
This is my script
import com.test.database.* import com.test.constant.* import org.neo4j.kernel.* target(main: "The description of the script goes here!") { db = DataRepository.getInstance(new EmbeddedGraphDatabase( Constant.PROJECT_PATH + "/web-app/WEB-INF/resources/db")) } setDefaultTarget(main)
And my java classes are in src/java, but when I run the script I got this error
Error executing script DbCreate: No such property: DataRepository for class: DbCreate No such property: DataRepository for class: DbCreate at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:387) at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415) at gant.Gant$_dispatch_closure7.doCall(Gant.groovy) at gant.Gant.withBuildListeners(Gant.groovy:427) at gant.Gant.this$2$withBuildListeners(Gant.groovy) at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source) at gant.Gant.dispatch(Gant.groovy:415) at gant.Gant.this$2$dispatch(Gant.groovy) at gant.Gant.invokeMethod(Gant.groovy) at gant.Gant.executeTargets(Gant.groovy:590) at gant.Gant.executeTargets(Gant.groovy:589) Caused by: groovy.lang.MissingPropertyException: No such property: DataRepository for class: DbCreate at DbCreate$_run_closure1.doCall(DbCreate:11) at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
My question would be could I call user-defined java classes in grails script?