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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<groupId>io.github.ascopes</groupId>
<artifactId>protobuf-maven-plugin-parent</artifactId>
<version>3.8.3-SNAPSHOT</version>
<version>3.9.0-SNAPSHOT</version>

<name>Protobuf Maven Plugin Parent</name>
<description>Parent POM for the Protobuf Maven Plugin.</description>
Expand Down
2 changes: 1 addition & 1 deletion protobuf-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>io.github.ascopes</groupId>
<artifactId>protobuf-maven-plugin-parent</artifactId>
<version>3.8.3-SNAPSHOT</version>
<version>3.9.0-SNAPSHOT</version>
</parent>

<artifactId>protobuf-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Copyright (C) 2023 - 2025, Ashley Scopes.
#
# 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.
#

invoker.goals = clean package
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (C) 2023 - 2025, Ashley Scopes.

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.

-->
<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>

<parent>
<groupId>@project.groupId@.it</groupId>
<artifactId>integration-test-parent</artifactId>
<version>@project.version@</version>
<relativePath>../setup/pom.xml</relativePath>
</parent>

<groupId>gh-782-sanctioned-executable-paths</groupId>
<artifactId>gh-782-sanctioned-executable-paths</artifactId>

<properties>
<protobuf.version>4.28.2</protobuf.version>

</properties>

<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</dependency>

<dependency>
<groupId>com.salesforce.servicelibs</groupId>
<artifactId>reactor-grpc-stub</artifactId>
</dependency>

<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
</dependency>

<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
</dependency>

<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
</dependency>

<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
</dependency>

<!-- See https://github.com/grpc/grpc-java/issues/9179 -->
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>

<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>

<configuration>
<binaryMavenPlugins>
<binaryMavenPlugin>
<groupId>io.grpc</groupId>
<artifactId>protoc-gen-grpc-java</artifactId>
<version>${grpc.version}</version>
</binaryMavenPlugin>
</binaryMavenPlugins>

<jvmMavenPlugins>
<jvmMavenPlugin>
<groupId>com.salesforce.servicelibs</groupId>
<artifactId>reactor-grpc</artifactId>
<version>${reactor-grpc.version}</version>
</jvmMavenPlugin>
</jvmMavenPlugins>

<sanctionedExecutablePath>${java.io.tmpdir}/pmp-gh-782-sanctioned-executable-paths</sanctionedExecutablePath>
</configuration>

<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (C) 2023 - 2025, Ashley Scopes.
*
* 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.
*/
import java.nio.file.FileVisitResult
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.SimpleFileVisitor

Path tempDir = Path.of(System.getProperty("java.io.tmpdir"))
Path sanctionedDir = tempDir.resolve("pmp-gh-782-sanctioned-executable-paths")

Files.walkFileTree(sanctionedDir, new SimpleFileVisitor<Path>() {
FileVisitResult visitFile(Path file, BasicFileAttributes _) {
println("Dropping file ${file}")
Files.delete(file)
return FileVisitResult.CONTINUE
}

FileVisitResult postVisitDirectory(Path dir, IOException _) {
println("Dropping dir ${dir}")
Files.delete(dir)
return FileVisitResult.CONTINUE
}
})

return true
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (C) 2023 - 2025, Ashley Scopes.
*
* 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.
*/
import java.nio.file.Files
import java.nio.file.Path

Path tempDir = Path.of(System.getProperty("java.io.tmpdir"))

// We use /tmp for this to work around Windows problems
// with https://github.com/ascopes/protobuf-maven-plugin/pull/786
Files.createDirectories(tempDir.resolve("pmp-gh-782-sanctioned-executable-paths"))

return true
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (C) 2023 - 2025, Ashley Scopes.
*
* 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.
*/
package org.example.helloworld;

import reactor.core.publisher.Mono;

public class ReactorGreetingServiceImpl extends ReactorGreetingServiceGrpc.GreetingServiceImplBase {
@Override
public Mono<GreetingResponse> greet(Mono<GreetingRequest> request) {
return request.map(body -> GreetingResponse.newBuilder()
.setText("Hello, " + body.getName() + "!")
.build());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// Copyright (C) 2023 - 2025, Ashley Scopes.
//
// 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 = "org.example.helloworld";

package org.example.helloworld;

message GreetingRequest {
string name = 1;
}

message GreetingResponse {
string text = 1;
}

service GreetingService {
rpc Greet(GreetingRequest) returns (GreetingResponse);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (C) 2023 - 2025, Ashley Scopes.
*
* 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.
*/
package org.example.helloworld;

import static org.junit.jupiter.api.Assertions.assertEquals;

import io.grpc.ManagedChannelBuilder;
import io.grpc.ServerBuilder;
import org.junit.jupiter.api.Test;

class ReactorGreetingServiceImplTest {
@Test
void greetingServiceWorksAsExpected() throws Throwable {
// Given
var service = new ReactorGreetingServiceImpl();
var server = ServerBuilder
.forPort(8084)
.addService(service)
.build();
var channel = ManagedChannelBuilder.forAddress("localhost", 8084)
.usePlaintext()
.build();
var stub = ReactorGreetingServiceGrpc.newReactorStub(channel);

try {
server.start();

// When
var request = GreetingRequest
.newBuilder()
.setName("Dave")
.build();
var response = stub.greet(request).block();

// Then
assertEquals("Hello, Dave!", response.getText());
} finally {
server.shutdown();
server.awaitTermination();
}
}
}
Loading
Loading