Skip to content

yojo-generator/gradle-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

42 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ YOJO Gradle Plugin

AsyncAPI β†’ Java DTO Generator for Gradle
βœ… Multi-spec βœ… AsyncAPI v2.6/v3.0 βœ… Lombok βœ… Polymorphism βœ… Validation βœ… Enums with Descriptions

Yojo Banner

Gradle Plugin Portal JDK 17+
License AsyncAPI 2.0+
Status: Active


⚠️ Supported Specifications

Specification Status Notes
AsyncAPI v2.0 / v2.6 βœ… Full Primary target
AsyncAPI v3.0 (RC) βœ… Experimental Supports operations, channels, messages, payload: { schema: ... }
OpenAPI 3.x ❌ Not supported Planned no earlier than 2026

πŸ’‘ Yojo is AsyncAPI-only. For OpenAPI, use OpenAPI Generator.


πŸ“¦ Installation

Groovy DSL (build.gradle)

plugins {
    id 'io.github.yojo-generator.gradle-plugin' version '1.0.3'
}

Kotlin DSL (build.gradle.kts)

plugins {
    id("io.github.yojo-generator.gradle-plugin") version "1.0.3"
}

πŸ›  Working Configuration

Groovy DSL (build.gradle)

yojo {
    configurations {
        create("main") {
            specificationProperties {
                register("api") {
                    specName("test.yaml")
                    inputDirectory(layout.projectDirectory.dir("contract").asFile.absolutePath)
                    outputDirectory(layout.buildDirectory.dir("generated/sources/yojo/com/example/api").get().asFile.absolutePath)
                    packageLocation("com.example.api")
                }
                register("one-more-api") {
                    specName("test.yaml")
                    inputDirectory(layout.projectDirectory.dir("contract").asFile.absolutePath)
                    outputDirectory(layout.buildDirectory.dir("generated/sources/yojo/oneMoreApi").get().asFile.absolutePath)
                    packageLocation("oneMoreApi")
                }
            }
            springBootVersion("3.2.0")
            lombok {
                enable(true)
                allArgsConstructor(true)
                noArgsConstructor(true)
                accessors {
                    enable(true)
                    fluent(false)
                    chain(true)
                }
                equalsAndHashCode {
                    enable(true)
                    callSuper(false)
                }
            }
        }
    }
}

sourceSets {
    main.java.srcDir(layout.buildDirectory.dir("generated/sources/yojo"))
}

tasks.compileJava {
    dependsOn("generateClasses")
}

Kotlin DSL (build.gradle.kts)

yojo {
    configurations {
        create("main") {
            specificationProperties {
                register("api") {
                    specName.set("api.yaml")
                    inputDirectory.set(layout.projectDirectory.dir("contract").asFile.absolutePath)
                    outputDirectory.set(layout.buildDirectory.dir("generated/sources/yojo/api/com/example/api").get().asFile.absolutePath)
                    packageLocation.set("com.example.api")
                }
                register("events-api") {
                    specName.set("events.yaml")
                    inputDirectory.set(layout.projectDirectory.dir("contract").asFile.absolutePath)
                    outputDirectory.set(layout.buildDirectory.dir("generated/sources/yojo/events").get().asFile.absolutePath)
                    packageLocation.set("events")
                }
            }

            springBootVersion.set("3.2.0")
            lombok {
                enable.set(true)
                allArgsConstructor.set(true)
                noArgsConstructor.set(true)
                accessors {
                    enable.set(true)
                    fluent.set(false)
                    chain.set(true)
                }
                equalsAndHashCode {
                    enable.set(true)
                    callSuper.set(false)
                }
            }
        }
    }
}

sourceSets {
    main {
        java {
            srcDir(layout.buildDirectory.dir("generated/sources/yojo"))
        }
    }
}

tasks.compileJava {
    dependsOn("generateClasses")
}

β†’ Output structure:

build/generated/sources/yojo/
β”œβ”€β”€ api/
β”‚   β”œβ”€β”€ common/      # DTOs, enums, interfaces
β”‚   └── messages/    # message payloads
└── events-api/    # same structure

