protoc-gen-validate icon indicating copy to clipboard operation
protoc-gen-validate copied to clipboard

How to use PGV validator for Java

Open banandh opened this issue 1 year ago • 2 comments

Hi,

Was checking options to include gRPC validation in proto file and protoc-gen-validate can add validator method in the generated class and validates the rules mentioned in the proto file.

I have included below plugin in Java Maven project but getting build error. Need help to verify the configuration and just alternates for validating the proto fields.

org.xolstice.maven.plugins protobuf-maven-plugin 0.6.1 com.google.protobuf:protoc:$3.12.2:exe:${os.detected.classifier} protoc-java-pgv compile-custom lang=java java-pgv build.buf.protoc-gen-validate:protoc-gen-validate:0.9.1:exe:${os.detected.classifier}

Build Error: [ERROR] Failed to execute goal org.xolstice.maven.plugins:protobuf-maven-plugin:0.6.1:compile-custom (protoc-java-pgv) o n project grpc-java: Unable to resolve artifact: Missing: [ERROR] ---------- [ERROR] 1) com.google.protobuf:protoc:exe:windows-x86_64:$3.12.2 [ERROR] [ERROR] Try downloading the file manually from the project website. [ERROR] [ERROR] Then, install it using the command: [ERROR] mvn install:install-file -DgroupId=com.google.protobuf -DartifactId=protoc -Dversion=$3.12.2 -Dclassifier= windows-x86_64 -Dpackaging=exe -Dfile=/path/to/file [ERROR] [ERROR] Alternatively, if you host your own repository you can deploy the file there: [ERROR] mvn deploy:deploy-file -DgroupId=com.google.protobuf -DartifactId=protoc -Dversion=$3.12.2 -Dclassifier=wi ndows-x86_64 -Dpackaging=exe -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id] [ERROR] [ERROR] Path to dependency: [ERROR] 1) org.examples.grpc.java:grpc-java:jar:1.0-SNAPSHOT [ERROR] 2) com.google.protobuf:protoc:exe:windows-x86_64:$3.12.2 [ERROR] [ERROR] ---------- [ERROR] 1 required artifact is missing. [ERROR] [ERROR] for artifact: [ERROR] org.examples.grpc.java:grpc-java:jar:1.0-SNAPSHOT [ERROR]

banandh avatar Feb 28 '23 12:02 banandh

Have you been able to resolve? I'm getting similar errors

pmizenin avatar Apr 04 '23 05:04 pmizenin

No i was not able to resolve and couldn't find usage details of this plugin

banandh avatar Apr 18 '23 05:04 banandh

As explained in the README, this project is in maintenance mode. We recommend upgrading to protovalidate.

I'm going to go ahead and close this issue, but feel free to open one against protovalidate if needed. Thanks!

chrispine avatar Feb 29 '24 19:02 chrispine