Code Monkey home page Code Monkey logo

dart-protoc-builder's Introduction

A Dart build package to compile Protocol Buffer files to Dart source code using build_runner (i.e. the Dart build pipline) without needing to manually install the protoc compiler or the Dart Protobuf plugin protoc_plugin.

The protoc_builder package downloads the necessary Protobuf dependencies for your platform to a temporary local directory, thereby streamlining the development process.

Installation

Add the necessary dependencies to your pubspec.yaml file:

dev_dependencies:
  build_runner: <latest>
  protoc_builder: <latest>

Configuration

You must add your .proto files to a build.yaml file next to the pubspec.yaml:

targets:
  $default:
    sources:
      - $package$
      - lib/$lib$
      - proto/** # Your .proto directory

This will use the default configuration for the protoc_builder.

You may also configure custom options:

targets:
  $default:
    sources:
      - $package$
      - lib/$lib$
      - proto/**
    builders:
      protoc_builder:
        options:
          # The version of the Protobuf compiler to use.
          # (Default: "3.19.1", make sure to use quotation marks)
          protobuf_version: "3.19.1"
          # The version of the Dart protoc_plugin package to use.
          # (Default: "20.0.1", make sure to use quotation marks)
          protoc_plugin_version: "20.0.1"
          # Directory which is treated as the root of all Protobuf files.
          # (Default: "proto/")
          root_dir: "proto/"
          # Include paths given to the Protobuf compiler during compilation.
          # (Default: ["proto/"])
          proto_paths:
            - "proto/"
          # The root directory for generated Dart output files.
          # (Default: "lib/src/proto")
          out_dir: "lib/src/generated"
          # Enable the gRPC flag for the Dart protoc plugin to generate `.pbgrpc.dart` files.
          # (Default: false)
          grpc: true

Running

Once everything is set up, you may simply run the build_runner package:

pub run build_runner build

The build_runner sometimes caches results longer than it should, so in some cases, it may be necessary to delete the .dart_tool/build directory.

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.