Groovy
Group and Count Elements in Collection or Map
we can group items in a collection, map or array and count the number of elements in a group.
def list = ['Groovy', 'Grails', 'Java']
// 2 items start with G, 1 with J.
assert list.countBy { it[0] } == ['G': 2, 'J': 1]
Useful in Testing! In fact, I discovered this one while reading Spock, Up & Running
Escaping HTML within XML with Groovy
No need to use the org.apache.commons:commons-text
dependency. If you are in Groovy world, Groovy XML has you covered.
Groovy Calamari Support
Greach Doorbuster tickets
There are only a dozen Doorbuster tickets remaining for Greach 2019, act now to secure yours!
Micronaut
Introduction to Micronaut Webinar
💰Free.
🎤Graeme Rocher, Micronaut project lead.
📅: November 14, 2018.
⏳: 1 hour. 10:00 a.m. to 11:00 a.m. CT.
📍: Online.
Grails
Generate Links Outside Controllers or Tag Libraries
In Grails we can create a link to a controller with the link() method. This works in the context of a request, like in a controller, tag library or Groovy Server Page (GSP). But since Grails 2.0 we can also generate links in services or any other Spring bean in our project. To create a link we need to inject the grailsLinkGenerator bean into our class.
Caution: the bean name must be grailsLinkGenerator
, not linkGenerator
.
Grails Testing deep dive
💰50$.
🎤Sergio del Amo Caballero.
📅: Friday, November 16 2018.
⏳: 3 hours. 9:00am to 12:00pm CST.
📍: Online.
Gradle
My task… what’s wrong with your Gradle task?
@czaszo explains Gradle phases, the use of dependsOn
, mustRunAfter
, finalizedBy
to control task execution order and teaser of Gradle tasks inputs and outputs.
The Java Library Plugin
The compile, testCompile, runtime and testRuntime configurations inherited from the Java plugin are still available but are deprecated. You should avoid using them, as they are only kept for backwards compatibility.
Gradle is pushing us to move towards implementation
and api
.
This is probably the must read bit:
So when should you use the api configuration? An API dependency is one that contains at least one type that is exposed in the library binary interface, often referred to as its ABI (Application Binary Interface). This includes, but is not limited to:
-types used in super classes or interfaces
-types used in public method parameters, including generic parameter types (where public is something that is visible to compilers. I.e. , public, protected and package private members in the Java world)
-types used in public fields
-public annotation types
By contrast, any type that is used in the following list is irrelevant to the ABI, and therefore should be declared as an implementation dependency:
-types exclusively used in method bodies
types exclusively used in private members
types exclusively found in internal classes (future versions of Gradle will let you declare which packages belong to the public API)
Comment
Links to this week’s agenda. Gradle links to master your build and several Groovy goddies.
Sergio del Amo