How to use getStartupArgs()
Since 0.9.1 it seems you can read the command line arguments issue #245 with the getStartupArgs() method (documentation)
But I do know how to use it, I've put it in in all the Griffon lifecycle, Controller, Service, and I get the exception
org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: [LifeCycle|Controller|Service].getStartupArgs() is applicable for argument types: () values: []
Caused by: groovy.lang.MissingMethodException: No signature of method: [LifeCycle|Controller|Service].getStartupArgs() is applicable for argument types: () values: [
]
app.getStartupArgs()
That's the way you can read the arguments
Related
I created a simple groovy script in shared library to update the build details
def call(body) {
currentBuild.displayName = body.displayName
currentBuild.description = body.description
}
I call UpdateBuildDetails from pipeline step
UpdateBuildDetails ([displayName: params.SERVICE_NAME,
description: 'Test'])
Here is the error. Can someone advise what I am missing:
hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: UpdateBuildDetails.call() is applicable for argument types: (java.util.LinkedHashMap) values: [[displayName:update-service, description:Test]]
Possible solutions: call(java.lang.Object, java.lang.Object), wait(), any(), wait(long), main([Ljava.lang.String;), each(groovy.lang.Closure)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58)
Caught: groovy.lang.MissingMethodException: No signature of method: java.util.LinkedHashMap.reset() is applicable for argument types: () values: []
Possible solutions: keySet(), keySet(), keySet(), get(java.lang.Object), get(java.lang.Object), get(java.lang.Object)
groovy.lang.MissingMethodException: No signature of method: java.util.LinkedHashMap.reset() is applicable for argument types: () values: []
Possible solutions: keySet(), keySet(), keySet(), get(java.lang.Object), get(java.lang.Object), get(java.lang.Object)
at main.run(main.groovy:394)
There is code at line 394 of main.groovy that is calling reset() (directly or indirectly) on an instance of LinkedHashMap. That isn't valid.
My test code below:
trait Behavior {
}
class Dog {
def greet() {
println 'Hi, I am a dog.'
}
}
def foo(Dog dog) {
dog.greet()
}
def dog = new Dog() as Behavior
dog.greet()
foo(dog)
It gives errors as below:
Hi, I am a dog.
Caught: groovy.lang.MissingMethodException: No signature of method: test2.foo() is applicable for argument types: (Dog1_groovyProxy) values: [Dog1_groovyProxy#48f278eb]
Possible solutions: foo(Dog), run(), run(), any(), find(), use([Ljava.lang.Object;)
groovy.lang.MissingMethodException: No signature of method: test2.foo() is applicable for argument types: (Dog1_groovyProxy) values: [Dog1_groovyProxy#48f278eb]
Possible solutions: foo(Dog), run(), run(), any(), find(), use([Ljava.lang.Object;)
at test2.run(test2.groovy:18)
Why does the trait change the class type of 'dog'? When it implements the trait 'Behavior', it won't be an instance of class Dog? Calling 'foo' method gives errors.
Trait changes class type compatibility unlike 'implement'?
as here changes the instance type to a Behavior, as explained in the documentation
When coercing an object to a trait, the result of the operation is not the same instance. It is guaranteed that the coerced object will implement both the trait and the interfaces that the original object implements, but the result will not be an instance of the original class.
After this code I have error:
gebLocator(wait: true) { $("a#fCoverage") }
browser.js.exec(gebLocator+ ".addEventListener('click', function(){alert('GTM')});")
Error message:
groovy.lang.MissingMethodException: No signature of method:
geb.navigator.NonEmptyNavigator.plus() is applicable for argument
types: (java.lang.String) values: [.addEventListener('click',
function(){alert('GTM')});] Possible solutions:
plus(geb.navigator.Navigator), has(java.lang.String),
is(java.lang.String), last(), value(), add(java.lang.String)
The error message means that you have tried to execute method plus(String) on NonEmptyNavigator what is impossible because NonEmptyNavigator doesn't have such a method.
If you want to execute js code using geb driver:
browser.js.exec("document.getElementById('fCoverage').addEventListener('click', function(){alert('GTM')});")
I have two groovy scripts A and B.
A looks like:
import some.Class
//Some helper function
String doSomeWork(Integer input) {
//does something with input and returns a String
return "result: $input"
}
//Now do some real stuff here
println( doSomeWork(42) )
In B I want to import A (its in the classpath) and use its doSomeWork:
import A
println A //prints class A. This means we can access it here. =)
println( A.doSomeWork(45) ) //Now try to call As doSomeWork
The last line however results in an exception:
Caught: groovy.lang.MissingMethodException: No signature of method: static A.doSomeWork() is applicable for argument types: (java.lang.Integer) values: [45]
Possible solutions: doSomeWork(java.lang.Integer)
groovy.lang.MissingMethodException: No signature of method: static A.doSomeWork() is applicable for argument types: (java.lang.Integer) values: [45]
Possible solutions: doSomeWork(java.lang.Integer)
at B.run(B.groovy:3)
import A //Will execute As code
println A //prints class A. This means we can access it here. =)
println( (new A()).doSomeWork(45) ) //Now call As doSomeWork
What do I have to do to successfull call As doSomeWork in script B?
EDIT: Okay, I found out. it is not a static method but a method of A. So (new A()).doSomeWork(45) is doing the job. However, that means when A is imported, all its code is executed before Bs code. How can I avoid that? My goal is to only use As method (which obvioulsy does not access any of As properties) without A doing any other side effects.