Domain Specific Language Dsl In Groovy
Define a new clibuilder instance specifying an optional usage string.
Domain specific language dsl in groovy. 5 3 mb file format. Def lst 1 2 3 4 print lst. Groovy dsls integrate seamlessly into the groovy language itself in such a way that it s not always apparent where the regular. The focus is on how the groovy language can be used to construct domain specific minilanguages.
In groovy 2 5 this approach became deprecated. A dsl is a programming language designed to solve a specific issue very efficiently. Domain specific languages dsls have become a valuable part of the groovy idiom. The examples include a quick and simple groovy dsl to interface with twitter.
One of the big benefits of groovy is how its dynamic features support the development of domain specific languages dsls or mini languages which we can run directly on the jvm alongside your existing java. They are a vector of communication and can be seen as a. Groovy for domain specific languages 2nd edition author. By definition a dsl can be applied to many areas.
Dsls are particularly good to solve business requirements in a scope. Back to groovy with a sample domain specific language dsl to demonstrate how groovy is a good fit for building these kinds of mini langagues specifically designed to solve a particular problem. The main focus however is on how groovy supports the development of domain specific languages through its metaprogramming features. Writing a domain specific language in groovy.
Dsl or domain specific language is meant to simplify the code written in groovy in such a way that it becomes easily understandable for the common user. For a more elaborated explanation i recommend the article on wikipedia. The times when developing on the jvm meant you were a java programmer have long passed. Dsls are used in native groovy builders grails and gorm and testing frameworks.
Practical examples are used throughout to demystify these seemingly complex language features and to show how they can be used to create simple and elegant dsls. This article describes one way to create an own domain specific language dsl in java groovy. The groovy util version in groovy 2 5 points to the commons cli version for backwards compatibility but has been removed in groovy 3 0. Jenkinsfiles using a domain specific language dsl based on the groovy programming language are persistent files that model delivery pipelines as code.