Skip to content

Commit dcbe5e3

Browse files
committed
upgrade to spring boot 3
1 parent 0b92de6 commit dcbe5e3

File tree

5 files changed

+16
-35
lines changed

5 files changed

+16
-35
lines changed

lib/src/main/resources/handlebars/springcodegen/libraries/producer/api.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import org.springframework.kafka.support.KafkaHeaders;
99
import org.springframework.kafka.support.SendResult;
1010
import org.springframework.messaging.Message;
1111
import org.springframework.messaging.support.MessageBuilder;
12-
import org.springframework.util.concurrent.ListenableFuture;
1312

1413
import java.time.Duration;
1514
import java.util.Collections;
1615
import java.util.Map;
16+
import java.util.concurrent.CompletableFuture;
1717
import java.util.concurrent.ExecutionException;
1818
import java.util.concurrent.TimeUnit;
1919
import java.util.concurrent.TimeoutException;
@@ -35,10 +35,10 @@ public class {{classname}} {
3535
.withPayload(event)
3636
.copyHeaders(headers)
3737
.setHeaderIfAbsent(KafkaHeaders.TOPIC, topic)
38-
.setHeaderIfAbsent(KafkaHeaders.MESSAGE_KEY, key)
38+
.setHeaderIfAbsent(KafkaHeaders.KEY, key)
3939
.build();
4040
log.debug("sending message to '{}' topic: '{}'", topic, message);
41-
ListenableFuture<SendResult<String, Object>> future = kafkaOperations.send(message);
41+
CompletableFuture<SendResult<String, Object>> future = kafkaOperations.send(message);
4242
try {
4343
SendResult<String, Object> result = future.get(timeout.getSeconds(), TimeUnit.SECONDS);
4444
log.trace("event is sent to {} topic with result: {}", topic, result);

plugin/src/main/java/com/github/slamdev/openapispringgenerator/plugin/OpenApiTask.java

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@
1515
import org.openapitools.codegen.validation.Invalid;
1616

1717
import javax.inject.Inject;
18-
import java.io.BufferedReader;
19-
import java.io.BufferedWriter;
2018
import java.io.File;
2119
import java.io.IOException;
22-
import java.nio.charset.StandardCharsets;
2320
import java.nio.file.Files;
2421
import java.nio.file.Path;
2522
import java.nio.file.StandardOpenOption;
@@ -162,7 +159,7 @@ public void run() throws IOException {
162159

163160
FileTree resourcesTree = (FileTree) getProject().fileTree(tempDir).exclude("**/*.java");
164161
move(resourcesTree, "resources", (src, dest) -> {
165-
if (!"spring.factories".equals(src.getFileName().toString())) {
162+
if (!"org.springframework.boot.autoconfigure.AutoConfiguration.imports".equals(src.getFileName().toString())) {
166163
throw new IllegalStateException("" + dest + " already exists");
167164
}
168165
mergeSpringFactories(src, dest);
@@ -202,25 +199,9 @@ private void clearDir(Path dir) throws IOException {
202199
}
203200

204201
private void mergeSpringFactories(Path src, Path dest) {
205-
try (BufferedReader srcReader = Files.newBufferedReader(src); BufferedReader destReader = Files.newBufferedReader(dest)) {
206-
Properties srcProps = new Properties();
207-
srcProps.load(srcReader);
208-
209-
Properties destProps = new Properties();
210-
destProps.load(destReader);
211-
212-
for (String key : srcProps.stringPropertyNames()) {
213-
if (destProps.containsKey(key)) {
214-
String merged = destProps.getProperty(key) + "," + srcProps.getProperty(key);
215-
destProps.put(key, merged);
216-
} else {
217-
destProps.put(key, srcProps.getProperty(key));
218-
}
219-
}
220-
221-
try (BufferedWriter writer = Files.newBufferedWriter(dest, StandardCharsets.UTF_8, StandardOpenOption.TRUNCATE_EXISTING)) {
222-
destProps.store(writer, null);
223-
}
202+
try {
203+
byte[] srcContent = Files.readAllBytes(src);
204+
Files.write(dest, srcContent, StandardOpenOption.APPEND);
224205
Files.delete(src);
225206
} catch (IOException e) {
226207
throw new IllegalStateException(e);

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
rootProject.name = 'openapi-spring-generator'
22

3-
include 'plugin', 'cli', 'lib'//, 'showcase:client', 'showcase:server'
3+
include 'plugin', 'cli', 'lib', 'showcase:client', 'showcase:server'

showcase/client/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
buildscript {
22
dependencies {
3-
classpath project(':plugin')
3+
classpath files('../../plugin/build/libs/plugin.jar')
44
}
55
}
66

77
plugins {
88
id 'java'
9-
id 'org.springframework.boot' version '2.3.5.RELEASE'
10-
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
9+
id 'org.springframework.boot' version '3.0.0'
10+
id 'io.spring.dependency-management' version '1.1.0'
1111
id 'pmd'
1212
id 'checkstyle'
13-
id 'com.github.spotbugs' version '4.6.0'
13+
id 'com.github.spotbugs' version '5.0.13'
1414
}
1515

1616
apply plugin: 'com.github.slamdev.openapi-spring-generator'

showcase/server/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
buildscript {
22
dependencies {
3-
classpath project(':plugin')
3+
classpath files('../../plugin/build/libs/plugin.jar')
44
}
55
}
66

77
plugins {
88
id 'java'
9-
id 'org.springframework.boot' version '2.3.5.RELEASE'
10-
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
9+
id 'org.springframework.boot' version '3.0.0'
10+
id 'io.spring.dependency-management' version '1.1.0'
1111
id 'pmd'
1212
id 'checkstyle'
13-
id 'com.github.spotbugs' version '4.6.0'
13+
id 'com.github.spotbugs' version '5.0.13'
1414
}
1515

1616
apply plugin: 'com.github.slamdev.openapi-spring-generator'

0 commit comments

Comments
 (0)