How to set sources for JavaCompile Task?

I’m trying to convert an old legacy project that uses ant over to gradle. I’ve been running gradle 6.6.1 and using the kotlin DSL. This project is structured with the main source files in src/java-main/app/, and test files in src/java-test/app. There are also several other source files in other directories. Ideally, I’d restructure this project into multiple modules with each using the traditional src/main/java/ directory structure, but I can’t do that just yet. If I change the main sourceset like so, I can build the main application just fine:

sourceSets {
  main {
    java { 
      setSrcDirs(setOf("src/java-main")) 
    }
}

I’ve created a custom JavaCompile task, and if I don’t explicitly set the source myself, the build completes successfully:

tasks.register<JavaCompile>("compileMainAppSrc") {
    sourceCompatibility = "1.8"
    targetCompatibility = "1.8"
}

But, if I explicitly try to set the source (which I need to do for those other src files currently present in the project), then the build fails:

tasks.register<JavaCompile>("compileTongalSrc") {
    sourceCompatibility = "1.8"
    targetCompatibility = "1.8"

    source(sourceSets["main"].java)
    classpath = sourceSets["main"].compileClasspath
    destinationDirectory.set(sourceSets["main"].java.destinationDirectory)
}

The build errors are all the same: error: cannot find symbol. It appears that the lombok annotations are not being properly processed anymore.

I do include the lombok plugin here:

plugins {
  java
  id("io.freefair.lombok") version "5.2.1"
}

And I have lombok defined in my dependencies as such:

dependencies {
  compileOnly("org.projectlombok:lombok:1.16.4")
  annotationProcessor("org.projectlombok:lombok:1.16.4")
}

Any help would be greatly appreciated!