Minimum code coverage threshold in Jacoco Gradle

The feature is now available. You simply need to apply the Gradle JaCoCo plugin and define coverage verification like this: apply plugin: ‘jacoco’ jacocoTestCoverageVerification { violationRules { rule { limit { minimum = 0.7 } } } } // to run coverage verification during the build (and fail when appropriate) check.dependsOn jacocoTestCoverageVerification The last line … Read more

Detecting the platform (Window or Linux) by Groovy/Grails

System.properties[‘os.name’] will return the name of the OS, e.g. “Windows XP”. So if you want to figure out whether you’re running on Windows or not, you could do something like: if (System.properties[‘os.name’].toLowerCase().contains(‘windows’)) { println “it’s Windows” } else { println “it’s not Windows” } Alternatively, org.apache.commons.lang.SystemUtils (from the Apache commons-lang project) exposes some boolean constants … Read more

Groovy ‘assert’: How to display the value?

An assertion is similar to an if, it verifies the expression you provide: if the expression is true it continues the execution to the next statement (and prints nothing), if the expression is false, it raises an AssertionError. You can customize the error message providing a message separated by a colon like this: assert 4 … Read more

Convert Array to string in Java/Groovy

Use join, e.g., tripIds.join(“, “) Tangential If you want to create a list from another list you generally want something like map or collect as opposed to manually creating a list and appending to it, e.g. (untested): def sql = Sql.newInstance(“jdbc:mysql://localhost:3306/steer”, “root”, “”, “com.mysql.jdbc.Driver”) def tripIds = sql.map { it.id } Or if you only … Read more

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