Skip to content

ZenWave SDK generates Spring Boot in Java by default. A customization is a Maven jar of Handlebars templates and Java helpers. The official plugins load it through their templates option, so the same ZDL, OpenAPI and AsyncAPI models generate code for another stack. A customization does not define a plugin of its own.

This guide has two readers: you and your coding agent. Each step has an Agent: block with instructions to follow and a Human: line that explains why the step exists.

  1. Create an empty folder and put a base-project/ inside it. It is a small working project in your stack (.NET, Node.js, Go, Java, …) that shows the patterns you want generated: layers, naming, persistence, messaging and tests. It must build, and its tests must pass.
  2. Give this guide to your coding agent in one of two ways:
    • Copy the prompt below, open your agent in that folder, and paste it. The agent fetches this guide as Markdown.
    • Or download CUSTOMIZATION-GUIDE.md into the folder, check it, and tell your agent: Read CUSTOMIZATION-GUIDE.md and create a ZenWave customization from my base project.
Read https://www.zenwave360.io/docs/build-your-own-customization.md and create a ZenWave customization from my base project

The downloaded CUSTOMIZATION-GUIDE.md has the same content as the page you are reading, in Markdown so you can save it to disk. The instructions are the same.

These customizations follow this recipe. Read their code when a step needs a concrete example.

TargetStatusSourceWhat to look at
Spring Boot, JavaDefaultbackend-application-defaultThe official templates and helpers you replace: BackendApplicationProjectTemplates and its .hbs files.
Spring Boot, KotlinOfficialkotlin-backend-applicationThe project shape to copy: one module, *Templates extends ProjectTemplates, helpers, .hbs templates, provided dependencies.
Quarkus, JavaBeta, unofficialzenwave-quarkusThe working documents (docs/), the shared test models, and the e2e/ loop with regenerate.sh.

The generator always runs on the JVM, from the jbang CLI, the Maven plugin or the IDE. Your customization is a Java Maven module: its *Templates and *Helpers classes are Java, built with Java 17 or later.

The Handlebars templates can emit any language. A .NET, Node.js or Go customization is still a Java Maven module, and its templates write C#, TypeScript or Go files into your project. Only the build of the customization itself needs Java and Maven. The generated project keeps its own toolchain.

Code formatting after generation only runs for files registered as JAVA or KOTLIN. For other languages, register templates with a null output type and format the output with your own tools.

Human: the base project is your definition of good code. The generator can only reproduce patterns that someone wrote down first.

Agent:

  1. Check the three inputs. Ask the human for anything missing, and do not guess. If nobody can answer, write your assumption under “Open questions” in docs/target-stack.md and continue:
    • base-project/: run its install, build and test commands (for example npm ci, dotnet build, mvn verify). Write down the exact commands and confirm they pass. If you cannot run them, for example without network access, write that down too.
    • Target stack name, for example dotnet, nestjs or quarkus. It names the modules and the Java package.
    • ZenWave SDK version: the version the users of this customization run. The provided dependencies use it.
  2. Check the tools: JDK 17 or later, Maven and git.
  3. Get the ZenWave SDK source at that version, for example a clone of zenwave-sdk next to this folder. Before you use an io.zenwave360.sdk type, method, option or model key, read it in that source. Do not rely on memory.
  4. Create this layout in the same folder as base-project/ (the folder the human gave you, not a new subfolder). Do not modify base-project/:
my-customization/
├── base-project/                    # input, read-only
├── AGENTS.md                        # how to work in this repo (see below)
├── pom.xml                          # Maven reactor (step 4)
├── docs/
│   ├── target-stack.md              # step 2
│   ├── customization.md             # step 3
│   ├── tasks.md                     # step 5
│   └── sdk-coupling.md              # step 7
├── test-resources/                  # shared models (step 4)
├── <stack>-backend-application/     # templates + helpers (step 4)
└── e2e/                             # generate, build, test (step 6)
  1. Write a short AGENTS.md: what this repo is, where the pattern and stack are (docs/target-stack.md), where the contract is (docs/customization.md), where the status is (docs/tasks.md, with its marks), and the rule from item 3 about reading the SDK source.

Human: you get one page to review and approve before any template exists. A wrong decision is cheapest to fix here.

Agent: read all of base-project/ and write docs/target-stack.md with these sections. Write only what the base project shows. List anything else under “Open questions” for the human.

  1. General purpose. This is a ZenWave customization: a Maven jar of Handlebars templates and helpers, with no plugin of its own, selected with the templates option on the official plugins. It copies the project shape of kotlin-backend-application. Its dependencies on the official plugins whose templates it replaces are provided.

  2. Modules. A table with the role of each module: parent, test-resources, <stack>-backend-application, e2e, and one module per extra plugin you replace (for example AsyncAPI).

  3. Target stack. Language and version, framework, build tool, dependency wiring, and the layer and package layout. Map that layout to a ZenWave project layout such as CleanHexagonalProjectLayout or LayeredProjectLayout. Then naming conventions, persistence (ORM, repositories, migrations), mapping between DTOs and entities, REST controllers, messaging (in-process events, broker), and test style (unit, in-memory, integration, HTTP). Cite a base project file for each item.

    ZenWave layouts are Java packages: each layout.*Package is a dotted name that becomes a folder in the target path. For a folder-based language, record the folder of each layer, and the layout package that maps to it, so step 3 can use them.

  4. Hard constraints on generated code. Rules the base project follows that generated code must keep, for example “no framework types in the domain” or “repositories behind an interface”.

  5. Version pinning. Templates write sources into an existing project. They do not emit build files, the application entry point, wrappers, Docker Compose or a README. Those files, and every library version, belong to the base project and the e2e scaffold.

  6. Testing. Unit tests in the customization module, and the e2e loop from step 6.

  7. Open questions.

Stop and ask the human to review docs/target-stack.md.

Human: this file is the contract. Templates are written against it, and you review the customization one row at a time.

Agent: write docs/customization.md.

  1. How templates are selected. One row per official plugin you replace:
Official pluginTemplates classOption value
BackendApplicationDefaultPlugin<Stack>BackendApplicationTemplatesnew <package>.<Stack>BackendApplicationTemplates
OpenAPIControllersPlugin<Stack>OpenAPIControllersTemplatesnew <package>.<Stack>OpenAPIControllersTemplates
SpringWebTestClientPlugin<Stack>HttpTestTemplatesnew <package>.<Stack>HttpTestTemplates
AsyncAPIGeneratorPlugin<Stack>AsyncAPITemplates<package>.<Stack>AsyncAPITemplates (a class name, no new)

Keep only the plugins the base project needs. The backend one is the core.

  1. Target files. Read the official templates class in the SDK source (BackendApplicationProjectTemplates for the backend) and the Kotlin one (BackendApplicationKotlinTemplates). For each template they register, add a row: the target file in your stack, and when it is generated (each aggregate, each entity, each service, once, only with events, …). Use the same path placeholders, such as {{entity.name}} and {{service.name}}. Write each target path as source folder + layout package + file name: the official templates use src/main/java and src/test/java as source folders, and yours can be anything, for example src and test. The template list a template belongs to (entityTemplates, serviceTemplates, singleTemplates, …) sets how often it runs: read the list fields of ProjectTemplates in the SDK source. A list you leave empty generates nothing.

    If a concept does not fit an existing option value, for example raw SQL where persistence offers jpa and mongodb, write it down as an open question.

  2. Additions and removals. Mark the files your stack adds that the official templates do not have, for example a repository implementation. List the official templates you do not register, and why.

  3. Substitutions. For each concept (inbound service, service implementation, entity, repository, mapper, domain events and listeners, REST controller, tests), write what the target stack uses instead of the Spring Boot default. Cite the base project file it comes from.

Stop and ask the human to review docs/customization.md.

Human: copying a proven project shape means build, test and packaging problems are already solved.

Agent: create the Maven reactor. Mirror kotlin-backend-application file by file.

  1. Parent pom.xml: a property with the ZenWave SDK version, dependency management for the official plugins, and the module list.
  2. test-resources: the models every other module tests with, on the classpath (zdl/, openapi/openapi.yml, asyncapi/asyncapi.yml). Start from the SDK test models, for example customer-address-relational.zdl in zenwave-sdk-test-resources, plus a model that describes the base project’s own domain. Other modules depend on this one and keep no copies.
  3. <stack>-backend-application: a jar with provided dependencies on the official plugins it replaces:
<dependency>
    <groupId>io.zenwave360.sdk.plugins</groupId>
    <artifactId>backend-application-default</artifactId>
    <version>${zenwave-sdk.version}</version>
    <scope>provided</scope>
</dependency>
<!-- same for openapi-controllers and openapi-spring-webtestclient, if you replace them -->
  1. A templates class that extends io.zenwave360.sdk.zdl.ProjectTemplates, sets its templates folder in the constructor, registers templates with addTemplate(...) and adds its helpers in getTemplateHelpers. This is the shape of BackendApplicationKotlinTemplates:
public class MyStackBackendApplicationTemplates extends ProjectTemplates {

    // options are bound onto public fields with the same name
    public PersistenceType persistence = PersistenceType.jpa;

    protected Function<Map<String, Object>, Boolean> skipEntity = (model) -> is(model, "vo", "input");

