cretz / pb-and-k

Kotlin Code Generator and Runtime for Protocol Buffers
MIT License
139 stars 15 forks source link

Add bootjar so that codegenerator can be included as artifact #14

Closed phcoder closed 5 years ago

phcoder commented 5 years ago

This allows inclusing of pb-and-k from maven without any need of local installation

cretz commented 5 years ago

I don't really use spring (and many others don't either) and in general I'm not wanting to infect my build script with it. Assuming I understand the purpose here, why use maven to get the JAR if you need it all self-contained? If you want a self-contained release, there are release packages downloadable from the release area.

Can you help me understand why you need a self-contained executable boot jar instead of the executable already provided by assemble?

phcoder commented 5 years ago

Many projects are distributed as gradle projects. The expectation is that you can compile them by typing './gradlew assembleDebug' without preinstalling anything. Having to preinstall pb-and-k breaks this expectation with this patch I can put in build.gradle plugins { kotlin { artifact '....' } } and gradle will automatically download pb-and-k. Unfortunately this doesn't work with standard jar. Alternative is to have and distribute throught maven native compilations of protoc-gen-kotlin for linux-i386, linux-x64, osx-i386, osx-x64, windows. I have seen protoc-gen-kotlin-native but so far didn't manage to even compile it: phcoder@penguin:~/pb-and-k$ ./gradlew :protoc-gen-kotlin:protoc-gen-kotlin-native

.....

cretz commented 5 years ago

I have seen protoc-gen-kotlin-native but so far didn't manage to even compile it

I mention in the README under "Not Yet Implemented": "Protobuf code generator in Kotlin Native for easier importing". Currently the protoc-gen-kotlin generator is only built for the JVM. As mentioned in the README, to build the protoc-gen-kotlin code generator:

path/to/gradle :protoc-gen-kotlin:protoc-gen-kotlin-jvm:assembleDist

That builds the artifacts that you can also download in the releases area. To have the artifacts locally, you can run installDist instead of assembleDist and the artifacts will be in the build/install folder.

Maybe if you can tell me exactly what you are trying to do I can help you find the best way.

phcoder commented 5 years ago

Yes "Protobuf code generator in Kotlin Native for easier importing" is exactly what I want. Maybe it would make sense if I prepare the PR to make "Protobuf code generator in Kotlin Native" work?

cretz commented 5 years ago

@phcoder - Sure. The JVM one works fine btw, but a native one would be nice, but it's not a requirement to use the project in any way. I have already done most of the abstraction as common code at protoc-gen-kotlin/protoc-gen-kotlin-common. Just implement Platform.kt for native in protoc-gen-kotlin/protoc-gen-kotlin-native the same way I did for the JVM. You can even just throw from the serviceGenerator method for now.

One of the problems you might run into is converting bytes to CodeGeneratorRequest/CodeGeneratorResponse. This is because you can't dogfood this project until #7 is complete.

phcoder commented 5 years ago

@cretz It seems thatit's possible to remove dependency on platform protobuf libraries. Trying to do it, let's see how it goes. How important is it to keep api source-compatible? I'd like to make Marshaller an abstract class with ByteArrayMarshaller available on all the platforms and then platform providing only functions to read/write from stream

phcoder commented 5 years ago

I'm implementing #7 in pure kotlin. Wait couple of days