Skip to content

升级Spring Cloud 2024.0.0 #234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2025
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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
| 依赖 | 版本 |
| ------------ |----------|
| JDK | 17 |
| Kotlin | 1.8.22 |
| Gradle | 7.6.3 |
| Spring Boot | 3.0.11 |
| Spring Cloud | 2022.0.4 |
| Kotlin | 2.0.21 |
| Gradle | 8.10.2 |
| Spring Boot | 3.4.0 |
| Spring Cloud | 2024.0.0 |

## 示例

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
id("com.tencent.devops.publish") version Versions.DevopsReleasePlugin
}

val projectVersion = rootProject.file("version.txt").readText()
val projectVersion = rootProject.file("version.txt").readText().trim()

allprojects {
group = "com.tencent.devops"
Expand Down
3 changes: 1 addition & 2 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ object Libs {
const val SpringBootGradlePlugin = "org.springframework.boot:spring-boot-gradle-plugin:${Versions.SpringBoot}"
const val DependencyManagement = "io.spring.gradle:dependency-management-plugin:${Versions.DependencyManagement}"
const val KotlinSpringGradlePlugin = "org.jetbrains.kotlin:kotlin-allopen:${Versions.Kotlin}"
const val KtLint = "com.pinterest:ktlint:${Versions.KtLint}"
const val KtLint = "com.pinterest.ktlint:ktlint-cli:${Versions.KtLint}"
const val GoogleJibPlugin = "gradle.plugin.com.google.cloud.tools:jib-gradle-plugin:${Versions.Jib}"
const val GradleNexuxPublishPlugin = "io.github.gradle-nexus:publish-plugin:${Versions.GradleNexusPublish}"
}
Expand All @@ -15,4 +15,3 @@ object MavenBom {
const val SpringCloud = "org.springframework.cloud:spring-cloud-dependencies:${Versions.SpringCloud}"
const val DevOpsBoot = ":devops-boot-project:devops-boot-dependencies"
}

8 changes: 4 additions & 4 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
object Versions {
const val Jib: String = "3.2.0"
const val Java = "17"
const val Kotlin = "1.8.22"
const val SpringBoot = "3.3.2"
const val SpringCloud = "2023.0.3"
const val Kotlin = "2.0.21"
const val SpringBoot = "3.4.0"
const val SpringCloud = "2024.0.0"
const val DependencyManagement = "1.1.6"
const val GradleNexusPublish = "1.3.0"
const val KtLint = "0.50.0"
const val KtLint = "1.3.1"
const val DevopsReleasePlugin = "0.0.9"
}
6 changes: 3 additions & 3 deletions buildSrc/src/main/kotlin/ktlint.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies {
}
}

val outputDir = "${project.buildDir}/reports/ktlint/"
val outputDir = "${project.layout.buildDirectory}/reports/ktlint/"
val inputFiles = project.fileTree(mapOf("dir" to "src", "include" to "**/*.kt"))

