Skip to content

johnsonlee/codegen

Repository files navigation

Codegen

A lightweight framework for code generating.

Why Codegen?

In Java/Kotlin world, engineers usually use JavaPoet or KotlinPoet for code generating, those tool libraries are really cool, but it increases code maintainability, using JavaPoet or KotlinPoet to generate Java/Kotlin source code like using JSP languages to write a web page, you never know what you have written after a few months.

Codegen separates the generating logic into template and data model, it a little bit like SSR (Server Side Rendering), and provides the well-known template engines integration, e.g. Mustache, Velocity, it also supports custom template engine.

Example

See the example of AutoFactoryCodegen.kt