Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gernerate serices will rerwite the message class #11085

Open
baozi-2019 opened this issue Apr 8, 2024 · 4 comments
Open

Gernerate serices will rerwite the message class #11085

baozi-2019 opened this issue Apr 8, 2024 · 4 comments
Labels
question Waiting on reporter there was a request for more information without a response or answer or advice has been provided

Comments

@baozi-2019
Copy link

protoc version: libprotoc 26.0

shell: protoc --plugin=protoc-gen-grpc-java=/protoc-gen-grpc-java-1.63.0-osx-aarch_64.exe --proto_path=/xx/proto --java_out=/xx/java paged.proto user.proto

mvn plugin: kr.motd.maven:protobuf-maven-plugin:1.7.1

I used the Maven plugin to generate the class again. However, when executing compile custom, it will overwrite the result of the compile command, resulting in the message not being generated. I don't know how to solve this problem, please help me.

paged.proto

syntax = "proto3";

option java_multiple_files=false;
option java_package="com.baozi.api";
option java_outer_classname="PagedRequest";
option go_package = "/internal/service/out";

package com.baozi.api;

message PagedRequestDTO {
  uint32 pageNum = 1;
  uint32 pageSize = 2;
}

user.proto

syntax = "proto3";

option java_multiple_files=false;
option java_package="com.baozi.api";
option java_outer_classname="UserServiceGrpc";

package com.baozi.api;

import "google/protobuf/timestamp.proto";
import "google/protobuf/empty.proto";
import "paged.proto";

service UserService {
  rpc loginByPassword(LoginByPasswordReqDTO) returns(UserInfoWithPswOrAuthRespDTO);
    rpc queryUserByAccount(QueryUserByAccountReqDTO) returns(UserInfoWithPswOrAuthRespDTO);
    rpc getUserRolesAndPermissions(RolesAndPermissionsReqDTO) returns(RolesAndPermissionsRespDTO);
    rpc getUserAllInfoByUserId(GetUserAllInfoByUserIdReqDTO) returns(UserInfoWithPswOrAuthRespDTO);
    rpc getUserList(GetUserListReqDTO) returns(GetUserListRespDTO);
    rpc add(AddUserReqDTO) returns(AddUserRespDTO);
    rpc update(UpdateUserReqDTO) returns(UpdateUserRespDTO);
    rpc delete(DeleteUserReqDTO) returns(google.protobuf.Empty);
}

message LoginByPasswordReqDTO {
  string username = 1;
  bytes password = 2;
}

message QueryUserByAccountReqDTO {
  string account = 1;
  LoginAccountTypeEnum accountType = 2;
}

enum LoginAccountTypeEnum {
  USERNAME = 0;
  Phone = 1;
  EMAIL = 2;
}

message RolesAndPermissionsReqDTO {
  uint64 userId = 1;
}

message RolesAndPermissionsRespDTO {
  repeated string roles = 1;
  repeated string permissions = 2;
}

message UserInfoWithPswOrAuthRespDTO {
  uint64 userId = 1;
  string username = 2;
  string realName = 3;
  string phone = 4;
  string email = 5;
  uint32 sex = 6;
  string address = 7;
  google.protobuf.Timestamp createTime = 8;
  uint64 createUserId = 9;
  google.protobuf.Timestamp updateTime = 10;
  uint64 updateUserId = 11;
  oneof inner {
    AuthDTO auth = 12;
    PswDTO psw = 13;
  }
}

message AuthDTO {
  repeated string permissions = 12;
  repeated string roles = 13;
}
message PswDTO {
  bytes password = 4;
}

message GetUserAllInfoByUserIdReqDTO {
  uint64 userId = 1;
}

message GetUserListReqDTO {
    string username = 1;
    com.baozi.api.PagedRequestDTO page = 2;
}

message GetUserListRespDTO {
  repeated UserInfoWithPswOrAuthRespDTO userRespDTOs = 1;
  uint32 count = 2;
}

message AddUserReqDTO {
  uint64 userId = 1;
  string username = 2;
  string realName = 3;
  bytes password = 4;
  string phone = 5;
  string email = 6;
  google.protobuf.Timestamp createTime = 7;
  uint64 createUserId = 8;
}

message AddUserRespDTO {
  int32 resultCode = 1;
  repeated string repeatedParams = 2;
}

message UpdateUserReqDTO {
  uint64 userId = 1;
  string username = 2;
  string realName = 3;
  string password = 4;
  string phone = 5;
  string email = 6;
  uint64 updateUserId = 7;
}

message UpdateUserRespDTO {
  int32 resultCode = 1;
  repeated string repeatedParams = 2;
}

message DeleteUserReqDTO {
  uint64 userId = 1;
}
@temawi
Copy link
Contributor

temawi commented Apr 9, 2024

Are you saying that manually running protoc generates Java code for you but when you build your Maven project that code is removed?

I don't know how to help you without understanding your Maven setup. If you can provide a project that can be used to reproduce the issue then maybe we can assist, although this is more of a Maven issue than a gRPC one.

@temawi temawi added the Waiting on reporter there was a request for more information without a response or answer or advice has been provided label Apr 9, 2024
@baozi-2019
Copy link
Author

This is my plugin config.I ran it using the pom plugin.

<build>
        <extensions>
            <extension>
                <groupId>kr.motd.maven</groupId>
                <artifactId>os-maven-plugin</artifactId>
                <version>1.7.1</version>
            </extension>
        </extensions>
        <plugins>
            <plugin>
                <groupId>org.xolstice.maven.plugins</groupId>
                <artifactId>protobuf-maven-plugin</artifactId>
                <version>0.6.1</version>
                <configuration>
                    <protocArtifact>com.google.protobuf:protoc:3.21.7:exe:${os.detected.classifier}</protocArtifact>
                    <pluginId>grpc-java</pluginId>
                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.54.0:exe:${os.detected.classifier}</pluginArtifact>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>compile-custom</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

@baozi-2019
Copy link
Author

I accidentally clicked to close, I'm sorry

@baozi-2019 baozi-2019 reopened this Apr 11, 2024
@sergiitk sergiitk removed the Waiting on reporter there was a request for more information without a response or answer or advice has been provided label Apr 17, 2024
@ejona86
Copy link
Member

ejona86 commented Apr 17, 2024

I don't see anything wrong with that configuration. That looks the same as our example. You are just using normal mvn compile to build? How did you get that protoc command line?

@sergiitk sergiitk added the Waiting on reporter there was a request for more information without a response or answer or advice has been provided label Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Waiting on reporter there was a request for more information without a response or answer or advice has been provided
Projects
None yet
Development

No branches or pull requests

4 participants