streem / pbandk

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

Error during local testing `could not find or load main class` #239

Open Dogacel opened 2 years ago

Dogacel commented 2 years ago

I was following the readme and did

> ./gradlew :protoc-gen-pbandk:protoc-gen-pbandk-jvm:assembleDist
> ./gradlew :protoc-gen-pbandk:protoc-gen-pbandk-jvm:installDist

and when I tried to run protoc it gave me the could not find or load main class pbandk.gen.MainKt error. The solution was:

I am not sure which lead to the solution just opening the issue to guide others.

garyp commented 2 years ago

Hmm. We use Java 11 in the CI jobs, so it should definitely work fine with Java 11. How did you run protoc after the installDist step?

Dogacel commented 2 years ago
protoc --plugin=protoc-gen-pbandk=/Users/dogac/workdir/pbandk/protoc-gen-pbandk/jvm/build/install/protoc-gen-pbandk/bin/protoc-gen-pbandk \
--pbandk_out=kotlin_package_mapping="pbandk.*->com.*;testpb->testpb2":src \
*.proto

I was experimenting with the new package mapping option. If Java-11 is already in the CI jobs, probably the first command did the thing. But still, I was having compilation issues when running build with java-11. I was seeing issues with File. When I have some spare time, I will replicate and post the error codes during compilation with java-11.