I am using the following configuration in a `build...
# gradle
t
I am using the following configuration in a
build.gradle.kts
with Kotlin 1.2.61 and Gradle wrapper 4.10.1:
Copy code
buildscript {
    repositories {
        maven("<https://dl.bintray.com/kotlin/kotlin-dev>")
    }
}

repositories {
    maven("<https://dl.bintray.com/kotlin/kotlin-dev>")
}

plugins {
    id("org.gradle.kotlin.kotlin-dsl") version "0.18.3"
}
When I try to increase the version of
kotlin-dsl
to f.e.
0.18.4
or the latest
0.19.5
I get the following error:
Copy code
Plugin [id: 'org.gradle.kotlin.kotlin-dsl', version: '0.18.4'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:0.18.4')
  Searched in the following repositories:
    Gradle Central Plugin Repository
What maven repository is missing here? Or, which combination of Kotlin and kotlin-dsl should work?
e
You should not change the version of that plugin. Just do:
Copy code
plugins {
    `kotlin-dsl`
}
which is equivalent.
then Gradle will use the version of that plugin that works well with your Gradle version.
Note that this plugin is for writing Gradle plugins or build logic, e.g. in
buildSrc
or if you plan to publish a plugin. See https://docs.gradle.org/current/userguide/kotlin_dsl.html
t
I am using it in
buildSrc
to maintain the dependencies of my multi-module project. Nevertheless, I would like to have control of the
kotlin-dsl
version. I cannot let Gradle pull in a
-RC
or
-alpha
or
-beta
in an production environment.
e
You can’t change the version of the Gradle Kotlin DSL, it is embedded in Gradle. And the Gradle Kotlin DSL knows which version of the
kotlin-dsl
plugin to use.
n
i would be interested in how you manage versions of dependencies i just use
Copy code
allprojects {
    configurations.all {
        resolutionStrategy.eachDependency {
            if (requested.group == "org.jetbrains.kotlin") {
                useVersion(kotlin_version)
                because("version mix-matching annoys me")
            }
        }
    }
}
t
Can you explain why I cannot change the version? I can define different versions such as
id("org.gradle.kotlin.kotlin-dsl") version "0.18.0"
or
id("org.gradle.kotlin.kotlin-dsl") version "0.18.3"
although it is tight to the Gradle wrapper defined in the project (if I understand you correctly).
@eskatos I really would like to understand it.
e
yes, you can change the version, but you shouldn’t behavior is not guaranteed if you do change it we should issue a warning if you do
t
@eskatos I still struggle with updating my project to new version of Kotlin. A recent commit to try this can be found here on the
project-setup
branch: https://github.com/EventFahrplan/EventFahrplan/commit/9cb4c11f0ab8a0737a64b7bc8a78bad3b83004ad If you have some spare time I would appreciate.
e
what is the issue you have?
e
again, you should not set any version for the
kotlin-dsl
plugin and use the one provided by the current Gradle version you should use the
kotlin-dsl
plugin in your build logic projects only (e.g.
buildSrc
), then in your production code projects you use the regular Kotlin JVM gradle plugin if you do just that and have an issue, please raise it with a reproducer
from our testing, Gradle 4.10.3 works with production projects using Kotlin 1.3
t
I just updated the Gradle wrapper from
4.10.2
to
4.10.3
which works. ✔️ As soon as I change
id("org.gradle.kotlin.kotlin-dsl") version "0.18.2"
to
kotlin-dsl
I get the following error:
Copy code
* What went wrong:
Execution failed for task ':buildSrc:compileKotlin'.
> Could not resolve all files for configuration ':buildSrc:kotlinCompilerPluginClasspath'.
   > Could not find org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.2.61.
     Searched in the following locations: file:~/.gradle/caches/4.10.3/embedded-kotlin-repo-1.2.61-2/repo/org/jetbrains/kotlin/kotlin-scripting-compiler-embeddable/1.2.61/kotlin-scripting-compiler-embeddable-1.2.61.jar
     Required by:
         project :buildSrc
   > Could not find org.jetbrains.kotlin:kotlin-sam-with-receiver:1.2.61.
     Required by:
         project :buildSrc
I then tried to also use Kotlin
1.3.11
instead of
1.2.51
. The error remains the same. I can push these steps as separate commits if this helps.
e
do you have a repository declared in buildSrc where those dependencies can be resolved?
t
I did not. I defined
mavenCentral()
and resynced the project:
Copy code
> Configure project :buildSrc
WARNING: Unsupported Kotlin plugin version.
The `embedded-kotlin` and `kotlin-dsl` plugins rely on features of Kotlin `1.2.61` that might work differently than in the requested version `1.3.11`.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':buildSrc'.
> Failed to notify project evaluation listener.
   > java.lang.AbstractMethodError (no error message)
   > java.lang.AbstractMethodError (no error message)
I can paste the
--stacktrace
log if you want it.
e
A reproducer project would be much more helpful
t
I will push the commits on a branch on my project. Just a second.
👍 1
n
seems like you have some dependencies in buildSrc that do not like kotlin 1.3 yet
with kotlin 1.3 i found it sometimes nicer to use gradle 5.0+ the kotlin-dsl plugin will attempt to use the embedded kotlin version from the gradle plugin.. which is old
and dependencies do not line up correctly
t
I pushed the steps in separate commits here: https://github.com/EventFahrplan/EventFahrplan/commits/project-setup-2 If you click on the red or the green ✔️ they will take you to the build log of the particular commit. I added the
--stacktrace
option to have a verbose output. With regards to Gradle 5. Last time I checked the Android plugin for Gradle was not ready for Gradle 5.
e
thanks, I’ll have a look in a few hours
👍 1
In your root settings.gradle file I see that you
include(":buildSrc")
, you’re not supposed to do that,
buildSrc
is a nested build, not a project. this is probably what messes things
🚀 1
👍🏻 1
t
Thank you. You found the source of the errors! Who knows how long it would have taken me. I pushed the commits here: https://github.com/EventFahrplan/EventFahrplan/commits/project-setup-3
👍 1
For anyone to follow up. The temporary branches mentioned here before are now gone. The changes have been merged into
master
. - Thank you once again for your help.