gradle / kotlin-dsl-samples

Samples builds using the Gradle Kotlin DSL
https://gradle.org/kotlin/
Other
3.71k stars 432 forks source link

kotlin-dsl 1.2.3 … 1.2.5 broken #1355

Closed fluidsonic closed 5 years ago

fluidsonic commented 5 years ago

Expected Behavior

kotlin-dsl 1.2.2 works just fine so 1.2.31.2.5 should work just fine too.

Current Behavior

1.2.4 & 1.2.5:

$ ./gradlew tasks --stacktrace

> Configure project :
WARNING: Unsupported Kotlin plugin version.
The `embedded-kotlin` and `kotlin-dsl` plugins rely on features of Kotlin `1.3.20` that might work differently than in the requested version `1.3.21`.

FAILURE: Build failed with an exception.
…

java.lang.NoClassDefFoundError: org/gradle/kotlin/dsl/provider/PrecompiledScriptPluginsSupport
        at org.gradle.kotlin.dsl.plugins.precompiled.PrecompiledScriptPlugins.apply(PrecompiledScriptPlugins.kt:77)
        at org.gradle.kotlin.dsl.plugins.precompiled.PrecompiledScriptPlugins.apply(PrecompiledScriptPlugins.kt:40)

1.2.3:

$ ./gradlew clean assemble

Execution failed for task ':generateExternalPluginSpecBuilders'.
> org.gradle.kotlin.dsl.accessors.PluginAccessorsClassPathKt.writeSourceCodeForPluginSpecBuildersFor(Lorg/gradle/internal/classpath/ClassPath;Ljava/io/File;Ljava/lang/String;)V

Context

I just regularly update dependencies and don't expect a patch update to break my build.

Steps to Reproduce (for bugs)

1.2.5: https://scans.gradle.com/s/2hloqem2t4ef6 1.2.3: https://scans.gradle.com/s/5uocitqfgjofg

Your Environment

------------------------------------------------------------
Gradle 5.2.1
------------------------------------------------------------

Build time:   2019-02-08 19:00:10 UTC
Revision:     f02764e074c32ee8851a4e1877dd1fea8ffb7183

Kotlin DSL:   1.1.3
Kotlin:       1.3.20
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          1.8.0_191 (Oracle Corporation 25.191-b12)
OS:           Mac OS X 10.14.3 x86_64

on the command line

i-walker commented 5 years ago

I have the same warning and behavior.

fonix232 commented 5 years ago

1.2.6 also presents the same error

vab2048 commented 5 years ago

I had the same problem and so am using version 1.2.2 like so:

plugins { id("org.gradle.kotlin.kotlin-dsl") version "1.2.2" }

N.B. for whatever reason if I just use the following, it works fine as well:

plugins { `kotlin-dsl` }

I prefer to explicitly mark the version number so I went with the former rather than the latter.

eskatos commented 5 years ago

Each Gradle release is meant to be used with a specific version of the kotlin-dsl plugin and compatibility between arbitrary Gradle releases and kotlin-dsl plugin versions is not guaranteed.

Using an unexpected version of the kotlin-dsl plugin in a build can cause hard to diagnose problems.

Starting with Gradle 5.4, a warning is emitted whenever an unexpected version of the kotlin-dsl plugin is detected.

See https://github.com/gradle/gradle/pull/8877

yoavgrosswild commented 5 years ago

Although @eskatos has closed this issue, no solution was provided. I understand I need a specific version of the dsl for a specific version of Gradle. How do I know what version corresponds to gradle version?

eskatos commented 5 years ago

@yoavgrosswild simply omit any version when requesting the kotlin-dsl plugin:

plugins { `kotlin-dsl` }
ZacSweers commented 4 years ago

We omit any version still receive this printed error noise in builds

plugins {
  `kotlin-dsl`
  `java-gradle-plugin`
  kotlin("jvm") version "1.3.61"
  id("org.jlleitschuh.gradle.ktlint") version "9.1.1"
  id("com.google.protobuf") version "0.8.10"
}

Gradle 6.0.1

> Configure project :plugins
WARNING: Unsupported Kotlin plugin version.
The `embedded-kotlin` and `kotlin-dsl` plugins rely on features of Kotlin `1.3.50` that might work differently than in the requested version `1.3.61`.

It seems that kotlin-dsl is pinned to specific versions of kotlin, and it would be useful to have a way to suppress this if the dsl is not going to keep up with recent versions of kotlin and allow users to opt out of this, as it warns in build outputs on every gradle invocation. 1.3.50 was released August 2019.

rvp-diconium commented 4 years ago

The problem still persists for Kotlin 1.3.72

plugins {
    `kotlin-dsl`
    jacoco
    kotlin("jvm") version "1.3.72"
}

The embedded-kotlin and kotlin-dsl plugins rely on features of Kotlin 1.3.70 that might work differently than in the requested version 1.3.72

eskatos commented 4 years ago

Please follow/upvote https://github.com/gradle/gradle/issues/13020 about being able to silence the warning if you accept the risk.