Eclipse enable export "Project and External Dependencies"

For whomever this might still get handy:

The above example is not enough, it did not work for me either in latest Eclipse version or ancient Eclipse version I’m forced to use for some projects .

The Project and External Dependencies org.eclipse.buildship.core.gradleclasspathcontainer container must be explicitly added to containers, otherwise Buildship in Eclipse is adding the entry automatically so it is not available in the whenMerged hook for update if I understand it properly (How does Buildship create the .classpath file for Eclipse? - #5 by donat).

This is my working version that finally forced Eclipse Buildship to export the container:

eclipse {
  classpath {
    // see https://discuss.gradle.org/t/how-does-buildship-create-the-classpath-file-for-eclipse/26252/5
    containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
    
    file {
      whenMerged { classpath ->
        classpath.entries.findAll { entry -> entry.kind == 'con' & path == 'org.eclipse.buildship.core.gradleclasspathcontainer'}*.exported = true
      }
    }
  }
}