streem / pbandk

Kotlin Code Generator and Runtime for Protocol Buffers
MIT License
268 stars 37 forks source link

Windows support #45

Open OliverCulleyDeLange opened 4 years ago

OliverCulleyDeLange commented 4 years ago

I'm using the pbandk plugin with google's protobuf-gradle-plugin as per your example. I'm on windows, and the only way i can get it to work is by specifying the path to protoc-get.kotlin.bat in the kotlin plugin block like below. I've cloned the project and built it so thats where it comes from.

protobuf {
   ...
    plugins {
        kotlin {
            // This works on windows, but obviously isn't cross platform. 
            path = 'C:\\Users\\me\\pbandk\\protoc-gen-kotlin\\jvm\\build\\install\\protoc-gen-kotlin\\bin\\protoc-gen-kotlin.bat'
              // This fails, see error below.
//            artifact = 'com.github.streem.pbandk:protoc-gen-kotlin-jvm:0.8.0:jvm8@jar'
        }
    }
    ...
}

Using the jar as suggested in the example gives

* What went wrong:
Execution failed for task ':app:generateDebugProto'.
> protoc: stdout: . stderr: --kotlin_out: protoc-gen-kotlin: %1 is not a valid Win32 application.

The full command args from gradle --info are: [ C:\Users\olly_.gradle\caches\modules-2\files-2.1\com.google.protobuf\protoc\3.11.1\2f33a303623e20f356c70fce00579ae377dbc46b\protoc-3.11.1-windows-x8664.exe, -IC:\Users\olly\myapp\engine-rust\proto\proto, -IC:\Users\olly\myapp\app\build\extracted-protos\main, -IC:\Users\olly\myapp\app\build\extracted-protos\debug, -IC:\Users\olly\myapp\app\build\extracted-include-protos\debug, --plugin=protoc-gen-kotlin=C:\Users\olly.gradle\caches\modules-2\files-2.1\com.github.streem.pbandk\protoc-gen-kotlin-jvm\0.8.0\921451f497c1bfd53d0b145c0e8753b0c0697569\protoc-gen-kotlin-jvm-0.8.0-jvm8.jar, --kotlinout=log=debug:C:\Users\olly\myapp\app/gen/debug/kotlin, {list of .proto files} ]

garyp commented 4 years ago

Hi @OliverCulleyDeLange. The protoc-gen-kotlin-jvm-0.8.0-jvm8.jar file only works on Unix-like systems. On Windows you have to build it locally and specify the path to the protoc-gen-kotlin.bat file, as you've done. I've updated the pbandk README to clarify this.

If you know of a way to build a Java-based self-executing file for Windows, let us know. We definitely would like to support it if it's possible.

garyp commented 4 years ago

Looks like https://github.com/TheBoegl/gradle-launch4j might be able to create a self-executing file on Windows. If someone with access to a Windows machine wants to try that out, we'll gladly accept a PR that integrates that plugin into the pbandk Gradle build.