Thomas Broyer
06/21/2026, 9:49 PMproject) property from a block where the local this has a property of the same name? …when that block also has a deprecated project property 😉
I have something like the following:
testing {
suites {
named<JvmTestSuite>("test") {
dependencies {
implementation(project())
implementation(project.dependencies.embeddedKotlin("gradle-plugin") as String)
}
}
}
}
The thing is: that dependencies block (JvmComponentDependencies) has a project property that's now deprecated in 9.6.0, it also has no embeddedKotlin() extension.
Is there a way (with a this@xxx notation?) to access the "root" project or dependencies property?
Or is my only option to replace the embeddedKotlin helper with a more explicit implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$embeddedKotlinVersion")? Or would you rather pull that embeddedKotlin() call outside of the test suite into a variable?
(btw, this is for unit-testing –with `ProjectBuilder`– a plugin that depends on KGP)Martin
06/21/2026, 9:57 PMval topLevelProject = project
testing {
suites {
named<JvmTestSuite>("test") {
dependencies {
implementation(project())
implementation(topLevelProject.dependencies.embeddedKotlin("gradle-plugin") as String)
}
}
}
}
?Thomas Broyer
06/21/2026, 10:02 PMtesting {
suites {
named<JvmTestSuite>("test") {
val kotlinGradlePlugin = project.dependencies.embeddedKotlin("gradle-plugin") as String
dependencies {
implementation(project())
implementation(kotlinGradlePlugin)
}
}
}
}Ben Liblit
06/21/2026, 11:21 PMthis@xxx notation?) to access the "root" project or dependencies property?
I really wanted there to be a this@xxx solution, but I think there isn't one. According to IntelliJ IDEA, the available this variants inside that dependencies block are:
• this, which has type JvmComponentDependencies
• this@dependencies, which has type JvmComponentDependencies
• this@named, which has type JvmTestSuite
• this@suites, which has type NamedDomainObjectContainerScope<TestSuite>
• this@testing, which has type TestingExtension
Unless I've overlooked something, none of these has a field that gets you to the “root” project or dependencies property. And there's just no named scope that refers to the top-level scope of the script itself.ephemient
06/22/2026, 12:09 AMthis@Build_gradle, but that depends on the script filename and doesn't work in K2