Kotlin Gradle DSL - buildSrc 中的预编译脚本不起作用

Sha*_*han 6 gradle gradle-plugin gradle-kotlin-dsl

我正在使用 Gradle 版本 4.10.3(需要 Android 支持),并尝试将测试预编译脚本放入我的buildSrc文件夹中,以便与项目中的各种模块一起使用。这是我的基本代码设置:

//maven-deploy.gradle.kts, a custom precompiled plugin under
// buildSrc\src\main\kotlin\maven-deploy.gradle.kts

plugins {
    maven
    signing
}

//a test task
tasks {
    register("hello") {
        doLast {
            println("hello")
        }
    }
}

//buildSrc build.gradle.kts

plugins {
    `kotlin-dsl`
    `kotlin-dsl-precompiled-script-plugins`
}

repositories {
    jcenter()
}

//main project root's build.gradle.kts

plugins {
    base
    kotlin("jvm") version Vof.kotlin apply false
    kotlin("android") version Vof.kotlin apply false
    kotlin("android.extensions") version Vof.kotlin apply false
    id("kotlinx-serialization") version Vof.kotlin apply false
    id("maven-deploy")
}
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

error:Plugin [id: 'maven-deploy'] was not found in any of the following sources:
  - Gradle Core Plugins (not a core plugin, please see https://docs.gradle.org/4.10.3/userguide/standard_plugins.html for available core plugins)
  - Plugin Repositories (plugin dependency must include a version number for this source)
Run Code Online (Sandbox Code Playgroud)

我这样做错了吗?我正在Gradle 网站上关注此指南。这已经过时了吗?任何帮助表示赞赏!

编辑:我通过将java-gradle-plugin(带波浪号)build.gradle.kts添加到plugins. 但是,不确定这是否是正确的方法。