Edoardo Luppi
11/15/2025, 3:05 PMversion property.
How do I access YarnRootEnvSpec in 2.2.21?
An exception occurred applying plugin request [id: 'project.module']
> Failed to apply plugin 'project.module'.
> Extension of type 'YarnRootEnvSpec' does not exist. Currently registered extension types: [ExtraPropertiesExtension, LibrariesForLibs, VersionCatalogsExtension, RootProjectAccessor, KotlinMultiplatformExtension, KotlinTestsRegistry, BasePluginExtension, DefaultArtifactPublicationSet, SourceSetContainer, ReportingExtension, JavaToolchainService, JavaPluginExtension, KotlinArtifactsExtensionImpl, PublishingExtension, ProjectModuleExtension]Edoardo Luppi
11/15/2025, 3:16 PMEdoardo Luppi
11/15/2025, 4:06 PMbuildSrc plugin:
class ProjectModulePlugin : Plugin<Project> {
override fun apply(project: Project) {
project.apply<KotlinMultiplatformPluginWrapper>()
project.apply<MavenPublishPlugin>()
// Register an extension to allow configuring the plugin using
//
// projectModule {
// ...
// }
project.extensions.create<ProjectModuleExtension>("projectModule", project)
// Configure the Yarn environment for all K/JS modules
project.plugins.withType<YarnPlugin> {
project.the<YarnRootEnvSpec>().apply {
version.set("1.22.22")
// See https://youtrack.jetbrains.com/issue/KT-52578
ignoreScripts.set(false)
}
}
// ...Edoardo Luppi
11/15/2025, 4:59 PMYarnPlugin instances don't seem to exist.Artem Kobzar
11/15/2025, 5:16 PMEdoardo Luppi
11/15/2025, 5:36 PMEdoardo Luppi
11/15/2025, 5:38 PM// Configure Node.js
plugins.withTypeNodeJsPlugin {
theNodeJsEnvSpec().apply {
// The Node.js version must always come from the root project configuration
version = project.stringProperty("project.node.version")
}
}
// Configure Yarn Classic
plugins.withTypeYarnPlugin {
theYarnRootEnvSpec().apply {
// Use the latest version of Yarn Classic
version = "1.22.22"
// See https://youtrack.jetbrains.com/issue/KT-52578
ignoreScripts = false
}
}
And on the next Gradle command I saw:
18:15:18: Executing 'clean assemble --no-build-cache --no-configuration-cache'…
Type-safe project accessors is an incubating feature.
> Task :buildSrc:checkKotlinGradlePluginConfigurationErrors SKIPPED
> Task :buildSrc:compileKotlin UP-TO-DATE
> Task :buildSrc:compileJava NO-SOURCE
> Task :buildSrc:compileGroovy NO-SOURCE
> Task :buildSrc:pluginDescriptors UP-TO-DATE
> Task :buildSrc:processResources UP-TO-DATE
> Task :buildSrc:classes UP-TO-DATE
> Task :buildSrc:jar UP-TO-DATE
> Configure project :faproto
Node version 20.9.0
Yarn version 1.22.22
Download https://github.com/yarnpkg/yarn/releases/download/v1.22.22/yarn-v1.22.22.tar.gz, took 473 ms
So I think it is being applied correctly now. But confirmation would be cool!Edoardo Luppi
11/15/2025, 5:51 PMproject.plugins.withTypeYarnPlugin
It should have been:
rootProject.plugins.withTypeYarnPluginAdam Semenenko
11/17/2025, 9:37 AM