2

I am new to Gradle, and when I try adding a plugin to the build.gradle file, I get an error. My Gradle version is 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.

I have tried upgrading the Gradle version (it's up to date now), reinitializing the project, and restarted IDE and computer. Nothing seems to have worked.

harvanchik
  • 78
  • 5
  • Worked fine locally. Did you try in a terminal where `JAVA_HOME` is properly set as a baseline? – User51 Apr 27 '23 at 19:17
  • 2
    After trying in a terminal, it worked fine. So it must be a problem with IntelliJ. Though, I'm not sure how to solve this problem still. – harvanchik Apr 28 '23 at 03:11
  • 1
    The usual... Close IJ. Delete `.idea/`. Delete `.build/` (all of them). Remove from recent projects. Re-open project. Open project settings. Set JDK. Open Terminal Settings. Set JAVA_HOME. Open Gradle Settings. Set Gradle Java SDK.... Whatever other settings IntelliJ may want that day. – User51 Apr 28 '23 at 13:04
  • yup. For me, a project cleanup did the trick. I'm assuming it's some IntelliJ quirk that causes this. – spamove Aug 29 '23 at 17:39

1 Answers1

0

I encountered the same question. In my situation, I degrade the lombok's version to 6.5.0, there was no error any more.