Git Product home page Git Product logo

lein-protobuf's Introduction

lein-protobuf is a Leiningen plugin for compiling Google Protobuf .proto files into Java .class files. It can be used with or without clojure-protobuf, which is a Clojure wrapper around the Java protobuf API.

Getting started

Add the following to your project.clj file:

:plugins [[lein-protobuf "0.5.0"]]

Replace "0.5.0" with the actual latest version, which you can find at http://clojars.org/lein-protobuf.

Also, you should add the version of the protobuf library to your dependencies in project.clj corresponding to the version of protoc being used:

:dependencies [[com.google.protobuf/protobuf-java "2.6.1"]]

Note: lein-protobuf requires at least version 2.0 of Leiningen.

Usage

By default, lein-protobuf looks for .proto files in resources/proto in your project directory. This was chosen as the default location so that .proto files would also be included in your jar files. You can change this with:

:proto-path "path/to/proto"

You can specify custom protoc executable with:

:protoc "/usr/local/bin/protoc260"

To compile all .proto files in this directory, just run:

lein protobuf

You can also compile specific proto files with:

lein protobuf file1.proto file2.proto

We also add a hook to Leiningen's compile task, so .proto files will automatically be compiled before that task runs. So if you like, you can simply run:

lein compile

Protoc versions

Protoc version lein-protobuf version
2.6.1 0.4.3
2.5.0 0.4.0

Getting Help

If you have any questions or need help, you can find us on IRC in #flatland.

License

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

lein-protobuf's People

Contributors

echeran avatar edvorg avatar glenjamin avatar ninjudd avatar raspasov avatar raynes avatar rymndhng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

lein-protobuf's Issues

lein protobuf (compilation)

I have a file in my project which defines a protobuf like so:
(def Person (protodef Example$Person))

When I run lein protobuf I get an exception telling me Example$Person does not exist
It seems lein is trying to compile my file before compiling the protobuf file

Any idea?

Getting java.lang.AssertionError when I run `lein doc` to generate codox documentation with this plugin installed

lein-protobuf itself works fine, and simply commenting [lein-protobuf "0.3.1"] out restores the correct behaviour of other plugins.

Might be related to leinjacker version lein-protobuf depends on: weavejester/lein-ring#61

Full error:

Exception in thread "main" java.lang.AssertionError: Assert failed: (vector? (:dependencies project []))
    at leinjacker.deps$add_if_missing.invoke(deps.clj:43)
    at leiningen.doc$doc.invoke(doc.clj:16)
    at clojure.lang.Var.invoke(Var.java:415)
    at clojure.lang.AFn.applyToHelper(AFn.java:161)
    at clojure.lang.Var.applyTo(Var.java:532)
    at clojure.core$apply.invoke(core.clj:619)
    at leiningen.core.main$resolve_task$fn__2160.doInvoke(main.clj:148)
    at clojure.lang.RestFn.invoke(RestFn.java:410)
    at clojure.lang.AFn.applyToHelper(AFn.java:161)
    at clojure.lang.RestFn.applyTo(RestFn.java:132)
    at clojure.lang.AFunction$1.doInvoke(AFunction.java:29)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:619)
    at leiningen.core.main$apply_task.invoke(main.clj:188)
    at leiningen.core.main$resolve_and_apply.invoke(main.clj:192)
    at leiningen.core.main$_main$fn__2223.invoke(main.clj:256)
    at leiningen.core.main$_main.doInvoke(main.clj:246)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.lang.Var.invoke(Var.java:415)
    at clojure.lang.AFn.applyToHelper(AFn.java:161)
    at clojure.lang.Var.applyTo(Var.java:532)
    at clojure.core$apply.invoke(core.clj:617)
    at clojure.main$main_opt.invoke(main.clj:335)
    at clojure.main$main.doInvoke(main.clj:440)
    at clojure.lang.RestFn.invoke(RestFn.java:436)
    at clojure.lang.Var.invoke(Var.java:423)
    at clojure.lang.AFn.applyToHelper(AFn.java:167)
    at clojure.lang.Var.applyTo(Var.java:532)
    at clojure.main.main(main.java:37)

Can't find symbol 'eval-in-project'

It seems like the latest release is broken. 0.2-beta3 works fine, but on beta4 leiningen complains about an undefined symbol on line 41 of protobuf.clj.

Project license?

There's no apparent open source license on this project, so terms of use (and extension and etc) are a bit unclear at the moment. Is this project meant to be licensed under the EPL like e.g. clojure-protobuf?

Not setting :protoc in project.clj leads to NullPointerException

Using version 0.5.0, when I try lein run without setting :protoc in project.clj I get the following exception:

