Groovy
Base64 Encoding
Do you want to send a byte[] in a JSON Payload?
The byte[] and String classes in Groovy's GDK have methods to Base64 encode and decode Strings.
Current date in iso 8601 in Groovy
Do you need to work with dates?
ISO 8601:
The purpose of this standard is to provide an unambiguous and well-defined method of representing dates and times, so as to avoid misinterpretation of numeric representations of dates and times, particularly when data are transferred between countries with different conventions for writing numeric dates and times
Groovy makes your life easier.
Gradle
Building Groovy Libraries
In this Gradle guide, @ysb33r show how the init task can speed the creation of a Groovy Library. It creates an initial folder structure, initial content of the build.gradle file etc.
Gradle project properties
1️⃣st issue of @aalmiray's ✉️ newsletter.
Andres' discusses Gradle's project dynamic properties :
A Project can also have dynamic properties which can be defined in 4 ways:
- a file named gradle.properties, local to the project.
- a file named gradle.properties, available to all projects at ~/.gradle/ (%USER_HOME%/.gradle on Windows).
- on the command line using the -P flag.
- using the ext block inside the build file.
Moreover, he helps to understand script variable access.
a method defined on a script is the same as any other method defined anywhere else, that is, methods don’t understand the concept of owner and delegate, thus it can’t reach out into the script’s variables.
Tools
Scripting IDE for DSL awareness - GroovyDSL or GDSL
GroovyDSL is a framework with a domain-specific language designed to define the behaviour of end-user DSLs as script files which are executed by the IDE on the fly, bringing new reference resolution and code completion logic into the scope of a project.
This link contains examples of GSDL scripts and information about GroovyDSL.
Use GroovyDSL in IntelliJ IDEA Community Edition
Why should you bother to write a GDSL script?
when we define our own DSL or on a large project adding code completion for dynamic properties and methods can save a lot of time (and errors) in the long run
The code completion working in IntelliJ IDEA Community by @mrhaki
Introduction to GDSL in IntelliJ Idea
A collection of posts introducing GSDSL by @KushalLikhi.
- Introduction to GDSL in IntelliJ Idea
- Understanding Context And Contributors in Detail
- Defining dynamic property in a class
- Defining dynamic method in a class
- Adding Hinting for missingMethod implementation
- Setting a global context
- Delegating Closure Calls
- Defining methods in a closure passed to method of particular name
- Defining Properties in a closure passed to method of particular name
- Contributing to classes which match a path/name pattern
- Contributing methods with current class return types or parameters
- AutoComplete Script for grails-Mail-Plugin “sendMail” closure
- Getting Code of a method or Field in GDSL Script
- Advanced Example showing domain properties implementation
Android / iOS
Groovy Android Gradle Plugin 1.2.0 🎉
A Gradle plugin to support the Groovy language for building Android apps
I normally don't link to Software releases. However, @andrewreitz_ puts such an effort to support Groovy in the Android world that I wanted to let you know that Groovy Android Gradle Plugin 1.2.0 has been released.
Comment
Guadalajara (Spain) boils with 30º at 23:00. I am having a hard time to fall asleep but great Groovy material is piling up in my inbox.
This issue introduces you to GDSL. Another example of Groovy being used everywhere. The icing on the cake for this issue are some Groovy and Gradle articles.
Sergio del Amo