Chapter 12: Groovy Configuration

It is better to be a human being dissatisfied than a pig satisfied; better to be a Socrates dissatisfied than a fool satisfied. And if the fool or the pig thinks otherwise, it is because they have no experience of the better part.

—JOHN STUART MILL, Utilitarianism

Domains-specific languages are rather pervasive. The XML-based logback configuration can be be viewed as an example of a DSL. By the very nature of XML, XML-based configuration files are quite verbose and bulky. Moreover, a relatively large body of code in logback, namely Joran, is dedicated to processes these XML-based configuration files. Joran supports nifty features such as variable subsitution, conditional processing and on-the-fly extensibility. Not only Joran is a complex beast, the user-experience it provides can be described as unsatisfactory or at the very least unintuitive.

The Groovy-based DSL described in this chapter aims to be consistent, intuitive, and powerful. Everything you can do XML in configuration files, you can do in Groovy in a much shorter syntax. There is even a tool to automatically migrate XML