mscheong01 / krotoDC

Protobuf Kotlin Dataclass, Converter & Custom Kotlin Coroutine gRPC Generator
Apache License 2.0
92 stars 8 forks source link

Windows support #1

Closed ymarco closed 1 year ago

ymarco commented 1 year ago

Hi! The plugin seems to work fine on Linux, but on windows I've reached this problem:

// test.proto
syntax = "proto3";
message Test {}
:: run-krotoDC.cmd
java -jar protoc-gen-krotodc-1.0.0-jdk8.jar %*

Now run protoc --plugin=protoc-gen-krotoDC=run-krotoDC.cmd --krotoDC_out=. test.proto, and we get:

--krotoDC_out: protoc-gen-krotoDC: Plugin output is unparseable: \r\nC:\\Users\...>java -jar protoc-gen-krotoDC-1.0.0-jdk8.jar \r\n\020\001z\214\001\n\020/krotodc/Test.ktzxpackage krotodc\n\nimport io.github.mscheong01.krotodc.Krotodc\n\n@KrotoDC(forProto = Test.Test::class)\npublic class Test()\nz\225\004\n\037/krotodc/test/TestConverters.ktz\361\003package krotodc.test\n\nImport.....

To me it seems like a \n / \r\n issue. Any thoughts?

mscheong01 commented 1 year ago

It clearly does seem like an issue 😓 tbh, I've never used, or considered Windows in the process of developing this library. I'll take a look at other kotlin code generation libraries and find out what I should do to solve this. Thanks for the report! 🙇‍♂️

mscheong01 commented 1 year ago

I'm having trouble getting to the cause of this issue because I don't have a viable windows environment around me that I could debug this with. I think it will take me a few weeks to get this fixed 😢 One thing I noticed from other codegen libraries is that they don't seem to use different line separators 🤔. kotlinpoet also uses "\n" as a linebreaker, and it's hard to think that they haven't considered Windows so there might be a chance that the setup in which you ran the test may have something to do with it. i'll keep this thread updated on my progress and feel free to help me while I'm at it.

ymarco commented 1 year ago

so there might be a chance that the setup in which you ran the test may have something to do with it.

I'll try to run it in another windows machine on the weekend

ymarco commented 1 year ago

Yep, I get the same output on another laptop with freshly-installed java and protoc.

mscheong01 commented 1 year ago

@ymarco, thank you for verifying it again 🙇‍♂️. I plan to get my hands on a Windows computer this weekend and hope to fix the issue soon.

mscheong01 commented 1 year ago

Hi @ymarco :wave: I recently had the opportunity to debug this issue on a Windows system and identified a solution. Simply include @ECHO OFF in your .cmd file, like this:

:: run-krotoDC.cmd
@ECHO OFF
java -jar protoc-gen-krotodc-1.0.1-jdk8.jar %*

I discovered this fix by examining how the protobuf-gradle-plugin executes the plugins (link). As it turns out, the parsing error was not related to line separators, but rather caused by echoed commands. Please let me know if this resolves the issue for you. If the problem persists, feel free to reopen this issue so I can address it further.