pixel
pixel

Reputation: 26441

Reference version variable in gradle plugin DSL?

I have following file:

buildscript {
    ext {
        kotlinVersion = '1.2.10'
        springBootVersion = '2.0.0.M7'
    }
...

plugins {
    id "org.jetbrains.kotlin.jvm" version "1.2.10"

I would like to use kotlinVersion from ext block inside plugins declaration. How I can achieve that?

When I try to do it directly I get: argument list must be exactly 1 literal non empty string

Upvotes: 1

Views: 1013

Answers (2)

chenrui
chenrui

Reputation: 9866

You cannot reference variable in Plugin DSL,

Plugin docs reference below:

Where «plugin version» and «plugin id» must be constant, literal, strings and the apply statement with a boolean can be used to disable the default behavior of applying the plugin immediately (e.g. you want to apply it only in subprojects). No other statements are allowed; their presence will cause a compilation error.

Upvotes: 1

Related Questions