GithubHelp home page GithubHelp logo

colin-weng-s / krotodc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mscheong01/krotodc

0.0 0.0 0.0 52.62 MB

Protobuf Kotlin Dataclass, Converter & Custom Kotlin Coroutine gRPC Generator

License: Apache License 2.0

Kotlin 100.00%

krotodc's Introduction

krotoDC

krotoDC is a protoc plugin for generating Kotlin data classes and gRPC service/stub from a .proto input. This library makes it easy to work with Protocol Buffers and gRPC in your Kotlin projects.

check out my blog post that introduces krotoDC

Features

  • Generates Kotlin data classes from .proto files

  • Generates Converter extension methods between generated classes and GeneratedMessageV3 classes

  • Generates gRPC service/stub based on the service definition in .proto files

  • Supports Kotlin specific features like nullable fields and sealed oneof classes:

    see the generated code spec here

Installation

In your project's build.gradle.kts file, add the following dependencies:

dependencies {
    implementation("com.google.protobuf:protobuf-java:3.25.3")
    implementation("com.google.protobuf:protobuf-java-util:3.25.3")
    implementation("io.grpc:grpc-stub:1.61.1")
    implementation("io.grpc:grpc-kotlin-stub:1.4.1")
    implementation("io.github.mscheong01:krotoDC-core:1.1.1")
}

Usage

  1. Configure the protobuf plugin in your build.gradle.kts file:
protobuf {
    protoc {
        artifact = "com.google.protobuf:protoc:3.25.3"
    }
    plugins {
        id("grpc") {
            artifact = "io.grpc:protoc-gen-grpc-java:1.61.1"
        }
        id("krotoDC") {
            artifact = "io.github.mscheong01:protoc-gen-krotoDC:1.1.1:jdk8@jar"
        }
    }
    generateProtoTasks {
        all().forEach {
            it.plugins {
                id("grpc")
                id("krotoDC")
            }
        }
    }
}
  1. Create your .proto files with your message and service definitions.

  2. Build your project, and the plugin will generate Kotlin data classes and gRPC service/stub based on the .proto files.

Snapshot Versions

krotoDC provides snapshot versions that are automatically released when changes are pushed to the main branch. The current snapshot version is the next minor version of the current release version with a -SNAPSHOT suffix. For example, if the current release is 1.2.3, the snapshot version will be 1.3.0-SNAPSHOT.

To use snapshot versions, add the maven snapshot repository to your build configuration

repositories {
    maven {
        url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
    }
}

Contributing

Contributions are welcome! Please see our contributing guidelines for more information.

License

This project is licensed under the Apache 2.0 License.

krotodc's People

Contributors

mscheong01 avatar davin111 avatar dogacel avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.