Gradle 设置 groovy 文件到 kts 文件

Gradle settings groovy file to kts file

我把这个当作 settings.gradle

buildscript {
    repositories {
        maven {
            url 'https://plugins.gradle.org/m2/'
        }
    }
    dependencies {
        classpath 'gradle.plugin.net.vivin:gradle-semantic-build-versioning:4.0.0'
    }
}

apply plugin: 'net.vivin.gradle-semantic-build-versioning'

我需要将其转换为 settings.gradle.kts kotlin DSL 文件。我试过了:

buildscript {
    repositories {
        maven {
            url = uri("https://plugins.gradle.org/m2/")
        }
    }
    dependencies {
        classpath("gradle.plugin.net.vivin:gradle-semantic-build-versioning:4.0.0")
    }
}

apply ("gradle.plugin.net.vivin.gradle-semantic-build-versioning")

这给出了错误:

Cannot apply plugin of class 'org.gradle.api.Plugin' to 'net.vivin.gradle-semantic-build-versioning' (class: java.lang.String) as it does not implement PluginAware

这里有什么问题?

解决方法是:

plugins.apply("net.vivin.gradle-semantic-build-versioning")