diff --git a/.github/workflows/build-on-pr.yml b/.github/workflows/build-on-pr.yml index 9e0283c..a43bc38 100644 --- a/.github/workflows/build-on-pr.yml +++ b/.github/workflows/build-on-pr.yml @@ -11,10 +11,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Set up JDK 1.8 + - name: Set up JDK 17 uses: actions/setup-java@v1 with: - java-version: 1.8 + java-version: 17 - name: Set up Node JS uses: actions/setup-node@v2 with: diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index 6bae662..c03e890 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -13,10 +13,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Set up JDK 8 + - name: Set up JDK 17 uses: actions/setup-java@v1 with: - java-version: 8 + java-version: 17 - name: Set up Node JS uses: actions/setup-node@v2 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5c8254f..a6a2530 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -59,10 +59,10 @@ jobs: - uses: actions/checkout@v2 with: ref: v${{ needs.release.outputs.RELEASE_VERSION }} - - name: Set up JDK 8 + - name: Set up JDK 17 uses: actions/setup-java@v1 with: - java-version: 8 + java-version: 17 - name: Set up Node JS uses: actions/setup-node@v2 with: @@ -76,4 +76,4 @@ jobs: ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }} ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNING_KEY_ID }} ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }} - run: ./gradlew publish \ No newline at end of file + run: ./gradlew publish diff --git a/README.md b/README.md index 78dec18..3ea04da 100644 --- a/README.md +++ b/README.md @@ -47,13 +47,13 @@ ## 核心依赖 -| 依赖 | 版本 | -| ------------ | ------------- | -| JDK | 1.8+ | -| Kotlin | 1.6.21 | -| Gradle | 6.8.3 | -| Spring Boot | 2.4.5 | -| Spring Cloud | 2020.0.2 | +| 依赖 | 版本 | +| ------------ |----------| +| JDK | 17 | +| Kotlin | 1.8.22 | +| Gradle | 7.6.3 | +| Spring Boot | 3.0.11 | +| Spring Cloud | 2022.0.4 | ## 示例 diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index d30c5a4..95ab6da 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -5,11 +5,11 @@ object Release { object Versions { const val Jib: String = "3.2.0" - const val Java = "1.8" - const val Kotlin = "1.6.21" - const val SpringBoot = "2.6.13" - const val SpringCloud = "2021.0.5" - const val DependencyManagement = "1.0.15.RELEASE" + const val Java = "17" + const val Kotlin = "1.8.22" + const val SpringBoot = "3.0.11" + const val SpringCloud = "2022.0.4" + const val DependencyManagement = "1.1.3" const val GradleNexusPublish = "1.3.0" - const val KtLint = "0.41.0" + const val KtLint = "0.50.0" } diff --git a/devops-boot-project/devops-boot-core/build.gradle.kts b/devops-boot-project/devops-boot-core/build.gradle.kts index e990882..8972e4c 100644 --- a/devops-boot-project/devops-boot-core/build.gradle.kts +++ b/devops-boot-project/devops-boot-core/build.gradle.kts @@ -32,6 +32,10 @@ subprojects { } tasks { + compileJava { + sourceCompatibility = Versions.Java + targetCompatibility = Versions.Java + } compileKotlin { kotlinOptions.freeCompilerArgs = listOf("-Xjsr305=strict") kotlinOptions.jvmTarget = Versions.Java @@ -42,5 +46,8 @@ subprojects { test { useJUnitPlatform() } + withType(org.jetbrains.kotlin.gradle.internal.KaptGenerateStubsTask::class.java).configureEach { + kotlinOptions.jvmTarget = Versions.Java + } } } diff --git a/devops-boot-project/devops-boot-core/devops-api/build.gradle.kts b/devops-boot-project/devops-boot-core/devops-api/build.gradle.kts index 877a1af..5af0908 100644 --- a/devops-boot-project/devops-boot-core/devops-api/build.gradle.kts +++ b/devops-boot-project/devops-boot-core/devops-api/build.gradle.kts @@ -1,6 +1,6 @@ description = "DevOps Boot Api" dependencies { - api("io.swagger:swagger-annotations") - api("io.swagger:swagger-models") + api("io.swagger.core.v3:swagger-annotations") + api("io.swagger.core.v3:swagger-models") } diff --git a/devops-boot-project/devops-boot-core/devops-api/src/main/kotlin/com/tencent/devops/api/pojo/Response.kt b/devops-boot-project/devops-boot-core/devops-api/src/main/kotlin/com/tencent/devops/api/pojo/Response.kt index ab09e25..ae2ee4b 100644 --- a/devops-boot-project/devops-boot-core/devops-api/src/main/kotlin/com/tencent/devops/api/pojo/Response.kt +++ b/devops-boot-project/devops-boot-core/devops-api/src/main/kotlin/com/tencent/devops/api/pojo/Response.kt @@ -1,16 +1,15 @@ package com.tencent.devops.api.pojo import com.fasterxml.jackson.annotation.JsonIgnore -import io.swagger.annotations.ApiModel -import io.swagger.annotations.ApiModelProperty +import io.swagger.v3.oas.annotations.media.Schema -@ApiModel("数据返回包装模型") +@Schema(description = "数据返回包装模型") data class Response( - @ApiModelProperty("返回码") + @Schema(description = "返回码") val code: Int, - @ApiModelProperty("提示信息") + @Schema(description = "提示信息") val message: String? = null, - @ApiModelProperty("数据") + @Schema(description = "数据") val data: T? = null ) { /** diff --git a/devops-boot-project/devops-boot-core/devops-plugin/devops-plugin-core/src/main/kotlin/com/tencent/devops/plugin/core/DefaultPluginScanner.kt b/devops-boot-project/devops-boot-core/devops-plugin/devops-plugin-core/src/main/kotlin/com/tencent/devops/plugin/core/DefaultPluginScanner.kt index 6fbcbd3..f488e0e 100644 --- a/devops-boot-project/devops-boot-core/devops-plugin/devops-plugin-core/src/main/kotlin/com/tencent/devops/plugin/core/DefaultPluginScanner.kt +++ b/devops-boot-project/devops-boot-core/devops-plugin/devops-plugin-core/src/main/kotlin/com/tencent/devops/plugin/core/DefaultPluginScanner.kt @@ -6,7 +6,7 @@ import org.slf4j.LoggerFactory import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths -import kotlin.streams.toList +import java.util.stream.Collectors /** * 插件扫描器默认实现 @@ -22,7 +22,7 @@ class DefaultPluginScanner( logger.error("Failed to load plugin, Path[$pluginDir] is not a directory.") return emptyList() } - return Files.walk(pluginDir).filter { it.toString().endsWith(".jar") }.toList() + return Files.walk(pluginDir).filter { it.toString().endsWith(".jar") }.collect(Collectors.toList()) } override fun scan(id: String): Path? { @@ -35,7 +35,7 @@ class DefaultPluginScanner( val filename = it.toString() val name = filename.substringAfter("-").substringBeforeLast("-") name == id - }.toList().firstOrNull() + }.collect(Collectors.toList()).firstOrNull() } companion object { diff --git a/devops-boot-project/devops-boot-core/devops-pulsar/src/main/kotlin/com/tencent/devops/stream/binder/pulsar/util/PulsarUtils.kt b/devops-boot-project/devops-boot-core/devops-pulsar/src/main/kotlin/com/tencent/devops/stream/binder/pulsar/util/PulsarUtils.kt index a258273..60874d1 100644 --- a/devops-boot-project/devops-boot-core/devops-pulsar/src/main/kotlin/com/tencent/devops/stream/binder/pulsar/util/PulsarUtils.kt +++ b/devops-boot-project/devops-boot-core/devops-pulsar/src/main/kotlin/com/tencent/devops/stream/binder/pulsar/util/PulsarUtils.kt @@ -30,10 +30,10 @@ package com.tencent.devops.stream.binder.pulsar.util import com.tencent.devops.stream.binder.pulsar.constant.DLQ import com.tencent.devops.stream.binder.pulsar.constant.PATH_SPLIT import com.tencent.devops.stream.binder.pulsar.constant.RETRY +import jakarta.validation.constraints.NotBlank import org.apache.pulsar.client.api.DeadLetterPolicy import java.io.UnsupportedEncodingException import java.util.StringJoiner -import javax.validation.constraints.NotBlank object PulsarUtils { @@ -58,12 +58,12 @@ object PulsarUtils { private fun validateByte(b: Byte): Boolean { return ( - b >= 'a'.toByte() && b <= 'z'.toByte() || - b >= 'A'.toByte() && b <= 'Z'.toByte() || - b >= '0'.toByte() && b <= '9'.toByte() || - b == '.'.toByte() || b == '-'.toByte() || - b == '_'.toByte() - ) + b >= 'a'.code.toByte() && b <= 'z'.code.toByte() || + b >= 'A'.code.toByte() && b <= 'Z'.code.toByte() || + b >= '0'.code.toByte() && b <= '9'.code.toByte() || + b == '.'.code.toByte() || b == '-'.code.toByte() || + b == '_'.code.toByte() + ) } /** diff --git a/devops-boot-project/devops-boot-core/devops-schedule/devops-schedule-common/src/main/kotlin/com/tencent/devops/schedule/api/RpcAuthWebInterceptor.kt b/devops-boot-project/devops-boot-core/devops-schedule/devops-schedule-common/src/main/kotlin/com/tencent/devops/schedule/api/RpcAuthWebInterceptor.kt index 6e64882..a337977 100644 --- a/devops-boot-project/devops-boot-core/devops-schedule/devops-schedule-common/src/main/kotlin/com/tencent/devops/schedule/api/RpcAuthWebInterceptor.kt +++ b/devops-boot-project/devops-boot-core/devops-schedule/devops-schedule-common/src/main/kotlin/com/tencent/devops/schedule/api/RpcAuthWebInterceptor.kt @@ -1,11 +1,11 @@ package com.tencent.devops.schedule.api import com.tencent.devops.schedule.constants.SCHEDULE_RPC_AUTH_HEADER +import jakarta.servlet.http.HttpServletRequest +import jakarta.servlet.http.HttpServletResponse import org.slf4j.LoggerFactory import org.springframework.http.HttpStatus import org.springframework.web.servlet.HandlerInterceptor -import javax.servlet.http.HttpServletRequest -import javax.servlet.http.HttpServletResponse class RpcAuthWebInterceptor( private val accessToken: String diff --git a/devops-boot-project/devops-boot-core/devops-schedule/devops-schedule-server/src/main/kotlin/com/tencent/devops/schedule/config/ScheduleServerAuthInterceptor.kt b/devops-boot-project/devops-boot-core/devops-schedule/devops-schedule-server/src/main/kotlin/com/tencent/devops/schedule/config/ScheduleServerAuthInterceptor.kt index 2bedd3c..72e8672 100644 --- a/devops-boot-project/devops-boot-core/devops-schedule/devops-schedule-server/src/main/kotlin/com/tencent/devops/schedule/config/ScheduleServerAuthInterceptor.kt +++ b/devops-boot-project/devops-boot-core/devops-schedule/devops-schedule-server/src/main/kotlin/com/tencent/devops/schedule/config/ScheduleServerAuthInterceptor.kt @@ -3,13 +3,13 @@ package com.tencent.devops.schedule.config import com.tencent.devops.api.pojo.Response import com.tencent.devops.schedule.constants.SCHEDULE_API_AUTH_HEADER import com.tencent.devops.schedule.utils.JwtUtils +import jakarta.servlet.http.HttpServletRequest +import jakarta.servlet.http.HttpServletResponse import org.slf4j.LoggerFactory import org.springframework.http.HttpMethod import org.springframework.http.HttpStatus import org.springframework.http.MediaType.APPLICATION_JSON_VALUE import org.springframework.web.servlet.HandlerInterceptor -import javax.servlet.http.HttpServletRequest -import javax.servlet.http.HttpServletResponse /** * 调度中心认证拦截器 @@ -21,7 +21,7 @@ class ScheduleServerAuthInterceptor( private val signingKey = JwtUtils.createSigningKey(authProperties.secretKey) override fun preHandle(request: HttpServletRequest, response: HttpServletResponse, handler: Any): Boolean { - if (request.method == HttpMethod.OPTIONS.name) { + if (request.method == HttpMethod.OPTIONS.name()) { return true } val jwtToken = request.getHeader(SCHEDULE_API_AUTH_HEADER) diff --git a/devops-boot-project/devops-boot-core/devops-schedule/devops-schedule-server/src/main/kotlin/com/tencent/devops/schedule/manager/DefaultWorkerManager.kt b/devops-boot-project/devops-boot-core/devops-schedule/devops-schedule-server/src/main/kotlin/com/tencent/devops/schedule/manager/DefaultWorkerManager.kt index f532e23..bf1377a 100644 --- a/devops-boot-project/devops-boot-core/devops-schedule/devops-schedule-server/src/main/kotlin/com/tencent/devops/schedule/manager/DefaultWorkerManager.kt +++ b/devops-boot-project/devops-boot-core/devops-schedule/devops-schedule-server/src/main/kotlin/com/tencent/devops/schedule/manager/DefaultWorkerManager.kt @@ -60,13 +60,18 @@ open class DefaultWorkerManager( require(address.isNotBlank()) require(group.isNotBlank()) val status = WorkerStatusEnum.ofCode(param.status) - when(status) { + when (status) { WorkerStatusEnum.RUNNING -> { workerProvider.upsertWorker(group, address) } + WorkerStatusEnum.STOP -> { workerProvider.deleteWorker(group, address) } + + else -> { + throw RuntimeException("worker status is illegal") + } } logger.debug("worker[$group-$address] heartbeat, status[$status]") } @@ -93,7 +98,6 @@ open class DefaultWorkerManager( } - companion object { private val logger = LoggerFactory.getLogger(DefaultWorkerManager::class.java) } diff --git a/devops-boot-project/devops-boot-core/devops-schedule/devops-schedule-server/src/main/kotlin/com/tencent/devops/schedule/scheduler/monitor/JobTodoMonitor.kt b/devops-boot-project/devops-boot-core/devops-schedule/devops-schedule-server/src/main/kotlin/com/tencent/devops/schedule/scheduler/monitor/JobTodoMonitor.kt index c116846..47401f4 100644 --- a/devops-boot-project/devops-boot-core/devops-schedule/devops-schedule-server/src/main/kotlin/com/tencent/devops/schedule/scheduler/monitor/JobTodoMonitor.kt +++ b/devops-boot-project/devops-boot-core/devops-schedule/devops-schedule-server/src/main/kotlin/com/tencent/devops/schedule/scheduler/monitor/JobTodoMonitor.kt @@ -68,7 +68,7 @@ open class JobTodoMonitor( var hasRingData = false if (timeRingMap.isNotEmpty()) { for (second in timeRingMap.keys) { - if(timeRingMap[second]?.isNotEmpty() == true) { + if (timeRingMap[second]?.isNotEmpty() == true) { hasRingData = true break } @@ -146,10 +146,15 @@ open class JobTodoMonitor( logger.warn("job[${job.id}] is misfire, retry") jobScheduler.trigger(job.id.orEmpty(), TriggerTypeEnum.MISFIRE) } + MisfireStrategyEnum.IGNORE -> { logger.warn("job[${job.id}] is misfire, ignore") // do nothing } + + else -> { + throw RuntimeException("misfire strategy is illegal") + } } // fresh next generateNextTriggerTime(job) diff --git a/devops-boot-project/devops-boot-core/devops-web/build.gradle.kts b/devops-boot-project/devops-boot-core/devops-web/build.gradle.kts index 938cf18..7d2160b 100644 --- a/devops-boot-project/devops-boot-core/devops-web/build.gradle.kts +++ b/devops-boot-project/devops-boot-core/devops-web/build.gradle.kts @@ -6,5 +6,5 @@ dependencies { api(project(":devops-boot-project:devops-boot-core:devops-utils")) api("org.springframework:spring-web") api("org.springframework.boot:spring-boot-starter-actuator") - api("io.springfox:springfox-boot-starter") + api("org.springdoc:springdoc-openapi-starter-webmvc-ui") } diff --git a/devops-boot-project/devops-boot-core/devops-web/src/main/kotlin/com/tencent/devops/web/swagger/SwaggerConfiguration.kt b/devops-boot-project/devops-boot-core/devops-web/src/main/kotlin/com/tencent/devops/web/swagger/SwaggerConfiguration.kt index 727536e..eef5680 100644 --- a/devops-boot-project/devops-boot-core/devops-web/src/main/kotlin/com/tencent/devops/web/swagger/SwaggerConfiguration.kt +++ b/devops-boot-project/devops-boot-core/devops-web/src/main/kotlin/com/tencent/devops/web/swagger/SwaggerConfiguration.kt @@ -1,23 +1,14 @@ package com.tencent.devops.web.swagger +import io.swagger.v3.oas.models.Components +import io.swagger.v3.oas.models.OpenAPI +import io.swagger.v3.oas.models.info.Info +import io.swagger.v3.oas.models.security.SecurityScheme +import org.springdoc.core.models.GroupedOpenApi +import org.springdoc.core.utils.Constants.ALL_PATTERN import org.springframework.beans.factory.annotation.Value -import org.springframework.beans.factory.config.BeanPostProcessor import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration -import org.springframework.util.ReflectionUtils -import org.springframework.web.bind.annotation.RestController -import springfox.documentation.builders.ApiInfoBuilder -import springfox.documentation.builders.PathSelectors -import springfox.documentation.builders.RequestHandlerSelectors -import springfox.documentation.service.HttpAuthenticationScheme -import springfox.documentation.service.SecurityReference -import springfox.documentation.service.SecurityScheme -import springfox.documentation.spi.DocumentationType -import springfox.documentation.spi.service.contexts.SecurityContext -import springfox.documentation.spring.web.plugins.Docket -import springfox.documentation.spring.web.plugins.WebFluxRequestHandlerProvider -import springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider -import kotlin.streams.toList /** * swagger配置类 @@ -35,75 +26,25 @@ class SwaggerConfiguration { private val applicationVersion: String? = null @Bean - fun api(): Docket { - val apiInfo = ApiInfoBuilder() - .title(applicationName) - .description(applicationDesc) - .version(applicationVersion) - .build() - return Docket(DocumentationType.OAS_30) - .apiInfo(apiInfo) - .select() - .apis(RequestHandlerSelectors.withClassAnnotation(RestController::class.java)) - .paths(PathSelectors.any()) - .build() - .securityContexts(securityContexts()) - .securitySchemes(securitySchemes()) - } - - private fun securitySchemes(): List { - val basicAuthScheme = HttpAuthenticationScheme.BASIC_AUTH_BUILDER - .name(BASIC_AUTH) - .description("Basic authorization") - .build() - return listOf(basicAuthScheme) - } - - private fun securityContexts(): List { - val securityContext = SecurityContext.builder() - .securityReferences(basicAuthReference()) - .operationSelector { true } + fun api(): GroupedOpenApi { + return GroupedOpenApi.builder() + .pathsToMatch(ALL_PATTERN) + .packagesToScan("com.tencent") .build() - return listOf(securityContext) - } - - private fun basicAuthReference(): List { - val basicSecurityReference = SecurityReference(BASIC_AUTH, emptyArray()) - return listOf(basicSecurityReference) } - /** - * 处理升级springboot,导致的swagger启动报错 - * @see bug in springfox - * */ @Bean - fun springfoxHandlerProviderBeanPostProcessor(): BeanPostProcessor { - return object : BeanPostProcessor { - override fun postProcessAfterInitialization(bean: Any, beanName: String): Any { - if (bean is WebMvcRequestHandlerProvider || bean is WebFluxRequestHandlerProvider) { - customizeSpringfoxHandlerMappings(getHandlerMappings(bean)) - } - return bean - } - - private fun customizeSpringfoxHandlerMappings(mappings: MutableList) { - val copy = mappings.stream() - .filter { mapping -> - val field = ReflectionUtils.findField(mapping.javaClass, "patternParser") - field?.isAccessible = true - field?.get(mapping) == null - }.toList() - mappings.clear() - mappings.addAll(copy) - } - - @Suppress("UNCHECKED_CAST") - private fun getHandlerMappings(bean: Any): MutableList { - val field = ReflectionUtils.findField(bean.javaClass, "handlerMappings") ?: return mutableListOf() - field.isAccessible = true - return field.get(bean) as MutableList - } - } + fun openApi(): OpenAPI { + val info = Info() + .title(applicationName) + .description(applicationDesc) + .description(applicationDesc) + .version(applicationVersion) + val components = Components().addSecuritySchemes( + BASIC_AUTH, + SecurityScheme().type(SecurityScheme.Type.HTTP).name(BASIC_AUTH).description("Basic authorization") + ) + return OpenAPI().info(info).components(components) } companion object { diff --git a/devops-boot-project/devops-boot-core/devops-webflux/src/main/kotlin/com/tencent/devops/webflux/WebExtensions.kt b/devops-boot-project/devops-boot-core/devops-webflux/src/main/kotlin/com/tencent/devops/webflux/WebExtensions.kt index e897fcc..8bbf611 100644 --- a/devops-boot-project/devops-boot-core/devops-webflux/src/main/kotlin/com/tencent/devops/webflux/WebExtensions.kt +++ b/devops-boot-project/devops-boot-core/devops-webflux/src/main/kotlin/com/tencent/devops/webflux/WebExtensions.kt @@ -27,7 +27,7 @@ package com.tencent.devops.webflux -import kotlinx.coroutines.reactive.awaitSingleOrNull +import kotlinx.coroutines.reactor.awaitSingleOrNull import org.springframework.web.server.ServerWebExchange import org.springframework.web.server.WebFilterChain diff --git a/devops-boot-project/devops-boot-dependencies/build.gradle.kts b/devops-boot-project/devops-boot-dependencies/build.gradle.kts index 6dfe440..ed49a6c 100644 --- a/devops-boot-project/devops-boot-dependencies/build.gradle.kts +++ b/devops-boot-project/devops-boot-dependencies/build.gradle.kts @@ -32,9 +32,10 @@ dependencies { api("com.google.guava:guava:29.0-jre") // swagger - api("io.swagger:swagger-annotations:1.5.20") - api("io.swagger:swagger-models:1.5.20") - api("io.springfox:springfox-boot-starter:3.0.0") + api("io.swagger.core.v3:swagger-annotations:2.2.16") + api("io.swagger.core.v3:swagger-models:2.2.16") + api("io.swagger.core.v3:swagger-jaxrs2:2.2.16") + api("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0") // mq stream api("org.apache.pulsar:pulsar-client:2.9.1") diff --git a/devops-boot-project/devops-boot-tools/devops-boot-gradle-plugin/src/main/kotlin/com/tencent/devops/conventions/KtLintConvention.kt b/devops-boot-project/devops-boot-tools/devops-boot-gradle-plugin/src/main/kotlin/com/tencent/devops/conventions/KtLintConvention.kt index 38ef5b8..d43b478 100644 --- a/devops-boot-project/devops-boot-tools/devops-boot-gradle-plugin/src/main/kotlin/com/tencent/devops/conventions/KtLintConvention.kt +++ b/devops-boot-project/devops-boot-tools/devops-boot-gradle-plugin/src/main/kotlin/com/tencent/devops/conventions/KtLintConvention.kt @@ -32,6 +32,6 @@ class KtLintConvention { companion object { private const val KT_LINT = "ktlint" - private const val KT_LINT_DEPENDENCY = "com.pinterest:ktlint:0.41.0" + private const val KT_LINT_DEPENDENCY = "com.pinterest:ktlint:0.50.0" } } diff --git a/devops-boot-project/devops-boot-tools/devops-boot-gradle-plugin/src/main/kotlin/com/tencent/devops/utils/Constants.kt b/devops-boot-project/devops-boot-tools/devops-boot-gradle-plugin/src/main/kotlin/com/tencent/devops/utils/Constants.kt index 0c4c217..b1ecf1d 100644 --- a/devops-boot-project/devops-boot-tools/devops-boot-gradle-plugin/src/main/kotlin/com/tencent/devops/utils/Constants.kt +++ b/devops-boot-project/devops-boot-tools/devops-boot-gradle-plugin/src/main/kotlin/com/tencent/devops/utils/Constants.kt @@ -1,6 +1,5 @@ package com.tencent.devops.utils -import com.tencent.devops.conventions.SpringCloudConvention import com.tencent.devops.enums.AssemblyMode import org.gradle.api.JavaVersion import org.gradle.api.Project @@ -16,10 +15,10 @@ const val DEVOPS_JAVA_VERSION = "devops.javaVersion" const val DEVOPS_KOTLIN = "devops.kotlin" /** - * 查找java version, 默认1.8 + * 查找java version, 默认17 */ fun findJavaVersion(project: Project): String { - return project.findPropertyOrDefault(DEVOPS_JAVA_VERSION, JavaVersion.VERSION_1_8.toString()) + return project.findPropertyOrDefault(DEVOPS_JAVA_VERSION, JavaVersion.VERSION_17.toString()) } /** diff --git a/devops-boot-sample/api-kotlin-sample/src/main/kotlin/com/tencent/devops/sample/client/SampleClient.kt b/devops-boot-sample/api-kotlin-sample/src/main/kotlin/com/tencent/devops/sample/client/SampleClient.kt index 4ed29f0..77f64cb 100644 --- a/devops-boot-sample/api-kotlin-sample/src/main/kotlin/com/tencent/devops/sample/client/SampleClient.kt +++ b/devops-boot-sample/api-kotlin-sample/src/main/kotlin/com/tencent/devops/sample/client/SampleClient.kt @@ -2,22 +2,21 @@ package com.tencent.devops.sample.client import com.tencent.devops.api.pojo.Response import com.tencent.devops.sample.pojo.Sample -import io.swagger.annotations.Api -import io.swagger.annotations.ApiOperation +import io.swagger.v3.oas.annotations.Operation +import io.swagger.v3.oas.annotations.tags.Tag import org.springframework.cloud.openfeign.FeignClient import org.springframework.context.annotation.Primary import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestMapping /** * Sample FeignClient */ -@Api("Sample 服务接口") +@Tag(name = "Sample 服务接口") @Primary @FeignClient("devops-kotlin-sample", contextId = "SampleClient", path = "/service/sample") interface SampleClient { - @ApiOperation("获取Sample") + @Operation(description = "获取Sample") @GetMapping fun getSample(): Response } diff --git a/devops-boot-sample/api-kotlin-sample/src/main/kotlin/com/tencent/devops/sample/pojo/Sample.kt b/devops-boot-sample/api-kotlin-sample/src/main/kotlin/com/tencent/devops/sample/pojo/Sample.kt index 1455420..cc8f8e0 100644 --- a/devops-boot-sample/api-kotlin-sample/src/main/kotlin/com/tencent/devops/sample/pojo/Sample.kt +++ b/devops-boot-sample/api-kotlin-sample/src/main/kotlin/com/tencent/devops/sample/pojo/Sample.kt @@ -1,12 +1,11 @@ package com.tencent.devops.sample.pojo -import io.swagger.annotations.ApiModel -import io.swagger.annotations.ApiModelProperty +import io.swagger.v3.oas.annotations.media.Schema -@ApiModel("样例") +@Schema(description = "样例") data class Sample( - @ApiModelProperty("id") + @Schema(description = "id") val id: Long, - @ApiModelProperty("名称") + @Schema(description = "名称") val name: String ) diff --git a/devops-boot-sample/biz-kotlin-sample/src/main/kotlin/com/tencent/devops/sample/controller/TestController.kt b/devops-boot-sample/biz-kotlin-sample/src/main/kotlin/com/tencent/devops/sample/controller/TestController.kt index 50ebbd1..0d6c645 100644 --- a/devops-boot-sample/biz-kotlin-sample/src/main/kotlin/com/tencent/devops/sample/controller/TestController.kt +++ b/devops-boot-sample/biz-kotlin-sample/src/main/kotlin/com/tencent/devops/sample/controller/TestController.kt @@ -1,14 +1,11 @@ package com.tencent.devops.sample.controller +//import com.tencent.devops.plugin.api.PluginManager import com.tencent.devops.api.pojo.Response -import com.tencent.devops.plugin.api.PluginManager -import com.tencent.devops.plugin.api.applyExtension import com.tencent.devops.sample.client.SampleClient import com.tencent.devops.sample.config.GreetingProperties -import com.tencent.devops.sample.extension.PrintExtension import com.tencent.devops.sample.pojo.Sample import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.PathVariable import org.springframework.web.bind.annotation.RestController /** @@ -16,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController */ @RestController class TestController( - private val pluginManager: PluginManager, +// private val pluginManager: PluginManager, private val sampleClient: SampleClient, private val greetingProperties: GreetingProperties ) { @@ -32,8 +29,8 @@ class TestController( /** * test plugin */ - @GetMapping("/print/{content}") - fun print(@PathVariable content: String) { - pluginManager.applyExtension { print(content) } - } +// @GetMapping("/print/{content}") +// fun print(@PathVariable content: String) { +// pluginManager.applyExtension { print(content) } +// } } diff --git a/devops-boot-sample/boot-java-sample/gradle.properties b/devops-boot-sample/boot-java-sample/gradle.properties index f44c455..0432f8f 100644 --- a/devops-boot-sample/boot-java-sample/gradle.properties +++ b/devops-boot-sample/boot-java-sample/gradle.properties @@ -1,2 +1,2 @@ devops.kotlin=false -devops.javaVersion=1.8 \ No newline at end of file +devops.javaVersion=17 diff --git a/devops-boot-sample/boot-java-sample/src/main/resources/application.yml b/devops-boot-sample/boot-java-sample/src/main/resources/application.yml index 002f0c4..f8f3337 100644 --- a/devops-boot-sample/boot-java-sample/src/main/resources/application.yml +++ b/devops-boot-sample/boot-java-sample/src/main/resources/application.yml @@ -1,3 +1,6 @@ spring: application: name: java-sample + cloud: + consul: + enabled: false diff --git a/devops-boot-sample/boot-kotlin-sample/gradle.properties b/devops-boot-sample/boot-kotlin-sample/gradle.properties index 510cce2..c657013 100644 --- a/devops-boot-sample/boot-kotlin-sample/gradle.properties +++ b/devops-boot-sample/boot-kotlin-sample/gradle.properties @@ -1,4 +1,4 @@ devops.kotlin=true -devops.javaVersion=1.8 +devops.javaVersion=17 devops.copyWithVersion=false devops.assemblyMode=consul diff --git a/devops-boot-sample/boot-kotlin-sample/src/main/resources/bootstrap.yaml b/devops-boot-sample/boot-kotlin-sample/src/main/resources/bootstrap.yaml index 11d85b2..f70ae8b 100644 --- a/devops-boot-sample/boot-kotlin-sample/src/main/resources/bootstrap.yaml +++ b/devops-boot-sample/boot-kotlin-sample/src/main/resources/bootstrap.yaml @@ -9,6 +9,7 @@ spring: tags: env=xxx, a=b metadata: env: aaa + enabled: false server: port: 8080 diff --git a/devops-boot-sample/gradle/wrapper/gradle-wrapper.properties b/devops-boot-sample/gradle/wrapper/gradle-wrapper.properties index 442d913..068cdb2 100644 --- a/devops-boot-sample/gradle/wrapper/gradle-wrapper.properties +++ b/devops-boot-sample/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/devops-boot-sample/webflux-sample/api-webflux-sample/src/main/kotlin/com/tencent/devops/sample/client/SampleClient.kt b/devops-boot-sample/webflux-sample/api-webflux-sample/src/main/kotlin/com/tencent/devops/sample/client/SampleClient.kt index a31cc0e..a111787 100644 --- a/devops-boot-sample/webflux-sample/api-webflux-sample/src/main/kotlin/com/tencent/devops/sample/client/SampleClient.kt +++ b/devops-boot-sample/webflux-sample/api-webflux-sample/src/main/kotlin/com/tencent/devops/sample/client/SampleClient.kt @@ -2,8 +2,8 @@ package com.tencent.devops.sample.client import com.tencent.devops.api.pojo.Response import com.tencent.devops.sample.pojo.Sample -import io.swagger.annotations.Api -import io.swagger.annotations.ApiOperation +import io.swagger.v3.oas.annotations.Operation +import io.swagger.v3.oas.annotations.tags.Tag import org.springframework.cloud.openfeign.FeignClient import org.springframework.context.annotation.Primary import org.springframework.web.bind.annotation.GetMapping @@ -12,13 +12,13 @@ import org.springframework.web.bind.annotation.RequestMapping /** * Sample FeignClient */ -@Api("Sample 服务接口") +@Tag(name = "Sample 服务接口") @Primary @FeignClient("devops-kotlin-sample", contextId = "SampleClient") @RequestMapping("/service/sample") interface SampleClient { - @ApiOperation("获取Sample") + @Operation(description = "获取Sample") @GetMapping fun getSample(): Response } diff --git a/devops-boot-sample/webflux-sample/api-webflux-sample/src/main/kotlin/com/tencent/devops/sample/pojo/Sample.kt b/devops-boot-sample/webflux-sample/api-webflux-sample/src/main/kotlin/com/tencent/devops/sample/pojo/Sample.kt index b95f8a7..9a43f7e 100644 --- a/devops-boot-sample/webflux-sample/api-webflux-sample/src/main/kotlin/com/tencent/devops/sample/pojo/Sample.kt +++ b/devops-boot-sample/webflux-sample/api-webflux-sample/src/main/kotlin/com/tencent/devops/sample/pojo/Sample.kt @@ -1,12 +1,12 @@ package com.tencent.devops.sample.pojo -import io.swagger.annotations.ApiModel -import io.swagger.annotations.ApiModelProperty +import io.swagger.v3.oas.annotations.media.Schema -@ApiModel("样例") + +@Schema(description = "样例") data class Sample( - @ApiModelProperty("id") + @Schema(description = "id") val id: Long, - @ApiModelProperty("名称") + @Schema(description = "名称") val name: String, ) diff --git a/devops-boot-sample/webflux-sample/boot-webflux-sample/src/main/resources/application.yml b/devops-boot-sample/webflux-sample/boot-webflux-sample/src/main/resources/application.yml index 0d6a741..5134dcb 100644 --- a/devops-boot-sample/webflux-sample/boot-webflux-sample/src/main/resources/application.yml +++ b/devops-boot-sample/webflux-sample/boot-webflux-sample/src/main/resources/application.yml @@ -15,3 +15,8 @@ devops: context: initializer: classes: com.tencent.devops.sample.config.BeansInitializer +management: + endpoints: + web: + exposure: + include: "*" diff --git a/devops-boot-sample/webflux-sample/boot-webflux-sample/src/main/resources/bootstrap.yaml b/devops-boot-sample/webflux-sample/boot-webflux-sample/src/main/resources/bootstrap.yaml index 11d85b2..fd917d4 100644 --- a/devops-boot-sample/webflux-sample/boot-webflux-sample/src/main/resources/bootstrap.yaml +++ b/devops-boot-sample/webflux-sample/boot-webflux-sample/src/main/resources/bootstrap.yaml @@ -9,8 +9,7 @@ spring: tags: env=xxx, a=b metadata: env: aaa -server: - port: 8080 + enabled: false resilience4j: thread-pool-bulkhead: diff --git a/docs/index.md b/docs/index.md index 63f2572..c27aa14 100644 --- a/docs/index.md +++ b/docs/index.md @@ -43,13 +43,13 @@ ## 核心依赖 -| 依赖 | 版本 | -| ------------ | ------------- | -| JDK | 1.8+ | -| Kotlin | 1.6.21 | -| Gradle | 6.8.3 | -| Spring Boot | 2.6.13 | -| Spring Cloud | 2021.0.5 | +| 依赖 | 版本 | +| ------------ |----------| +| JDK | 17 | +| Kotlin | 1.8.22 | +| Gradle | 7.6.3 | +| Spring Boot | 3.0.11 | +| Spring Cloud | 2022.0.4 | ## 示例 diff --git a/docs/plugin/devops-boot-gradle-plugin.md b/docs/plugin/devops-boot-gradle-plugin.md index 93523b5..a90f2f8 100644 --- a/docs/plugin/devops-boot-gradle-plugin.md +++ b/docs/plugin/devops-boot-gradle-plugin.md @@ -4,7 +4,7 @@ `devops-boot-gradle-plugin`是一个用于快速构建`Spring Boot`应用程序的gradle插件,引入该插件后,会为开发者自动完成: -- 配置jdk插件及编译选项,默认版本为1.8 +- 配置jdk插件及编译选项,默认版本为17 - 配置maven仓库列表,除中央仓库之外还添加了腾讯源 - 添加`spring boot`相关插件 - 添加依赖管理插件,并引入`devops-boot-dependencies`基础依赖`bom` @@ -42,12 +42,12 @@ plugins { 支持在`gradle.properties`中进行如下配置: -| 属性 | 类型 | 默认值 | 说明 | -| ------------------ | ------- | ------ | ------------------ | -| devops.kotlin | boolean | true | 是否添加kotlin支持 | -| devops.javaVersion | string | 1.8 | jdk版本 | -| devops.copyWithVersion | boolean | false | 拷贝jar到release目录时是否带版本号 | -| devops.assemblyMode | string | null | 支持consul/k8s/kubernetes,默认使用consul | +| 属性 | 类型 | 默认值 | 说明 | +| ------------------ | ------- |-------| ------------------ | +| devops.kotlin | boolean | true | 是否添加kotlin支持 | +| devops.javaVersion | string | 17 | jdk版本 | +| devops.copyWithVersion | boolean | false | 拷贝jar到release目录时是否带版本号 | +| devops.assemblyMode | string | null | 支持consul/k8s/kubernetes,默认使用consul | ## 功能介绍 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 442d913..068cdb2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists