Welcome to KlumAST
Turn your models into supermodels!
Breaking changes
I decided to release 1.2.0 prior to doing some extensive refactorings including splitting into runtime and compile time dependencies.
Thus 1.2.0 is simply a step up to 2.0.0, mainly designed to replace various rc-version in use.
Some new features being introduced in 1.2.0 need KlumAST to be present on the classpath during runtime.
Closure are now all DELEGATE_ONLY
, this means methods of an outer object cannot be directly accessed. This is cleaner and somewhat closer to the behaviour of xml or other structured languages. Accessing outer methods should be a corner case. Take a look at Migration if you encounter errors.
What is KlumAST?
KlumAST is the first part of the KlumDSL suite. It provides and easy way to create a complete DSL for a model classes.
There are two main objectives for this project:
-
be as terse as possible while still being readable and using almost no boilerplate code
-
Offer as much IDE-based assistance as possible. Since KlumAST uses AST transformations, this works out of the box for all major IDEs (as long as the model classes are separated from the actual configuration)
Example
Given the following config classes:
@DSL
class Config {
Map<String, Project> projects
boolean debugMode
List<String> options
}
@DSL
class Project {
@Key String name
String url
MavenConfig mvn
}
@DSL
class MavenConfig {
List<String> goals
List<String> profiles
List<String> cliOptions
}
A config object can be created with the following dsl:
def github = "http://github.com"
def config = Config.create {
debugMode true
options "demo", "fast"
option "another"
projects {
project("demo") {
url "$github/x/y"
mvn {
goals "clean", "compile"
profile "ci"
profile "!developer"
cliOptions "-X -pl :abc".split(" ")
}
}
project("demo2") {
url "$github/a/b"
mvn {
goals "compile"
profile "ci"
}
}
}
}
Find more details on in our brand new wiki