πŸ“‹ Configuration Attributes Reference

Top-level: yojo { }

Attribute Type Description
configurations NamedDomainObjectContainer<YojoConfig> Container for independent generation configs

configurations { create("name") { ... } }

Attribute Type Required Description Example
specificationProperties NamedDomainObjectContainer<SpecificationProperties> βœ… List of AsyncAPI specs to generate register("api") { ... }
springBootVersion(...) String β€” Selects jakarta (β‰₯3.0) or javax (≀2.7) validation springBootVersion("3.2.0")
lombok { ... } closure β€” Lombok configuration see below

specificationProperties { register("id") { ... } }

Attribute Type Required Description Example
specName(...) String βœ… Filename of AsyncAPI spec (.yaml, .yml) specName("asyncapi.yaml")
inputDirectory(...) String βœ… Absolute path to spec directory layout.projectDirectory.dir("contract").asFile.absolutePath
outputDirectory(...) String βœ… Absolute path to output root layout.buildDirectory.dir("generated/sources/yojo/api").get().asFile.absolutePath
packageLocation(...) String βœ… Base Java package (without .common/.messages) packageLocation("com.example.api")

πŸ“ Generated packages:

  • com.example.api.common.*
  • com.example.api.messages.*

lombok { ... }

Attribute Type Default Description Java Effect
enable(...) boolean true Enable Lombok annotations @Data
allArgsConstructor(...) boolean false Generate @AllArgsConstructor @AllArgsConstructor
noArgsConstructor(...) boolean true Generate @NoArgsConstructor @NoArgsConstructor
accessors { ... } closure β€” Configure @Accessors see below
equalsAndHashCode { ... } closure β€” Configure @EqualsAndHashCode see below

accessors { ... }

Attribute Type Default Description
enable(...) boolean false Enable @Accessors
fluent(...) boolean false fluent = true β†’ obj.field(val) instead of obj.setField(val)
chain(...) boolean false chain = true β†’ setters return this

β†’ @Accessors(fluent = false, chain = true)

equalsAndHashCode { ... }

Attribute Type Default Description
enable(...) boolean false Enable @EqualsAndHashCode
callSuper(...) boolean null callSuper = true/false β†’ @EqualsAndHashCode(callSuper = true)

βœ… Supported AsyncAPI Features

Feature YAML Example β†’ Java
multipleOf: 0.01 multipleOf: 0.01 @Digits(integer = 1, fraction = 2)
realization: ArrayList items: { ..., realization: ArrayList } List<T> field = new ArrayList<>();
Enum + x-enumNames x-enumNames: { SUCCESS: "Ok" } SUCCESS("Ok") + String getValue()
Enum case conversion enum: [success-case, "\r\n"] SUCCESS_CASE, CARRIAGE_RETURN_LINE_FEED
pathForGenerateMessage pathForGenerateMessage: 'io.github.events' package io.github.events;
removeSchema: true payload: { $ref: X, removeSchema: true } Only fields in message, no X.java
Inheritance extends: { fromClass: BaseEntity } class Dto extends BaseEntity { ... }
Interfaces format: interface, methods: [...] interface Service { Type method(...); }
format: existing format: existing, name: User, package: com.domain private User user; + import com.domain.User;

πŸ—Ί Roadmap

Feature Status
Jackson annotations (@JsonProperty, @JsonFormat) βœ… In development
AsyncAPI spec validation (pre-generation) βœ… In development
Lombok extensions (@Builder, @SuperBuilder) βœ… In development
OpenAPI 3.1 support 🚧 Planned Q2 2026

πŸ“¬ Contact

πŸ™Œ Send your AsyncAPI spec β€” I’ll help you integrate.
🐞 PRs and issues are welcome!


βš–οΈ License

Distributed under the Apache License 2.0.
See LICENSE.md.


πŸš€ AsyncAPI β†’ Java β€” fast, precise, zero manual work.
Let’s generate some code!

About

This is gradle-plugin for spring-boot application.

Resources

License

Stars

Watchers

Forks

Packages

No packages published