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
4 changes: 2 additions & 2 deletions .github/workflows/check-samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
matrix:
include:
- javaVersion: 17
springBootVersion: "3.5.5"
springBootVersion: "4.0.0-RC2"
- javaVersion: 17
springBootVersion: "3.5.0-SNAPSHOT"
springBootVersion: "4.0.0-SNAPSHOT"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
18 changes: 14 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,21 @@
<description>Building gRPC applications with Spring Boot</description>

<modules>
<!-- Spring gRPC modules -->
<module>spring-grpc-build-dependencies</module>
<module>spring-grpc-docs</module>
<module>spring-grpc-dependencies</module>
<module>spring-grpc-core</module>
<!-- <module>samples</module>-->
<module>spring-grpc-dependencies</module>
<module>spring-grpc-docs</module>
<module>samples</module>

<!-- Spring Boot modules -->
<module>spring-grpc-client-spring-boot-autoconfigure</module>
<module>spring-grpc-client-spring-boot-starter</module>
<module>spring-grpc-server-spring-boot-autoconfigure</module>
<module>spring-grpc-server-spring-boot-starter</module>
<module>spring-grpc-server-web-spring-boot-starter</module>
<module>spring-grpc-spring-boot-starter</module>
<module>spring-grpc-test-spring-boot-autoconfigure</module>
</modules>

<organization>
Expand Down Expand Up @@ -70,7 +80,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>17</java.version>
<!-- internal dependencies -->
<spring-boot.version>4.0.0-SNAPSHOT</spring-boot.version>
<spring-boot.version>4.0.0-RC2</spring-boot.version>
<jackson.version>2.20.0</jackson.version>
<junit.version>5.13.4</junit.version>
<assertj.version>3.27.4</assertj.version>
Expand Down
2 changes: 1 addition & 1 deletion samples/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
19 changes: 12 additions & 7 deletions samples/grpc-client/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.5.5'
id 'io.spring.dependency-management' version '1.1.6'
id 'org.springframework.boot' version '4.0.0-RC2'
id 'io.spring.dependency-management' version '1.1.7'
id 'com.google.protobuf' version '0.9.4'
}

Expand All @@ -28,13 +28,18 @@ dependencyManagement {
}

dependencies {
implementation 'org.springframework.grpc:spring-grpc-client-spring-boot-starter'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.grpc:spring-grpc-test'
testImplementation 'org.springframework.experimental.boot:spring-boot-testjars-maven:0.0.3'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
implementation 'org.springframework.grpc:spring-grpc-client-spring-boot-starter'

testImplementation 'org.springframework.grpc:spring-grpc-test-spring-boot-autoconfigure'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.boot:spring-boot-web-server'
testImplementation 'org.springframework.experimental.boot:spring-boot-testjars-maven:0.4.0.0-RC1'
testImplementation 'io.grpc:grpc-inprocess'

testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}


tasks.named('test') {
useJUnitPlatform()
}
Expand Down
26 changes: 21 additions & 5 deletions samples/grpc-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.5</version>
<version>4.0.0-RC2</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>org.springframework.grpc</groupId>
Expand All @@ -29,8 +29,8 @@
</scm>
<properties>
<java.version>17</java.version>
<spring-javaformat-maven-plugin.version>0.0.39</spring-javaformat-maven-plugin.version>
<protobuf-java.version>4.31.1</protobuf-java.version>
<spring-javaformat-maven-plugin.version>0.0.43</spring-javaformat-maven-plugin.version>
<protobuf-java.version>4.32.1</protobuf-java.version>
<grpc.version>1.76.0</grpc.version>
<maven.version>3.9.4</maven.version>
<maven.resolver.version>1.9.18</maven.resolver.version>
Expand All @@ -46,6 +46,7 @@
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.springframework.grpc</groupId>
Expand All @@ -54,13 +55,28 @@

