使用toml设置spotless gradle插件时出现问题

whitzsjs  于 2023-02-23  发布在  其他
关注(0)|答案(1)|浏览(264)

我在项目中使用libs.version.toml,并添加了以下内容

[versions]
spotless = "6.13.0"
[libraries]
spotless-gradlePlugin = { group = "com.diffplug.spotless", name = "spotless-gradle-plugin", version.ref = "spotless" }
[plugins]
spotless = {id = "com.diffplug.spotless", version.ref = "spotless"}

然后在build.gradlebuild-logic中有这个

plugins {
    `kotlin-dsl`
}
group = "com.mygroup.buildlogic"

java {
    sourceCompatibility = JavaVersion.VERSION_11
    targetCompatibility = JavaVersion.VERSION_11
}

repositories {
    google()
    mavenCentral()
}

dependencies {
    compileOnly(libs.spotless.gradlePlugin)
}
....

但我得到这个错误

build-logic:main: Could not find com.diffplug.spotless:spotless-gradle-plugin:6.13.0.
Searched in the following locations:
  - https://dl.google.com/dl/android/maven2/com/diffplug/spotless/spotless-gradle-plugin/6.13.0/spotless-gradle-plugin-6.13.0.pom
  - https://repo.maven.apache.org/maven2/com/diffplug/spotless/spotless-gradle-plugin/6.13.0/spotless-gradle-plugin-6.13.0.pom
Required by:
    project :build-logic

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

我错过了什么?

f0ofjuux

f0ofjuux1#

您需要将gradlePluginPortal()添加到repositories块中

repositories {    
    gradlePluginPortal()
    google()
    mavenCentral()
}

相关问题