Skip to content

A powerful Java utility for generating Avro schemas and MapStruct mappers from Java DTO classes with minimal configuration.

License

Notifications You must be signed in to change notification settings

ravinderji/Avro_Schema_And_Mapstruct_Mapper_Generator

Repository files navigation

Avro Schema And MapStruct Mapper Generator

A powerful Java utility for generating Avro schemas and MapStruct mappers from Java DTO classes with minimal configuration.

Java Version Maven Central License: MIT

Features

  • Automatic Schema Generation: Convert Java DTOs to Avro schemas with a single command
  • Bidirectional Mapping: Generate MapStruct mappers for both DTO-to-Avro and Avro-to-DTO conversions
  • Type Support: Handles complex types including:
    • Nested objects and records
    • Enums with custom values
    • Collections (List, Set, Map)
    • Java 8 Date/Time types (LocalDateTime, LocalDate)
    • Custom type conversions
  • Flexible Output: Choose between inline or standalone schema generation
  • Smart Scanning: Automatic discovery of DTO classes with filtering options
  • Build Tool Integration: Seamless integration with Maven and Gradle

Prerequisites

  • Java 17 or higher
  • Maven 3.6.0+ or Gradle 7.0+
  • Dependencies:
    • Avro 1.11.x
    • MapStruct 1.5.x
    • Jackson 2.15.x

Quick Start

Maven

<dependency>
    <groupId>com.example</groupId>
    <artifactId>avro-mapstruct-generator</artifactId>
    <version>1.0.0</version>
</dependency>

Gradle

implementation 'com.example:avro-mapstruct-generator:1.0.0'

Command Line

# Clone the repository
git clone https://github.com/yourusername/avro-mapstruct-generator.git
cd avro-mapstruct-generator

# Build the project
mvn clean install

# Generate schemas and mappers
java -jar target/avro-mapstruct-generator.jar \
    --jar=path/to/your/dto-jar.jar \
    --out=generated \
    --packages=com.your.package

Project Structure

src/
├── main/java/codtumlr/utility/
│   ├── App.java              # Main application entry point
│   ├── AvroSchemaGenerator.java # Avro schema generation logic
│   ├── MapperGenerator.java  # MapStruct mapper generation
│   ├── ClassScanner.java     # Classpath scanning utilities
└── test/                    # Unit and integration tests

Documentation

  • Usage Guide - Detailed usage instructions and examples

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments


Built with ❤️ by Ravinderjeet Singh Nagpal

About

A powerful Java utility for generating Avro schemas and MapStruct mappers from Java DTO classes with minimal configuration.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages