HN 표시: Avro 스키마에서 Java POJO를 생성하는 Gradle Avro 플러그인
hackernews
|
|
📦 오픈소스
#review
원문 출처: hackernews · Genesis Park에서 요약 및 분석
요약
Apache Avro 컴파일러를 래핑하여 .avsc 파일에서 Java 클래스를 생성해주는 Gradle 플러그인이 공개되었습니다. 이 플러그인은 Gradle 7.3 이상과 호환되며, 별도의 설정 없이 기본 경로를 사용하거나 사용자가 필요에 따라 입출력 디렉터리를 지정할 수 있습니다. `generateAvroJava` 태스크를 실행하면 설정된 소스 디렉터리 내의 모든 스키마 파일을 찾아 Java 소스로 변환하고 메인 소스 세트에 추가합니다.
본문
A Gradle plugin that wraps Apache Avro Compiler to generate Java classes from .avsc files. Add the plugin to your build.gradle.kts file: plugins { id("io.github.flumennigrum.gradle.avro") version "0.1.0" } Add avro to the dependencies block in build.gradle.kts file: dependencies { // other dependencies implementation("org.apache.avro:avro:AVRO_VERSION_HERE") // more dependencies } Default values: - input directory: src/main/avro - output directory: build/generated/source/avro/main If your project structure follows the default values, you're good to go, no more configuration needed! If you need to change the default values, you can configure the plugin using the avro extension block: avro { // Input directory for Avro schema files (.avsc) source.from("src/main/custom-avro-directory") // Output directory for generated Java sources outputDir.set(layout.buildDirectory.dir("generated/source/custom-avro-directory/main")) } The plugin registers a task named generateAvroJava : ./gradlew generateAvroJava This task will: - Find all .avsc files in the configured source directory. - Generate Java classes using Avro's SpecificCompiler . - Add the generated sources to the main Java source set. This plugin is compatible with Gradle 7.3 and later. See CONTRIBUTING.md for details. PRs and issues are welcome! This project is licensed under the Apache License, Version 2.0.
Genesis Park 편집팀이 AI를 활용하여 작성한 분석입니다. 원문은 출처 링크를 통해 확인할 수 있습니다.
공유