    @Override
    public List<Object> getTemplateHelpers(Generator generator) {
        var helpers = new ArrayList<>(super.getTemplateHelpers(generator));
        if (generator instanceof BackendApplicationDefaultGenerator backendGenerator) {
            helpers.add(new MyStackBackendApplicationHelpers(backendGenerator));
        }
        return helpers;
    }

    public MyStackBackendApplicationTemplates() {
        setTemplatesFolder("com/example/zenwave/mystack/BackendApplicationDefaultGenerator");
        var layoutNames = new ProjectLayout();
        // copied from the Kotlin customization: change the source folder, template, file name and output type for your stack
        this.addTemplate(this.entityTemplates, "src/main/kotlin", "core/domain/{{persistence}}/Entity.kt",
                layoutNames.entitiesPackage, "{{entity.name}}.kt", KOTLIN, skipEntity, false);
        // ...one addTemplate per row of docs/customization.md
    }
}
  1. Templates live under src/main/resources/<templates folder>/<source folder>/<template location>.hbs. In the example above that is src/main/resources/com/example/zenwave/mystack/BackendApplicationDefaultGenerator/src/main/kotlin/core/domain/jpa/Entity.kt.hbs.
  2. A first unit test that runs the official plugin with your templates on a test-resources model, as the Kotlin tests do:
Plugin plugin = new BackendApplicationDefaultPlugin()
        .withZdlFile("classpath:zdl/customer-address-relational.zdl")
        .withTargetFolder("target/projects/customer-address")
        .withOption("templates", "new " + MyStackBackendApplicationTemplates.class.getName())
        .withOption("basePackage", "com.example.customers")
        .withOption("persistence", PersistenceType.jpa)
        .withOption("style", ProgrammingStyle.imperative)
        .withOption("forceOverwrite", true)
        .withOption("haltOnFailFormatting", false);
new MainGenerator().generate(plugin);
// assert the generated files exist and contain the expected types
  1. An empty e2e module, filled in step 6.

Run mvn install and confirm it passes before you write templates.

Step 5 · Templates and helpers, one slice at a time

Section titled “Step 5 · Templates and helpers, one slice at a time”

Human: small slices keep every diff reviewable, and docs/tasks.md shows progress at a glance.

Agent:

  1. Write docs/tasks.md: one task per group of rows of docs/customization.md, grouped by module. Marks: [ ] not started, [/] in progress, [x] done or ready for review, [!] blocked. Only one task is [/] at a time. Update the mark when a task moves.
  2. Start with a thin vertical slice: entity, repository port, inbound service and service implementation. Then do the remaining rows.
  3. For each template:
    • Start from the official .hbs (or the Kotlin one) for that slot, and rewrite it so its output matches the base project file for the same concept.
    • Register it with addTemplate(list, sourceFolder, templateLocation, targetPackage, targetFile, outputType, skip, skipOverwrite). The list sets how often it runs: entityTemplates once per entity, serviceTemplates once per service, singleTemplates once, and so on. The sourceFolder is part of both the template location and the target path. targetPackage is a layout placeholder from ProjectLayout, such as layoutNames.entitiesPackage, rendered as a folder. skip is a function of the template model that returns true to skip the file. With skipOverwrite set to true, an existing file is kept unless the user passes forceOverwrite: use it for files developers edit by hand.
    • Partials resolve relative to the template that includes them.
  4. Helpers:
    • A helper is a public method on your helpers class, called from templates by name. When the default helpers already compute what you need, use them.
    • A helper with the same name as an SDK helper replaces it for your templates, as the Kotlin javaType does.
    • To see the model a template receives, run jbang zw -p ZdlToJsonPlugin zdlFile=zenwave-model.zdl and read the SDK source of the helper or model key you use.
  5. Add or extend a unit test with each slice: assert the target files exist and contain the types the contract names.
  6. Run mvn install after each slice. A slice is [x] when its unit tests pass and its output builds in the e2e loop.

Human: your base project’s own tests are the acceptance test. Generated code that passes them follows your patterns.