<dependency>
<groupId>org.springframework.grpc</groupId>
<artifactId>spring-grpc-test</artifactId>
<artifactId>spring-grpc-test-spring-boot-autoconfigure</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-web-server</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.experimental.boot</groupId>
<artifactId>spring-boot-testjars-maven</artifactId>
<version>0.0.3</version>
<version>0.4.0.0-RC1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-inprocess</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
spring.application.name=grpc-client
spring.grpc.client.default-channel.address=static://0.0.0.0:9090
spring.grpc.client.default-channel.address=static://0.0.0.0:${launched.grpc.port}

#logging.level.org.springframework.experimental.boot.server.exec=debug
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@
import org.springframework.util.FileCopyUtils;

/**
* An {@link ApplicationListener} that saves embedded server port and management port into
* file. This application listener will be triggered whenever the server starts, and the
* file name can be overridden at runtime with a System property or environment variable
* named "PORTFILE" or "portfile".
* An {@link ApplicationListener} that saves the gRPC server port into a file. This
* application listener will be triggered whenever the gRPC server starts, and the file
* name can be overridden at runtime with a System property or environment variable named
* "PORTFILE" or "portfile".
*
* <b>NOTE:</b> This is currently required in order to use spring-boot-testjars as it
* expects this file to be available in order to determine the port of the dynamically
* launched gRPC server.
*
* @author David Liu
* @author Phillip Webb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
public class DefaultDeadlineSetupTests {

@Nested
@SpringBootTest(properties = { "spring.grpc.client.default-channel.address=static://0.0.0.0:${local.grpc.port}",
"spring.grpc.client.default-channel.default-deadline=1s" })
@SpringBootTest(properties = "spring.grpc.client.default-channel.default-deadline=1s")
@DirtiesContext
@EnabledIf("serverJarAvailable")
class Deadline {
Expand All @@ -48,11 +47,12 @@ void contextLoads() {
static class ExtraConfiguration {

@Bean
@DynamicProperty(name = "local.grpc.port", value = "port")
@DynamicProperty(name = "launched.grpc.port", value = "port")
static CommonsExecWebServerFactoryBean grpcServer() {
return CommonsExecWebServerFactoryBean.builder()
.classpath(classpath -> classpath
.entries(new MavenClasspathEntry("org.springframework.grpc:grpc-server-sample:1.0.0-SNAPSHOT"))
.entries(MavenClasspathEntry.springBootDependency("spring-boot-web-server"))
.files("target/test-classes"));
}

Expand All @@ -76,8 +76,7 @@ public CommandLineRunner otherRunner(SimpleGrpc.SimpleBlockingStub stub) {
}

@Nested
@SpringBootTest(properties = { "spring.grpc.client.default-channel.address=static://0.0.0.0:${local.grpc.port}",
"spring.grpc.client.default-channel.default-deadline=1s" })
@SpringBootTest(properties = "spring.grpc.client.default-channel.default-deadline=1s")
@DirtiesContext
@EnabledIf("serverJarAvailable")
class WithoutDeadline {
Expand All @@ -96,11 +95,12 @@ void contextLoads() {
static class ExtraConfiguration {

@Bean
@DynamicProperty(name = "local.grpc.port", value = "port")
@DynamicProperty(name = "launched.grpc.port", value = "port")
static CommonsExecWebServerFactoryBean grpcServer() {
return CommonsExecWebServerFactoryBean.builder()
.classpath(classpath -> classpath
.entries(new MavenClasspathEntry("org.springframework.grpc:grpc-server-sample:1.0.0-SNAPSHOT"))
.entries(MavenClasspathEntry.springBootDependency("spring-boot-web-server"))
.files("target/test-classes"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.springframework.experimental.boot.test.context.EnableDynamicProperty;
import org.springframework.test.annotation.DirtiesContext;

@SpringBootTest(properties = "spring.grpc.client.default-channel.address=static://0.0.0.0:${local.grpc.port}")
@SpringBootTest
@DirtiesContext
@EnabledIf("serverJarAvailable")
public class GrpcClientApplicationTests {
Expand All @@ -38,19 +38,18 @@ void contextLoads() {
static class ExtraConfiguration {

@Bean
@DynamicProperty(name = "local.grpc.port", value = "port")
@DynamicProperty(name = "launched.grpc.port", value = "port")
static CommonsExecWebServerFactoryBean grpcServer() {
return CommonsExecWebServerFactoryBean.builder()
.classpath(classpath -> classpath
.entries(new MavenClasspathEntry("org.springframework.grpc:grpc-server-sample:1.0.0-SNAPSHOT"))
.entries(MavenClasspathEntry.springBootDependency("spring-boot-web-server"))
.files("target/test-classes"));
}

@Bean
static BeanDefinitionRegistryPostProcessor startup(WebServer server) {
return registry -> {
server.getPort();
};
return registry -> System.out.println("*** gRPC server started on port " + server.getPort());
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
org.springframework.context.ApplicationListener=\
org.springframework.grpc.autoconfigure.server.GrpcServerPortFileWriter
org.springframework.grpc.autoconfigure.server.GrpcServerPortFileWriter
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
spring:
grpc:
server:
port: ${server.port}
port: ${server.port}

#logging.level:
# org.springframework.experimental.boot.server.exec: debug
17 changes: 9 additions & 8 deletions samples/grpc-oauth2/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.5.5'
id 'io.spring.dependency-management' version '1.1.6'
id 'org.springframework.boot' version '4.0.0-RC2'
id 'io.spring.dependency-management' version '1.1.7'
id 'org.graalvm.buildtools.native' version '0.10.3'
id 'com.google.protobuf' version '0.9.4'
}
Expand All @@ -20,6 +20,7 @@ processTestAot {
}

repositories {
mavenLocal()
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
maven { url 'https://repo.spring.io/snapshot' }
Expand All @@ -34,12 +35,12 @@ dependencyManagement {
dependencies {
implementation 'org.springframework.grpc:spring-grpc-spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'io.grpc:grpc-services'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.grpc:spring-grpc-test'
testImplementation 'org.springframework.experimental.boot:spring-boot-testjars-maven:0.0.4'

testImplementation 'org.springframework.grpc:spring-grpc-test-spring-boot-autoconfigure'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
testImplementation 'org.springframework.experimental.boot:spring-boot-testjars-maven:0.4.0.0-RC1'

testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

Expand Down
19 changes: 10 additions & 9 deletions samples/grpc-oauth2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.5</version>
<version>4.0.0-RC2</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>org.springframework.grpc</groupId>
Expand All @@ -30,7 +30,7 @@
<properties>
<java.version>17</java.version>
<spring-javaformat-maven-plugin.version>0.0.43</spring-javaformat-maven-plugin.version>
<protobuf-java.version>4.31.1</protobuf-java.version>
<protobuf-java.version>4.32.1</protobuf-java.version>
<grpc.version>1.76.0</grpc.version>
</properties>
<dependencyManagement>
Expand All @@ -53,25 +53,26 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
</dependency>

<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-services</artifactId>
<groupId>org.springframework.grpc</groupId>
<artifactId>spring-grpc-test-spring-boot-autoconfigure</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.grpc</groupId>
<artifactId>spring-grpc-test</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.experimental.boot</groupId>
<artifactId>spring-boot-testjars-maven</artifactId>
<version>0.0.4</version>
<version>0.4.0.0-RC1</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

@SpringBootApplication
@Import(AuthenticationConfiguration.class)
public class GrpcServerApplication {
class GrpcServerApplication {

public static final Metadata.Key<String> USER_KEY = Metadata.Key.of("X-USER", Metadata.ASCII_STRING_MARSHALLER);

Expand All @@ -39,4 +39,4 @@ AuthenticationProcessInterceptor jwtSecurityFilterChain(GrpcSecurity grpc) throw
.build();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io.grpc.stub.StreamObserver;

@Service
public class GrpcServerService extends SimpleGrpc.SimpleImplBase {
class GrpcServerService extends SimpleGrpc.SimpleImplBase {

private static Log log = LogFactory.getLog(GrpcServerService.class);

Expand Down Expand Up @@ -45,4 +45,4 @@ public void streamHello(HelloRequest req, StreamObserver<HelloReply> responseObs
responseObserver.onCompleted();
}

}
}
Loading