Gradle can't import my Java 8 package because it thinks it's Java 11

My package has this in its gradle.build:

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

The project I’m trying to import it into also has this

When I try to build the project it throws this error:

Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Could not resolve com.saifxhatem:my-package:1.0.
     Required by:
         project :
      > No matching variant of com.saifxhatem:my-package:1.0 was found. The consumer was configured to find an API of a library compatible with Java 8, preferably in the form of class files, and its dependencies declared externally but:
          - Variant 'apiElements' capability com.saifxhatem:my-package:1.0 declares an API of a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
          - Variant 'runtimeElements' capability com.saifxhatem:my-package:1.0 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8

My IntelliJ is set Amazon Coretto 1.8