Kotlin Gradle DSL - Precompiled script in buildSrc not working
Asked Answered
D

0

6

I am using Gradle version 4.10.3 (need Android support) and am trying to put a test precompiled script into my buildSrc folder for use with various modules within the project. Here is my basic code setup:

//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")
}

and I'm getting this error:

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)

Am I doing this incorrectly? I am following this guide on the Gradle website. Is this outdated? Any help is appreciated!

EDIT: I got this working by adding java-gradle-plugin (with tildes) to the buildSrc's build.gradle.kts file under plugins. Not sure if that is the correct way to go about this, however.

Dissipated answered 12/2, 2019 at 12:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.