Gradle version `4.5.1` gradle.properties ```kotli...
# gradle
c
Gradle version
4.5.1
gradle.properties
Copy code
kotlin.version=1.2.21
build.gradle.kts
Copy code
plugins {
	kotlin("jvm")
}
settings.gradle.kts
Copy code
pluginManagement {
	repositories {
		gradlePluginPortal()
	}
	resolutionStrategy {
		eachPlugin {
			if (requested.id.id.startsWith("org.jetbrains.kotlin")) {
				useVersion(gradle.rootProject.extra["kotlin.version"] as String)
			}
		}
	}
}

rootProject.name = "blabla"
$ gradle tasks
result:
Copy code
FAILURE: Build failed with an exception.
Build file '/home/czar/work/occ/build.gradle.kts' line: 2
Plugin [id: 'org.jetbrains.kotlin.jvm'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Gradle Central Plugin Repository (plugin dependency must include a version number for this source)
g
Hmm, I thought that you cannot use
gradle.rootProject
in setting.gradle. Is this ever worked for you?
c
Yup, works for Gradle 4.4.1
g
But it doesn’t work for your case. Version of plugin is empty and cause this error
c
The same thing works with gradle 4.4.1 and does not work with gradle 4.5.1
I'll create demo and post it shortly
g
hmm
c
Weird, I tried to write a testkit demo project to showcase what's happening in a test, but with testkit both versions fail: 4.4.1 and 4.5.1
Also, useVersion("1.2.21") doesn't work either, so access to
rootProject
is not the problem.
Next thing I'll try: checking if the problem is the same with groovy
gradle.settings
. If it is, then it is not Kotlin related and I'll move to gradle issue tracker
g
groovy should also support this syntax in setting.gradle to access gradle properties
settings["kotlin.version"]
you can try, maybe it’s gradle.properties problem
c
I'm totally weirded out now, I've created small demo project with source above and it doesn't work in 4.4.1 too... whilst I have a working project with exactly same configuration, which does work in 4.4.1. The working one is here: https://github.com/AlexCzar/db-info-demo
actually, db-info-demo works even with gradle 4.5.1
and it's not properties problem, as I've said, even when I use literal
"1.2.21"
instead of referencing properties, I get the same problem. I think settings file is not evaluated at all, because none of my println("something") that I place there to check are reached.
Shit... I wasn't naming some of the files correctly, in the ones which work name was correct:
settings.gradle.kts
, in ones which didn't work
gradle.settings.kts
. gradle versions were irrelevant I just had two projects one with 4.4.1 (and correct file name) and one with 4.5.1 (and incorrect file name)
g
🤣
cool bug!
c
I stumble upon this particular issue once or twice a year and I keep forgetting about it until the next time 😄 I hate that.
"gradle settings" sounds more natural to my ear, "gradle build" too for that matter, but I create "build.gradle" all the time and don't make the mistake, I create "settings.gradle" less often, so the mistake is always lurking in the shadows 😄
g
🍺