Skip to content

Commit c8d66be

Browse files
authored
Merge pull request #783 from ascopes/feature/gh-782-sanctioned-executable-paths
GH-782: Implement ability to use sanctioned executable paths
2 parents 07025ed + 933c08b commit c8d66be

25 files changed

Lines changed: 977 additions & 78 deletions

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
<groupId>io.github.ascopes</groupId>
2323
<artifactId>protobuf-maven-plugin-parent</artifactId>
24-
<version>3.8.3-SNAPSHOT</version>
24+
<version>3.9.0-SNAPSHOT</version>
2525

2626
<name>Protobuf Maven Plugin Parent</name>
2727
<description>Parent POM for the Protobuf Maven Plugin.</description>

protobuf-maven-plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<groupId>io.github.ascopes</groupId>
2424
<artifactId>protobuf-maven-plugin-parent</artifactId>
25-
<version>3.8.3-SNAPSHOT</version>
25+
<version>3.9.0-SNAPSHOT</version>
2626
</parent>
2727

2828
<artifactId>protobuf-maven-plugin</artifactId>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# Copyright (C) 2023 - 2025, Ashley Scopes.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
invoker.goals = clean package
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright (C) 2023 - 2025, Ashley Scopes.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
18+
-->
19+
<project xmlns="http://maven.apache.org/POM/4.0.0"
20+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
22+
<modelVersion>4.0.0</modelVersion>
23+
24+
<parent>
25+
<groupId>@project.groupId@.it</groupId>
26+
<artifactId>integration-test-parent</artifactId>
27+
<version>@project.version@</version>
28+
<relativePath>../setup/pom.xml</relativePath>
29+
</parent>
30+
31+
<groupId>gh-782-sanctioned-executable-paths</groupId>
32+
<artifactId>gh-782-sanctioned-executable-paths</artifactId>
33+
34+
<properties>
35+
<protobuf.version>4.28.2</protobuf.version>
36+
37+
</properties>
38+
39+
<dependencies>
40+
<dependency>
41+
<groupId>com.google.protobuf</groupId>
42+
<artifactId>protobuf-java</artifactId>
43+
</dependency>
44+
45+
<dependency>
46+
<groupId>com.salesforce.servicelibs</groupId>
47+
<artifactId>reactor-grpc-stub</artifactId>
48+
</dependency>
49+
50+
<dependency>
51+
<groupId>io.grpc</groupId>
52+
<artifactId>grpc-protobuf</artifactId>
53+
</dependency>
54+
55+
<dependency>
56+
<groupId>io.grpc</groupId>
57+
<artifactId>grpc-netty</artifactId>
58+
</dependency>
59+
60+
<dependency>
61+
<groupId>io.grpc</groupId>
62+
<artifactId>grpc-stub</artifactId>
63+
</dependency>
64+
65+
<dependency>
66+
<groupId>io.projectreactor</groupId>
67+
<artifactId>reactor-core</artifactId>
68+
</dependency>
69+
70+
<!-- See https://github.com/grpc/grpc-java/issues/9179 -->
71+
<dependency>
72+
<groupId>javax.annotation</groupId>
73+
<artifactId>javax.annotation-api</artifactId>
74+
</dependency>
75+
76+
<dependency>
77+
<groupId>org.junit.jupiter</groupId>
78+
<artifactId>junit-jupiter</artifactId>
79+
<scope>test</scope>
80+
</dependency>
81+
</dependencies>
82+
83+
<build>
84+
<plugins>
85+
<plugin>
86+
<groupId>org.apache.maven.plugins</groupId>
87+
<artifactId>maven-compiler-plugin</artifactId>
88+
</plugin>
89+
90+
<plugin>
91+
<groupId>org.apache.maven.plugins</groupId>
92+
<artifactId>maven-surefire-plugin</artifactId>
93+
</plugin>
94+
95+
<plugin>
96+
<groupId>@project.groupId@</groupId>
97+
<artifactId>@project.artifactId@</artifactId>
98+
99+
<configuration>
100+
<binaryMavenPlugins>
101+
<binaryMavenPlugin>
102+
<groupId>io.grpc</groupId>
103+
<artifactId>protoc-gen-grpc-java</artifactId>
104+
<version>${grpc.version}</version>
105+
</binaryMavenPlugin>
106+
</binaryMavenPlugins>
107+
108+
<jvmMavenPlugins>
109+
<jvmMavenPlugin>
110+
<groupId>com.salesforce.servicelibs</groupId>
111+
<artifactId>reactor-grpc</artifactId>
112+
<version>${reactor-grpc.version}</version>
113+
</jvmMavenPlugin>
114+
</jvmMavenPlugins>
115+
116+
<sanctionedExecutablePath>${java.io.tmpdir}/pmp-gh-782-sanctioned-executable-paths</sanctionedExecutablePath>
117+
</configuration>
118+
119+
<executions>
120+
<execution>
121+
<goals>
122+
<goal>generate</goal>
123+
</goals>
124+
</execution>
125+
</executions>
126+
</plugin>
127+
</plugins>
128+
</build>
129+
</project>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright (C) 2023 - 2025, Ashley Scopes.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
import java.nio.file.FileVisitResult
17+
import java.nio.file.Files
18+
import java.nio.file.Path
19+
import java.nio.file.SimpleFileVisitor
20+
21+
Path tempDir = Path.of(System.getProperty("java.io.tmpdir"))
22+
Path sanctionedDir = tempDir.resolve("pmp-gh-782-sanctioned-executable-paths")
23+
24+
Files.walkFileTree(sanctionedDir, new SimpleFileVisitor<Path>() {
25+
FileVisitResult visitFile(Path file, BasicFileAttributes _) {
26+
println("Dropping file ${file}")
27+
Files.delete(file)
28+
return FileVisitResult.CONTINUE
29+
}
30+
31+
FileVisitResult postVisitDirectory(Path dir, IOException _) {
32+
println("Dropping dir ${dir}")
33+
Files.delete(dir)
34+
return FileVisitResult.CONTINUE
35+
}
36+
})
37+
38+
return true
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (C) 2023 - 2025, Ashley Scopes.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
import java.nio.file.Files
17+
import java.nio.file.Path
18+
19+
Path tempDir = Path.of(System.getProperty("java.io.tmpdir"))
20+
21+
// We use /tmp for this to work around Windows problems
22+
// with https://github.com/ascopes/protobuf-maven-plugin/pull/786
23+
Files.createDirectories(tempDir.resolve("pmp-gh-782-sanctioned-executable-paths"))
24+
25+
return true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (C) 2023 - 2025, Ashley Scopes.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.example.helloworld;
17+
18+
import reactor.core.publisher.Mono;
19+
20+
public class ReactorGreetingServiceImpl extends ReactorGreetingServiceGrpc.GreetingServiceImplBase {
21+
@Override
22+
public Mono<GreetingResponse> greet(Mono<GreetingRequest> request) {
23+
return request.map(body -> GreetingResponse.newBuilder()
24+
.setText("Hello, " + body.getName() + "!")
25+
.build());
26+
}
27+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// Copyright (C) 2023 - 2025, Ashley Scopes.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
syntax = "proto3";
18+
19+
option java_multiple_files = true;
20+
option java_package = "org.example.helloworld";
21+
22+
package org.example.helloworld;
23+
24+
message GreetingRequest {
25+
string name = 1;
26+
}
27+
28+
message GreetingResponse {
29+
string text = 1;
30+
}
31+
32+
service GreetingService {
33+
rpc Greet(GreetingRequest) returns (GreetingResponse);
34+
}
35+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (C) 2023 - 2025, Ashley Scopes.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.example.helloworld;
17+
18+
import static org.junit.jupiter.api.Assertions.assertEquals;
19+
20+
import io.grpc.ManagedChannelBuilder;
21+
import io.grpc.ServerBuilder;
22+
import org.junit.jupiter.api.Test;
23+
24+
class ReactorGreetingServiceImplTest {
25+
@Test
26+
void greetingServiceWorksAsExpected() throws Throwable {
27+
// Given
28+
var service = new ReactorGreetingServiceImpl();
29+
var server = ServerBuilder
30+
.forPort(8084)
31+
.addService(service)
32+
.build();
33+
var channel = ManagedChannelBuilder.forAddress("localhost", 8084)
34+
.usePlaintext()
35+
.build();
36+
var stub = ReactorGreetingServiceGrpc.newReactorStub(channel);
37+
38+
try {
39+
server.start();
40+
41+
// When
42+
var request = GreetingRequest
43+
.newBuilder()
44+
.setName("Dave")
45+
.build();
46+
var response = stub.greet(request).block();
47+
48+
// Then
49+
assertEquals("Hello, Dave!", response.getText());
50+
} finally {
51+
server.shutdown();
52+
server.awaitTermination();
53+
}
54+
}
55+
}

0 commit comments

Comments
 (0)