Kotlin-dsl-samples: kotlind-dsl adds gradle-api (and other gradle jars) to classpath

Created on 12 Nov 2017  路  3Comments  路  Source: gradle/kotlin-dsl-samples

Summary

Gradle adds a bunch of gradle jars to classpath when build file written in kotlin-dsl and does not when it's written in groovy. This sometimes causes conflicts. E.g. if I have logback-classic dependency it conflicts with slf4j static binding in gradle-api jar.

Expected Behavior

gradle jars should not be added to application class path

Current Behavior

gradle jars are added to application class path which prevents it from running

Context

Demo project: https://github.com/AlexCzar/bad-gradle-import

Steps to Reproduce (for bugs)

See readme in the demo project (basically: clone and run build)

Your Environment

Gradle version: 4.3.1 with its own kotlin-dsl (also affects 4.2.1, I haven't tested lower versions)
OS: Linux 64bit (probably irrelevant, but I don't have Win to test that)

question kotlin-dsl-api kotlin-dsl-plugins

Most helpful comment

I'm experiencing this also - however I think my use is valid (pretty much exactly like this sample project: https://github.com/gradle/kotlin-dsl/tree/master/samples/multi-project-with-buildSrc). In buildSrc I have kotlin-dsl applied to develop a plugin, then in one of my project's modules, I'm getting the slf4j dependency conflict because gradle-api is on the classpath.

All 3 comments

Oops, my bad, should have used kotlin("jvm") version "1.1.51" instead of kotlin-dsl, former being a prerequisite for creating gradle plugins.
This can be closed/deleted as invalid.

No worries, @AlexCzar. Thanks for the feedback.

Closing as answered.

I'm experiencing this also - however I think my use is valid (pretty much exactly like this sample project: https://github.com/gradle/kotlin-dsl/tree/master/samples/multi-project-with-buildSrc). In buildSrc I have kotlin-dsl applied to develop a plugin, then in one of my project's modules, I'm getting the slf4j dependency conflict because gradle-api is on the classpath.

Was this page helpful?
0 / 5 - 0 ratings