val ktlintCheck by tasks.creating(JavaExec::class) {
Expand All @@ -18,7 +18,7 @@ val ktlintCheck by tasks.creating(JavaExec::class) {

description = "Check Kotlin code style."
classpath = ktlint
main = "com.pinterest.ktlint.Main"
mainClass.set("com.pinterest.ktlint.Main")
args = listOf("src/**/*.kt")
}

Expand All @@ -29,6 +29,6 @@ val ktlintFormat by tasks.creating(JavaExec::class) {

description = "Fix Kotlin code style deviations."
classpath = ktlint
main = "com.pinterest.ktlint.Main"
mainClass.set("com.pinterest.ktlint.Main")
args = listOf("-F", "src/**/*.kt")
}
17 changes: 13 additions & 4 deletions devops-boot-project/devops-boot-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
kotlin("jvm")
kotlin("kapt")
Expand Down Expand Up @@ -36,17 +38,24 @@ subprojects {
targetCompatibility = Versions.Java
}
compileKotlin {
kotlinOptions.freeCompilerArgs = listOf("-Xjsr305=strict", "-java-parameters")
kotlinOptions.jvmTarget = Versions.Java
compilerOptions {
freeCompilerArgs.add("-Xjsr305=strict")
freeCompilerArgs.add("-java-parameters")
jvmTarget.set(JvmTarget.fromTarget(Versions.Java))
}
}
compileTestKotlin {
kotlinOptions.jvmTarget = Versions.Java
compilerOptions {
jvmTarget.set(JvmTarget.fromTarget(Versions.Java))
}
}
test {
useJUnitPlatform()
}
withType(org.jetbrains.kotlin.gradle.internal.KaptGenerateStubsTask::class.java).configureEach {
kotlinOptions.jvmTarget = Versions.Java
compilerOptions {
jvmTarget.set(JvmTarget.fromTarget(Versions.Java))
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
com.tencent.devops.logging.LoggingAutoConfiguration
com.tencent.devops.logging.LoggingAutoConfiguration
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ class SpringExtensionRegistry : ExtensionRegistry, ApplicationContextAware {
require(WebApplicationContext::class.java.isAssignableFrom(applicationContext::class.java))
this.applicationContext = applicationContext
this.beanFactory = applicationContext.autowireCapableBeanFactory as DefaultListableBeanFactory
this.requestMappingHandlerMapping = applicationContext.getBean(RequestMappingHandlerMapping::class.java)
this.requestMappingHandlerMapping = applicationContext.getBean(
"requestMappingHandlerMapping",
RequestMappingHandlerMapping::class.java
)
}

override fun registerExtensionController(plugin: String, name: String, type: Class<*>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class PulsarMessageConverter {
ClassUtils.forName(
"com.alibaba.fastjson.support.spring.messaging.MappingFastJsonMessageConverter",
ClassUtils.getDefaultClassLoader()
).newInstance() as MessageConverter
).getDeclaredConstructor().newInstance() as MessageConverter
)
} catch (ignored: ClassNotFoundException) {
// ignore this exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class PulsarInboundChannelAdapter(
concurrency = extendedConsumerProperties.concurrency
)
} catch (e: Exception) {
logger.error("DefaultPulsarConsumer init failed, Caused by " + e.message)
log.error("DefaultPulsarConsumer init failed, Caused by " + e.message)
throw MessagingException(
MessageBuilder.withPayload(
"DefaultPulsarConsumer init failed, Caused by " + e.message
Expand Down Expand Up @@ -132,16 +132,16 @@ class PulsarInboundChannelAdapter(
private fun createListener(): (Consumer<*>, Message<*>) -> Unit {
return { it: Consumer<*>, msg: Message<*> ->
try {
if (logger.isDebugEnabled) {
logger.debug("Message received $msg ${msg.messageId}")
if (log.isDebugEnabled) {
log.debug("Message received $msg ${msg.messageId}")
}
val message = PulsarMessageConverterSupport.convertMessage2Spring(msg)
if (retryTemplate != null) {
retryTemplate!!.execute(
RetryCallback<Any, RuntimeException> { _: RetryContext? ->
sendMessage(message)
if (logger.isDebugEnabled) {
logger.debug("will send acknowledge: ${msg.messageId}")
if (log.isDebugEnabled) {
log.debug("will send acknowledge: ${msg.messageId}")
}
it.acknowledge(msg)
message
Expand All @@ -150,16 +150,16 @@ class PulsarInboundChannelAdapter(
)
} else {
sendMessage(message)
if (logger.isDebugEnabled) {
logger.debug("will send acknowledge: ${msg.messageId}")
if (log.isDebugEnabled) {
log.debug("will send acknowledge: ${msg.messageId}")
}
it.acknowledge(msg)
}
if (logger.isDebugEnabled) {
logger.debug("Message ${msg.messageId} has been consumed")
if (log.isDebugEnabled) {
log.debug("Message ${msg.messageId} has been consumed")
}
} catch (e: Exception) {
logger.warn("Error occurred while consuming message ${msg.messageId}: $e")
log.warn("Error occurred while consuming message ${msg.messageId}: $e")
it.negativeAcknowledge(msg)
}
}
Expand Down Expand Up @@ -187,15 +187,15 @@ class PulsarInboundChannelAdapter(
consumers.add(consumer)
}
} catch (e: Exception) {
logger.error("Error occurred while creating consumer $e")
log.error("Error occurred while creating consumer $e")
}

// val instrumentation = Instrumentation(topic, this)
// try {
// instrumentation.markStartedSuccessfully()
// } catch (e: java.lang.Exception) {
// instrumentation.markStartFailed(e)
// logger.error("PulsarConsumer init failed, Caused by " + e.message)
// log.error("PulsarConsumer init failed, Caused by " + e.message)
// throw MessagingException(
// MessageBuilder.withPayload(
// "PulsarConsumer init failed, Caused by " + e.message
Expand Down Expand Up @@ -228,6 +228,8 @@ class PulsarInboundChannelAdapter(
}

companion object {
private val logger = LoggerFactory.getLogger(PulsarInboundChannelAdapter::class.java)
// 命名为logger会和IntegrationObjectSupport中的logger冲突
// https://youtrack.jetbrains.com/issue/KT-56386
private val log = LoggerFactory.getLogger(PulsarInboundChannelAdapter::class.java)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ object PulsarMessageConverterSupport {
messageBuilder: MessageBuilder<*>
) {
if (!CollectionUtils.isEmpty(properties)) {
properties.forEach { (key: String?, value: String?) ->
properties.forEach { (key: String, value: String) ->
if (MessageHeaders.ID != key &&
MessageHeaders.TIMESTAMP != key
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ServiceBootstrapEnvironmentPostProcessor: EnvironmentPostProcessor, Ordere
with(Properties()) {
if (isConsulPresent()) {
setProperty("spring.cloud.consul.config.name", SERVICE_NAME)
setProperty("spring.cloud.consul.config.prefix", CONSUL_CONFIG_PREFIX)
setProperty("spring.cloud.consul.config.prefixes", CONSUL_CONFIG_PREFIX)
setProperty("spring.cloud.consul.config.format", CONSUL_CONFIG_FORMAT)
setProperty("spring.cloud.consul.config.profile-separator", CONSUL_CONFIG_SEPARATOR)
setProperty("spring.cloud.consul.discovery.service-name", SERVICE_NAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class SwaggerConfiguration {
return GroupedOpenApi.builder()
.pathsToMatch(ALL_PATTERN)
.packagesToScan("com.tencent")
.group("tencent")
.build()
}

Expand Down
12 changes: 7 additions & 5 deletions devops-boot-project/devops-boot-dependencies/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,21 @@ dependencies {
api("com.google.guava:guava:33.2.1-jre")

// swagger
api("io.swagger.core.v3:swagger-annotations:2.2.22")
api("io.swagger.core.v3:swagger-models:2.2.22")
api("io.swagger.core.v3:swagger-jaxrs2:2.2.22")
api("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0")
api("io.swagger.core.v3:swagger-annotations:2.2.25")
api("io.swagger.core.v3:swagger-models:2.2.25")
api("io.swagger.core.v3:swagger-jaxrs2:2.2.25")
api("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.7.0")

// mq stream
api("org.apache.pulsar:pulsar-client:2.9.5")
api("com.google.protobuf:protobuf-java:3.19.6")

// s3
api("com.amazonaws:aws-java-sdk-s3:1.11.700")

// crypto
api("com.tencent.bk.sdk:crypto-java-sdk:1.1.1")

//okhttp
api("com.squareup.okhttp3:okhttp:4.12.0")
}
}
5 changes: 4 additions & 1 deletion devops-boot-project/devops-boot-tools/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

description = "Tools for DevOps Boot"
Expand All @@ -7,7 +8,9 @@ subprojects {

tasks {
getByName<KotlinCompile>("compileKotlin") {
kotlinOptions.jvmTarget = Versions.Java
compilerOptions {
jvmTarget.set(JvmTarget.fromTarget(Versions.Java))
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ class KtLintCheckAction(

override fun execute(javaExec: JavaExec) {
with(javaExec) {
val outputDir = "${project.buildDir}/reports/ktlint/"
val outputDir = "${project.layout.buildDirectory}/reports/ktlint/"
val inputFiles = project.fileTree(mapOf("dir" to "src", "include" to "**/*.kt"))
group = "verification"
inputs.files(inputFiles)
outputs.dir(outputDir)
description = "Check Kotlin code style."
classpath = ktLint
main = "com.pinterest.ktlint.Main"
mainClass.set("com.pinterest.ktlint.Main")
args = listOf("src/**/*.kt")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ class KtLintFormatAction(

override fun execute(javaExec: JavaExec) {
with(javaExec) {
val outputDir = "${project.buildDir}/reports/ktlint/"
val outputDir = "${project.layout.buildDirectory}/reports/ktlint/"
val inputFiles = project.fileTree(mapOf("dir" to "src", "include" to "**/*.kt"))
group = "formatting"
inputs.files(inputFiles)
outputs.dir(outputDir)
description = "Fix Kotlin code style deviations."
classpath = ktLint
main = "com.pinterest.ktlint.Main"
mainClass.set("com.pinterest.ktlint.Main")
args = listOf("-F", "src/**/*.kt")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import com.tencent.devops.utils.findJavaVersion
import com.tencent.devops.utils.isKotlinSupport
import org.gradle.api.Project
import org.jetbrains.kotlin.allopen.gradle.SpringGradleSubplugin
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformJvmPlugin
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.utils.IMPLEMENTATION

/**
* kotlin相关配置
*/
class KotlinConvention {

/**
* 配置Kotlin默认编译选项
*/
Expand All @@ -21,12 +21,12 @@ class KotlinConvention {
if (!isKotlinSupport(this)) {
return
}
pluginManager.apply(KotlinPlatformJvmPlugin::class.java)
pluginManager.apply(KotlinPluginWrapper::class.java)
// all-open kotlin class
pluginManager.apply(SpringGradleSubplugin::class.java)
tasks.withType(KotlinCompile::class.java) {
it.kotlinOptions.jvmTarget = findJavaVersion(this)
it.kotlinOptions.freeCompilerArgs = listOf("-Xjsr305=strict", "-java-parameters")
it.compilerOptions.jvmTarget.set(JvmTarget.fromTarget(findJavaVersion(this)))
it.compilerOptions.freeCompilerArgs.addAll(listOf("-Xjsr305=strict", "-java-parameters"))
}
dependencies.add(IMPLEMENTATION, KOTLIN_STDLIB)
dependencies.add(IMPLEMENTATION, KOTLIN_REFLECT)
Expand All @@ -35,7 +35,6 @@ class KotlinConvention {
}

companion object {

/**
* std-jdk8依赖
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.tencent.devops.enums

import java.util.Locale

enum class AssemblyMode {
NONE,
CONSUL,
Expand All @@ -9,8 +11,8 @@ enum class AssemblyMode {

companion object {
fun ofValueOrDefault(value: String): AssemblyMode {
val upperCase = value.toUpperCase()
return values().find { it.name == upperCase } ?: CONSUL
val upperCase = value.uppercase(Locale.getDefault())
return entries.find { it.name == upperCase } ?: CONSUL
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion devops-boot-sample/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ rootProject.name = "devops-boot-sample"
// for debug devops-boot locally
@Suppress("UnstableApiUsage")
pluginManagement {
val projectVersion = File(rootDir.parent,"version.txt").readText()
val projectVersion = File(rootDir.parent,"version.txt").readText().trim()
plugins {
id("com.tencent.devops.boot") version projectVersion
}
Expand Down
Loading