Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void generateCode() throws TRpcCodeGenerateException {
try {
Files.createDirectories(tmpPath);
List<Path> importPaths = prepareImportPaths();
Path descriptorFile = generateDescriptorFile(getProtoFiles(true), importPaths);
Path descriptorFile = generateDescriptorFile(getProtoFiles(false), importPaths);
Files.createDirectories(tmpOutPath);
List<Descriptors.FileDescriptor> fdList = compileDescriptorSet(descriptorFile);
Map<String, Object> customVariables = codeGeneratorHook.getCustomVariables(fdList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,26 @@ public void test4() throws Exception {
assertTrue(Files.exists(base.resolve("pom.xml")));
}

/**
* Simulate 'mvn trpc:gen-code' on maven project at src/test/resources/TEST-5.
*/
public void test5() throws Exception {
executeTest("TEST-5");
Path base = Paths.get("src", "test", "resources", "TEST-5", "target", "generated-sources",
"trpc", "java").toAbsolutePath();
Path output = base.resolve(Paths.get("com", "tencent", "test", "helloworld"));
assertTrue(Files.exists(output));
assertTrue(Files.exists(output.resolve("module1/GreeterAPI.java")));
assertTrue(Files.exists(output.resolve("module1/GreeterAsyncAPI.java")));
assertTrue(Files.exists(output.resolve("module1/GreeterSvr.java")));
assertTrue(Files.exists(output.resolve("module1/GreeterSvrValidator.java")));
assertTrue(Files.exists(output.resolve("module2/GreeterAPI.java")));
assertTrue(Files.exists(output.resolve("module2/GreeterAsyncAPI.java")));
assertTrue(Files.exists(output.resolve("module2/GreeterSvr.java")));
assertTrue(Files.exists(output.resolve("module2/GreeterSvrValidator.java")));
assertTrue(Files.exists(base.resolve("pom.xml")));
}

private void executeTest(String root) throws Exception {
MavenProject project = readMavenProject(new File("src/test/resources/" + root));
MavenSession session = newMavenSession(project);
Expand Down
26 changes: 26 additions & 0 deletions trpc-maven-plugin/src/test/resources/TEST-5/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>trpc-maven-plugin-test</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>

<build>
<plugins>
<plugin>
<groupId>com.tencent.trpc</groupId>
<artifactId>trpc-maven-plugin</artifactId>
<configuration>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto3";
package trpc.test.helloworld.module1;
import "validate.proto";
option java_package = "com.tencent.test.helloworld.module1";
option java_outer_classname = "GreeterSvr";
// 请求协议头
message HelloRequest {
string message = 1 [(validate.rules).string.min_len = 2];
}
// 响应协议头
message HelloResponse {
string message = 1;
}
service Greeter {
rpc sayHello (HelloRequest) returns (HelloResponse);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto3";
package trpc.test.helloworld.module2;
import "validate.proto";
option java_package = "com.tencent.test.helloworld.module2";
option java_outer_classname = "GreeterSvr";
// 请求协议头
message HelloRequest {
string message = 1 [(validate.rules).string.min_len = 2];
}
// 响应协议头
message HelloResponse {
string message = 1;
}
service Greeter {
rpc sayHello (HelloRequest) returns (HelloResponse);
}