You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Gradle项目中添加kotest插件后无法找到该插件的问题

解决Gradle Kotlin项目中Kotest插件无法解析的问题

问题场景

按常规指南配置IntelliJ下的Gradle Kotlin项目引入Kotest时,已在build.gradle.kts中添加插件配置:

plugins {
    // 其他已有插件
    id("io.kotest") version "5.8.0"
}

同时配置了仓库:

repositories {
    mavenLocal()
    mavenCentral()
}

但执行./gradlew clean时触发报错,提示找不到指定插件:

FAILURE: Build failed with an exception.

* Where:
Build file '{path}/build.gradle.kts' line: 1

* What went wrong:
Plugin [id: 'io.kotest', version: '5.8.0'] 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 'io.kotest:io.kotest.gradle.plugin:5.8.0')
  Searched in the following repositories:
    Gradle Central Plugin Repository

解决方法

1. 使用正确的Kotest插件ID

io.kotest并非Kotest官方推荐的标准插件ID,不同项目类型需对应不同的插件ID:

  • JVM项目:使用io.kotest.plugin.jvm
  • 多平台项目:使用io.kotest.multiplatform

修改build.gradle.kts的plugins块:

plugins {
    // 其他已有插件
    id("io.kotest.plugin.jvm") version "5.8.0"
}

2. 配置插件仓库(若需保留原ID)

如果必须使用io.kotest作为插件ID,需在settings.gradle.kts中添加Maven Central到插件仓库列表,让Gradle能从该仓库查找插件:

pluginManagement {
    repositories {
        gradlePluginPortal()
        mavenCentral()
    }
}

验证

修改配置后重新执行./gradlew clean,即可正常解析Kotest插件并完成构建操作。

内容的提问来源于stack exchange,提问作者Christofer Ohlsson

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.04 21:12:42