Can't apply plugin: maven-publish

You are resolving dependencies during the configuration phase, which is too early and leads to your problem.

The manifest attributes are computed lazily by calling their toString() method. So you can do something like


jar {
  manifest {
    attributes(
      "Class-Path": new ManifestClasspath(configurations.earlib)
    )
  }
}

@groovy.transform.Canonical
class ManifestClasspath {
  Configuration configuration

  String toString() {
    configuration.files.name.join(' ')
  }
}

You can also do it shorter by using the fact that Groovy’s GStrings are lazy. But it might look a little too magic:

attributes(
  "Class-Path": "${configurations.earlib.files*.name.join(' ')}"
)