Wiring it up

<plugin>
  <groupId>dev.cjfravel</groupId>
  <artifactId>nomos-maven-plugin</artifactId>
  <version>0.0.1-alpha11</version>
  <executions>
    <execution>
      <phase>generate-sources</phase>
      <goals><goal>generate</goal></goals>
    </execution>
  </executions>
</plugin>

Template layout

Templates live under src/main/resources/nomos/templates/. A file's path beneath that root is its base package:

src/main/resources/nomos/templates/
  com/example/models/user.json       # base package com.example.models
  com/example/billing/invoice.json   # base package com.example.billing

Parameters

ParameterPropertyDefault
Template directorynomos.templateDirectorysrc/main/resources/nomos/templates
Output directorynomos.outputDirectorytarget/generated-sources/nomos
Includesnomos.includes**/*.json
Excludesnomos.excludes—
Fail on missing templatesnomos.failOnMissingTemplatesfalse

The generate goal is thread-safe, so it runs correctly under parallel builds (mvn -T). Leave nomos.failOnMissingTemplates at false to skip quietly when a module has no templates, or set it to true to fail the build instead.

Generated-sources folder

By default the plugin writes to target/generated-sources/nomos and adds it as a compile source root, so generated code compiles without being checked in. Point the output at a source directory only when you intend to commit the generated sources:

<configuration>
  <outputDirectory>src/main/scala</outputDirectory>
</configuration>

On each run the plugin prunes orphans: nomos-generated .scala files under the output directory that are no longer produced — because a definition or template was removed — are deleted. Only files carrying the // Code generated by Nomos. DO NOT EDIT. header are removed, so hand-written sources sharing the directory are never touched.

Multi-file projects

The plugin parses every template, then merges them into one shared definition space before generating. That means a $ref in one file resolves to a definition in another — so you can split a large model one template per package and still cross-reference freely.

Project-wide settings (listType, dateType, fromJsonStyle, …) need only appear in one template and apply to the whole project. Setting the same one to conflicting values in different files is a build error.

Back to Getting Started, or browse the API reference.