我是 Gradle 新手,当我尝试向
build.gradle
文件添加插件时,出现错误。我的 Gradle 版本是 8.1.1
。
plugins {
id 'java'
id "io.freefair.lombok" version "8.0.1"
}
group = 'me.harvanchik'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven {
name = "papermc-repo"
url = "https://repo.papermc.io/repository/maven-public/"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/groups/public/"
}
}
dependencies {
compileOnly "io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT"
}
def targetJavaVersion = 17
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
}
jar {
destinationDirectory.set(file("C:/my/path/plugins"))
}
tasks.withType(JavaCompile).configureEach {
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
options.release = targetJavaVersion
}
}
processResources {
def props = [version: version]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
}
}
An exception occurred applying plugin request [id: 'io.freefair.lombok', version: '8.0.1']
> Failed to apply plugin 'io.freefair.lombok'.
> Configuration with name 'mainSourceElements' not found.
我尝试过升级Gradle版本(现在是最新的),重新初始化项目,并重新启动IDE和计算机。似乎没有什么效果。
我也遇到了同样的问题。 在我的情况下,我将lombok的版本降级到6.5.0,就没有错误了。