Repository navigation
Development
Notes for working on ModelMaker itself. For using it, start at Getting Started.
./gradlew # default tasks: spotlessApply build publishToMavenLocal
./gradlew build # compile + tests + static analysis
./gradlew spotlessApply # format and apply the license header
./gradlew :modelmaker:test # core unit tests only
./gradlew :modelmaker-gradle-plugin:test # plugin functional tests (GradleTestKit) only
./gradlew publishToMavenLocal # publish to ~/.m2, needed before building the examples-
:modelmaker- the core generator library. Build-tool-agnostic, has amodule-info.java, published asio.github.malczuuu:modelmaker. -
:plugin-gradle- the Gradle pluginio.github.malczuuu.modelmaker, published asmodelmaker-gradle-plugin. Wraps the core in the Gradle API. -
build-logic/- an included build holding the shared convention plugins. -
examples/- standalone consumer builds, not part of the root build.
-
Java 25 toolchain;
maincompiles with--release 17for consumer compatibility, while a modernjavacdrives ErrorProne and NullAway. - NullAway runs in JSpecify mode on
mainonly - a nullness violation failsbuild. -
:plugin-gradleusesexplicitApi(): every public declaration needs an explicit visibility modifier and return type.
schema files → SchemaLoader → ModelType tree → ModelMaker.emit(type) → source text
-
Loading dispatches by file extension.
$refresolution happens across the whole batch after parsing, inSchemaReferences. -
ModelTypeis the resolved model - a top-level type plus nested types for inline objects, carrying the per-fileFeatureOverrides. -
ModelMakerhas two implementations:JavaModelMaker(the DTO) andKotlinExtensionMaker(the<Name>Extensions.kt). Java output is assembled from small focused*SnippetRendererpieces - fields, constructor, getters, builder, withers, support methods - each returning its code plus the imports it needs. -
Feature resolution happens in
emit: the schema's ownFeatureOverridesare applied on top of theModelOptionsthe maker was constructed with.
ModelMakerPlugin registers the modelmaker { } extension and two tasks, generateModelJava and
generateModelKotlin (which depends on it). Under the java plugin it puts both output directories on the main
source set and adds org.jspecify:jspecify on compileOnly unless already declared.
Tasks are @CacheableTask but deliberately not incremental - the output directory is wiped and rebuilt on every
run. generateModelKotlin doubles as a cleaner: with Kotlin generation off it deletes its output directory rather
than leaving stale .kt files.
- Spotless enforces the license header (
gradle/license-header.txt) on every*.java/*.kt/*.ktsundersrc/, google-java-format for Java, ktfmt for Kotlin sources and ktlint for*.gradle.kts. - No wildcard imports in Java.
- Tests run with the
per_classlifecycle - use proper@BeforeEach/@AfterEach, or@BeforeAllon an instance method. - Plugin tests are functional tests driven through GradleTestKit.
./gradlew publishToMavenLocal
examples/buildAll buildThe examples check in their generated sources, so a change in the emitted code shows up as a diff under
examples/*/src/main/model/java. Review it - that diff is the most readable description of what your change does.
See Examples.
-
README.mdstays short: what the project is, and one trivial example. - Everything else belongs in this wiki. When behavior changes, update the page that describes it and, if a new page
is added, list it in
_Sidebar.mdand on Home.
ModelMaker - Apache License 2.0 - Issues - Wiki index
Start here
Schemas
Output
Features
Integration
Reference