Koooooo-7 opened a new pull request, #14411:
URL: https://github.com/apache/dubbo/pull/14411

   ## What is the purpose of the change
   
   
   Build dubbo-compiler as a fat jar could support gradle 
`protobuf-gradle-plugin` run the `dubbo-complier` as protoc plugin correctly.
   BTW, Alternatively, user could build fat jar individually to do the trick 
also, since the plugin can use the jar path directly , either config all the 
necessary stuff to classpath.
   
   ```
      dubbo { 
              path = 
'/paths/dubbo-grpc-gradle-test/fat-dubbo-compiler-3.2.14.jar'
           }
   ```
   
   fix #13679 
   
   
   
   ## Brief changelog
   
   
   ## Verifying this change
   
   Setup a sample project.
   ```
   ├── build.gradle
   ├── settings.gradle
   └── src
       ├── main
       │   ├── java
       │   │   └── org
       │   │       └── example
       │   │           └── Main.java
       │   ├── proto
       │   │   └── helloworld.proto
       └── resources
   
   
   
   ```
   
   > helloworld.proto
   ```proto
   // Copyright 2015 The gRPC Authors
   //
   // Licensed under the Apache License, Version 2.0 (the "License");
   // you may not use this file except in compliance with the License.
   // You may obtain a copy of the License at
   //
   //     http://www.apache.org/licenses/LICENSE-2.0
   //
   // Unless required by applicable law or agreed to in writing, software
   // distributed under the License is distributed on an "AS IS" BASIS,
   // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   // See the License for the specific language governing permissions and
   // limitations under the License.
   syntax = "proto3";
   
   option java_multiple_files = true;
   option java_package = "io.grpc.examples.helloworld";
   option java_outer_classname = "HelloWorldProto";
   option objc_class_prefix = "HLW";
   
   package helloworld;
   
   // The greeting service definition.
   service Greeter {
     // Sends a greeting
     rpc SayHello (HelloRequest) returns (HelloReply) {}
   }
   
   // The request message containing the user's name.
   message HelloRequest {
     string name = 1;
   }
   
   // The response message containing the greetings
   message HelloReply {
     string message = 1;
   }
   ```
   
   > gradle.properties
   ```
   plugins {
       id 'java'
       id "com.google.protobuf" version "0.9.4"
   }
   
   group 'org.example'
   version '1.0-SNAPSHOT'
   
   repositories {
       mavenLocal()
       mavenCentral()
   }
   
   protobuf {
       protoc {
           artifact = 'com.google.protobuf:protoc:3.25.1'
       }
   
       plugins {
   
           grpc {
               artifact = 'io.grpc:protoc-gen-grpc-java:1.65.0'
           }
   
           dubbo {
               artifact = 'org.apache.dubbo:dubbo-compiler:3.2.15-SNAPSHOT'
           }
   
   
       }
   
       generateProtoTasks {
   
           all().configureEach { task ->
               task.plugins {
                   grpc {}
                   dubbo {}
               }
   
           }
       }
   }
   dependencies {
       implementation 'com.google.protobuf:protobuf-java:4.27.2'
       implementation 'org.apache.dubbo:dubbo-common:3.2.14'
   
       runtimeOnly 'io.grpc:grpc-netty-shaded:1.65.0'
       implementation 'io.grpc:grpc-protobuf:1.65.0'
       implementation 'io.grpc:grpc-stub:1.65.0'
       compileOnly 'org.apache.tomcat:annotations-api:6.0.53' // necessary for 
Java 9+
   
   }
   
   
   ```
   > output
   
   
![generated](https://github.com/apache/dubbo/assets/33706142/78df14f9-a124-46d4-95ac-7da48cfbe860)
   
   
   
   
   
   <!-- Follow this checklist to help us incorporate your contribution quickly 
and easily: -->
   
   ## Checklist
   - [x] Make sure there is a 
[GitHub_issue](https://github.com/apache/dubbo/issues) field for the change 
(usually before you start working on it). Trivial changes like typos do not 
require a GitHub issue. Your pull request should address just this issue, 
without pulling in other changes - one PR resolves one issue.
   - [ ] Each commit in the pull request should have a meaningful subject line 
and body.
   - [x] Write a pull request description that is detailed enough to understand 
what the pull request does, how, and why.
   - [ ] Check if is necessary to patch to Dubbo 3 if you are work on Dubbo 2.7
   - [ ] Write necessary unit-test to verify your logic correction, more mock a 
little better when cross module dependency exist. If the new feature or 
significant change is committed, please remember to add sample in [dubbo 
samples](https://github.com/apache/dubbo-samples) project.
   - [ ] Add some description to 
[dubbo-website](https://github.com/apache/dubbo-website) project if you are 
requesting to add a feature.
   - [ ] GitHub Actions works fine on your own branch.
   - [ ] If this contribution is large, please follow the [Software Donation 
Guide](https://github.com/apache/dubbo/wiki/Software-donation-guide).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to