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

时间:2019-02-12 12:14:12

标签: 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")
}

我收到此错误:

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)

我做错了吗?我正在Gradle网站上关注此guide。这是过时的吗?任何帮助表示赞赏!

编辑:通过将java-gradle-plugin(带有波浪号)添加到build.gradle.kts下的buildSrc的plugins文件中,我可以完成这项工作。但是,不确定这样做是否正确。

0 个答案:

没有答案
相关问题