Agent:

  1. Scaffold. Copy base-project/ to e2e/src/test/resources/projects/<name>/. Keep the build files, wrapper, configuration and Docker files. Remove the hand-written domain code that the generator now produces. Add zenwave-model.zdl with the model of that domain. Write down in docs/e2e-scaffold.md how the scaffold was made and what you changed.
  2. E2E test. A test in e2e copies the scaffold to target/projects/<name>/, replaces its zenwave-model.zdl with the test-resources model, runs the official plugins with your templates option into the copy, then runs the base project’s build and test commands from step 1 on the copy. Skip e2e tests in a normal build and run them with a property, as the SDK does with e2e.tests.skip: mvn install -De2e.tests.skip=false.
  3. Regenerate in place. Add e2e/regenerate.sh <name> [--force|--clean]. It reinstalls the templates, then regenerates the checked-in project. By default it writes only missing files and keeps hand-edited ones. --force overwrites every generated file. --clean deletes the generated source folders first.
  4. Loop. Generate, build, test. When something fails, fix the template or helper, never the generated file, and run again. Record each template fix in docs/tasks.md.
  5. Keep two e2e projects if you can: one hand-finished, with the full test suite, and one generated fresh, that at least compiles and passes architecture tests.

The zenwave-quarkus e2e runs the plugins through zenwave-sdk-maven-plugin in a Maven profile of the scaffold project, because the scaffold is a Maven project. For a non-JVM scaffold, the e2e test can run the plugins in Java with MainGenerator, as the unit test in step 4 does.

Human: the templates option is the only documented extension point. Everything else is SDK internals, and this file turns an SDK upgrade into a checklist.

Agent: write docs/sdk-coupling.md.

  1. Decision. Say whether you keep every template local, including ones identical to upstream, or load some from the SDK jar. zenwave-quarkus keeps all of them local: one folder holds the whole output, and an upstream change never alters the generated code silently. The cost is porting upstream fixes by hand.
  2. Last synced. The SDK version or commit, and the date. Update it after every port.
  3. What we depend on. A table: SDK surface, used by, stability, what a change breaks. Include at least: the templates option (documented); ProjectTemplates template lists, addTemplate, setTemplatesFolder, getTemplateHelpers; option binding onto public fields of the templates class; the upstream helpers your templates call; helper name precedence; partial resolution; the model keys your templates read; and the SDK utility classes your helpers call. Mark everything except the templates option as internal.
  4. How breaks are detected. Compile errors from mvn install, render errors and missing files from the unit tests, wrong output from the e2e loop. Say what is not covered: a model key that renders blank in a branch no e2e model exercises.
  5. When bumping the SDK. Diff upstream templates and Java since the last synced commit, check the templates classes for renamed or split lists, port the fixes that apply, run the full build with e2e, update “Last synced”.

Human: users keep the official plugins and their options. Only the templates option and one dependency change.

Agent: install with mvn install, or deploy the jar to a Maven repository your users can reach. Then document these three ways to use it in the customization’s README.

With a .zw file in ZenWave Editor:

@import("com.example:mystack-backend-application:1.0.0")
config {
    zdlFile "zenwave-model.zdl"

    plugins {
        BackendApplicationDefaultPlugin {
            templates "new com.example.zenwave.mystack.MyStackBackendApplicationTemplates()"
        }
    }
}

With the Maven plugin, add the customization as a plugin dependency and set templates in configOptions:

<plugin>
    <groupId>io.zenwave360.sdk</groupId>
    <artifactId>zenwave-sdk-maven-plugin</artifactId>
    <version>${zenwave.version}</version>
    <executions>
        <execution>
            <id>backend-application</id>
            <goals><goal>generate</goal></goals>
            <configuration>
                <generatorName>BackendApplicationDefaultPlugin</generatorName>
                <configOptions>
                    <zdlFile>${project.basedir}/zenwave-model.zdl</zdlFile>
                    <templates>new com.example.zenwave.mystack.MyStackBackendApplicationTemplates</templates>
                    <basePackage>com.example.customers</basePackage>
                </configOptions>
            </configuration>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>io.zenwave360.sdk.plugins</groupId>
            <artifactId>backend-application-default</artifactId>
            <version>${zenwave.version}</version>
        </dependency>
        <dependency>
            <groupId>com.example</groupId>
            <artifactId>mystack-backend-application</artifactId>
            <version>1.0.0</version>
        </dependency>
    </dependencies>
</plugin>

With the jbang CLI, add the jar with --deps, as described in Customizing Generated Code.

Human: use this list to review the work, or hand it to a second agent as a review checklist.

Agent: the customization is done when all of these are true:

  • docs/target-stack.md and docs/customization.md are reviewed by the human, and their open questions are answered.
  • Every row of docs/customization.md has a registered template, or is listed as not registered with a reason.
  • Every task in docs/tasks.md is [x], or [!] with a reason the human accepted.
  • mvn install passes with unit tests that cover every templates class.
  • mvn install -De2e.tests.skip=false generates the e2e projects and passes the base project’s build and tests on them.
  • Generated code respects every hard constraint in docs/target-stack.md.
  • docs/sdk-coupling.md lists the SDK surfaces used and the last synced SDK version.
  • The README shows how to use the customization from .zw, Maven and jbang.