Hello Robin
I wonder if there's a way to create global class object for one build.
I tried to use "pre-build" script in the advanced settings, and I declared a class with the following code
groovy:
class Foo {
String name
Integer age
def setAge(Integer years) {
this.age = years
}
def increaseAge(Integer years) {
this.age += years
}
def printAge() {
println this.age
}
}
So I was hoping that I could do def f = new Foo()
in any step with groovy, but instead, I get this configuration error before the build can even run:
java.lang.RuntimeException: Failed to evaluate below expression in configuration 'root/my/path/test':
groovy:
class Foo {
String name
Integer age
def setAge(Integer years) {
this.age = years
}
def increaseAge(Integer years) {
this.age += years
}
def printAge() {
println this.age
}
}
at com.pmease.quickbuild.util.ExceptionUtils.wrapException(ExceptionUtils.java:87)
at com.pmease.quickbuild.DefaultScriptEngine.evaluate(DefaultScriptEngine.java:321)
at com.pmease.quickbuild.DefaultScriptEngine.evaluate(DefaultScriptEngine.java:74)
at com.pmease.quickbuild.model.Configuration.runPreBuildScript(Configuration.java:1737)
at sun.reflect.GeneratedMethodAccessor446.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:196)
at com.pmease.quickbuild.model.Configuration_$$_jvst27f_0.runPreBuildScript(Configuration_$$_jvst27f_0.java)
at com.pmease.quickbuild.DefaultBuildEngine.process(DefaultBuildEngine.java:436)
at com.pmease.quickbuild.DefaultBuildEngine.access$000(DefaultBuildEngine.java:142)
at com.pmease.quickbuild.DefaultBuildEngine$2.run(DefaultBuildEngine.java:1230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.pmease.quickbuild.QuickbuildException: java.lang.ClassCastException: Foo cannot be cast to groovy.lang.Script
at com.pmease.quickbuild.plugin.basis.BasisPlugin$32.evaluate(BasisPlugin.java:365)
at com.pmease.quickbuild.DefaultScriptEngine.evaluate(DefaultScriptEngine.java:305)
at com.pmease.quickbuild.DefaultScriptEngine.evaluate(DefaultScriptEngine.java:74)
at com.pmease.quickbuild.model.Configuration.runPreBuildScript(Configuration.java:1737)
at sun.reflect.GeneratedMethodAccessor446.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:196)
at com.pmease.quickbuild.model.Configuration_$$_jvst27f_0.runPreBuildScript(Configuration_$$_jvst27f_0.java)
at com.pmease.quickbuild.DefaultBuildEngine.process(DefaultBuildEngine.java:436)
at com.pmease.quickbuild.DefaultBuildEngine.access$000(DefaultBuildEngine.java:142)
at com.pmease.quickbuild.DefaultBuildEngine$2.run(DefaultBuildEngine.java:1230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at com.pmease.quickbuild.plugin.basis.BasisPlugin$32.evaluate(BasisPlugin.java:406)
at com.pmease.quickbuild.DefaultScriptEngine.evaluate(DefaultScriptEngine.java:305)
... 13 more
Is there something wrong with the way I use "pre-build script"? Or is there a way to create a global class object at all?
Thank you!