> lein run
java.lang.NullPointerException: null
 at clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:301)
    leiningen.protobuf$build_protoc.invokeStatic (protobuf.clj:102)
    leiningen.protobuf$build_protoc.invoke (protobuf.clj:97)
    leiningen.protobuf$protobuf.invokeStatic (protobuf.clj:168)
    leiningen.protobuf$protobuf.doInvoke (protobuf.clj:161)
    clojure.lang.RestFn.invoke (RestFn.java:410)
    lein_protobuf.plugin$hooks$fn__1291.doInvoke (plugin.clj:10)
    clojure.lang.RestFn.applyTo (RestFn.java:139)
    clojure.core$apply.invokeStatic (core.clj:648)
    clojure.core$apply.invoke (core.clj:641)
    robert.hooke$compose_hooks$fn__11923.doInvoke (hooke.clj:40)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.core$apply.invokeStatic (core.clj:646)
    clojure.core$apply.invoke (core.clj:641)
    robert.hooke$run_hooks.invokeStatic (hooke.clj:46)
    robert.hooke$run_hooks.invoke (hooke.clj:45)
    robert.hooke$prepare_for_hooks$fn__11928$fn__11929.doInvoke (hooke.clj:54)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.lang.AFunction$1.doInvoke (AFunction.java:29)
    clojure.lang.RestFn.invoke (RestFn.java:408)
    clojure.lang.Var.invoke (Var.java:379)
    clojure.lang.AFn.applyToHelper (AFn.java:154)
    clojure.lang.Var.applyTo (Var.java:700)
    clojure.core$apply.invokeStatic (core.clj:648)
    clojure.core$apply.invoke (core.clj:641)
    leiningen.core.main$partial_task$fn__5829.doInvoke (main.clj:272)
    clojure.lang.RestFn.invoke (RestFn.java:410)
    clojure.lang.AFn.applyToHelper (AFn.java:154)
    clojure.lang.RestFn.applyTo (RestFn.java:132)
    clojure.lang.AFunction$1.doInvoke (AFunction.java:29)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.core$apply.invokeStatic (core.clj:648)
    clojure.core$apply.invoke (core.clj:641)
    leiningen.core.main$apply_task.invokeStatic (main.clj:322)
    leiningen.core.main$apply_task.invoke (main.clj:308)
    leiningen.core.eval$run_prep_tasks.invokeStatic (eval.clj:50)
    leiningen.core.eval$run_prep_tasks.invoke (eval.clj:42)
    leiningen.core.eval$prep.invokeStatic (eval.clj:85)
    leiningen.core.eval$prep.invoke (eval.clj:72)
    leiningen.core.eval$eval_in_project.invokeStatic (eval.clj:369)
    leiningen.core.eval$eval_in_project.invoke (eval.clj:363)
    leiningen.core.eval$eval_in_project.invokeStatic (eval.clj:367)
    leiningen.core.eval$eval_in_project.invoke (eval.clj:363)
    leiningen.run$run_main.invokeStatic (run.clj:128)
    leiningen.run$run_main.invoke (run.clj:123)
    leiningen.run$run.invokeStatic (run.clj:155)
    leiningen.run$run.doInvoke (run.clj:132)
    clojure.lang.RestFn.invoke (RestFn.java:410)
    clojure.lang.Var.invoke (Var.java:379)
    clojure.lang.AFn.applyToHelper (AFn.java:154)
    clojure.lang.Var.applyTo (Var.java:700)
    clojure.core$apply.invokeStatic (core.clj:648)
    clojure.core$apply.invoke (core.clj:641)
    leiningen.core.main$partial_task$fn__5829.doInvoke (main.clj:272)
    clojure.lang.RestFn.invoke (RestFn.java:410)
    clojure.lang.AFn.applyToHelper (AFn.java:154)
    clojure.lang.RestFn.applyTo (RestFn.java:132)
    clojure.lang.AFunction$1.doInvoke (AFunction.java:29)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.core$apply.invokeStatic (core.clj:648)
    clojure.core$apply.invoke (core.clj:641)
    leiningen.core.main$apply_task.invokeStatic (main.clj:322)
    leiningen.core.main$apply_task.invoke (main.clj:308)
    leiningen.core.main$resolve_and_apply.invokeStatic (main.clj:328)
    leiningen.core.main$resolve_and_apply.invoke (main.clj:324)
    leiningen.core.main$_main$fn__5895.invoke (main.clj:401)
    leiningen.core.main$_main.invokeStatic (main.clj:394)
    leiningen.core.main$_main.doInvoke (main.clj:391)
    clojure.lang.RestFn.invoke (RestFn.java:408)
    clojure.lang.Var.invoke (Var.java:379)
    clojure.lang.AFn.applyToHelper (AFn.java:154)
    clojure.lang.Var.applyTo (Var.java:700)
    clojure.core$apply.invokeStatic (core.clj:646)
    clojure.main$main_opt.invokeStatic (main.clj:314)
    clojure.main$main_opt.invoke (main.clj:310)
    clojure.main$main.invokeStatic (main.clj:421)
    clojure.main$main.doInvoke (main.clj:384)
    clojure.lang.RestFn.invoke (RestFn.java:436)
    clojure.lang.Var.invoke (Var.java:388)
    clojure.lang.AFn.applyToHelper (AFn.java:160)
    clojure.lang.Var.applyTo (Var.java:700)
    clojure.main.main (main.java:37)

Protobuf java files are not included during javac compilation

When running lein protobuf with .proto files in the default directory (resources/proto), after protoc has successfully completed, the java compiler step fails with errors such as:

error: cannot find symbol
    com.google.protobuf.ProtocolStringList
                       ^
  symbol:   class ProtocolStringList
  location: package com.google.protobuf

For this issue, everything was at the latest versions

:plugins [[lein-protobuf "0.4.3"]
:dependencies [[org.clojure/clojure "1.7.0"][org.flatland/protobuf "0.8.1"]]

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.