Difference between Groovy Binary and Source release?

A source release will be compiled on your own machine while a binary release must match your operating system. source releases are more common on linux systems because linux systems can dramatically vary in cpu, installed library versions, kernelversions and nearly every linux system has a compiler installed. binary releases are common on ms-windows systems. … Read more

Can you break from a Groovy “each” closure?

Nope, you can’t abort an “each” without throwing an exception. You likely want a classic loop if you want the break to abort under a particular condition. Alternatively, you could use a “find” closure instead of an each and return true when you would have done a break. This example will abort before processing the … Read more

Groovy / grails how to determine a data type?

To determine the class of an object simply call: someObject.getClass() You can abbreviate this to someObject.class in most cases. However, if you use this on a Map it will try to retrieve the value with key ‘class’. Because of this, I always use getClass() even though it’s a little longer. If you want to check … Read more

Recommended way to stop a Gradle build

I usually throw the relevant exception from the org.gradle.api package, for example InvalidUserDataException for when someone has entered something invalid, or GradleScriptException for more general errors. If you want to stop the current task or action, and move on to the next, you can also throw a StopActionException

Groovy executing shell commands

Ok, solved it myself; def sout = new StringBuilder(), serr = new StringBuilder() def proc=”ls /badDir”.execute() proc.consumeProcessOutput(sout, serr) proc.waitForOrKill(1000) println “out> $sout\nerr> $serr” displays: out> err> ls: cannot access /badDir: No such file or directory

Converting a string to int in Groovy

Use the toInteger() method to convert a String to an Integer, e.g. int value = “99”.toInteger() An alternative, which avoids using a deprecated method (see below) is int value = “66” as Integer If you need to check whether the String can be converted before performing the conversion, use String number = “66” if (number.isInteger()) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)