Skip to content

Commit

Permalink
feat: kts切换
Browse files Browse the repository at this point in the history
  • Loading branch information
livk-cloud committed Sep 21, 2022
1 parent a3031dd commit 6f60515
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 12 deletions.
12 changes: 1 addition & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,12 @@ configure(springModuleProjects) {

configure(allprojects) {
apply(plugin = "com.livk.clean.expand")
apply(plugin = "com.livk.all.configuration")
repositories {
maven { setUrl("https://maven.aliyun.com/repository/public") }
maven { setUrl("https://plugins.gradle.org/m2/") }
maven { setUrl("https://repo.spring.io/release") }
}

configurations {
all {
resolutionStrategy {
dependencySubstitution {
substitute(module("org.springframework.boot:spring-boot-starter-tomcat"))
.using(module("org.springframework.boot:spring-boot-starter-undertow:$bootVersion"))
}
}
}
}
}

configure(gradleModuleProjects) {
Expand Down
13 changes: 13 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("groovy-gradle-plugin")
id("java-gradle-plugin")
Expand All @@ -16,6 +18,13 @@ dependencies {
implementation("org.springframework.boot:spring-boot-gradle-plugin:$bootVersion")
}

tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "17"
}
}

gradlePlugin {
plugins {
create("compileArgsPlugin") {
Expand Down Expand Up @@ -45,5 +54,9 @@ gradlePlugin {
id = "com.livk.clean.expand"
implementationClass = "com.livk.tasks.DeleteExpand"
}
create("allConfiguration") {
id = "com.livk.all.configuration"
implementationClass = "com.livk.config.AllConfiguration"
}
}
}
33 changes: 33 additions & 0 deletions buildSrc/src/main/kotlin/com/livk/config/AllConfiguration.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.livk.config

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalogsExtension

/**
* <p>
* AllConfig
* </p>
*
* @author livk
* @date 2022/7/11
*/
abstract class AllConfiguration : Plugin<Project> {
override fun apply(project: Project) {
val springBootVersion = project.rootProject
.extensions
.getByType(VersionCatalogsExtension::class.java)
.named("libs")
.findVersion("springBoot")
.get()
.displayName
project.configurations.all { config ->
config.resolutionStrategy { strategy ->
strategy.dependencySubstitution { dependency ->
dependency.substitute(dependency.module("org.springframework.boot:spring-boot-starter-tomcat"))
.using(dependency.module("org.springframework.boot:spring-boot-starter-undertow:" + springBootVersion))
}
}
}
}
}
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/com/livk/tasks/DeleteExpand.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.livk.tasks

import com.livk.config.AllConfiguration
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.tasks.Delete
Expand Down
2 changes: 1 addition & 1 deletion livk-cloud-dependencies/livk-cloud-dependencies.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies {
api(platform(libs.spring.cloud.square.dependencies))
constraints {
val versionCatalog = rootProject.extensions
.getByType(VersionCatalogsExtension::class)
.getByType(VersionCatalogsExtension::class.java)
.named("libs")
versionCatalog.libraryAliases
.filter { !it.endsWith("dependencies") && !it.endsWith("bom") }
Expand Down

0 comments on commit 6f60515

Please sign in to comment.