Eclipse enable export "Project and External Dependencies"

I am trying to learn gradle with an eye towards migrating a large, multi project eclipse from an ant build to gradle. The eclipse projects depend on each other with controlled “Order and Export” between them. Each project may have a “lib” directory with extra jars that are included as libraries and exported. Conventional state-of-the-art 2000s stuff.

The project is too large to convert all projects into gradle nature at once. Since an eclipse gradle project cannot depend on an eclipse non-gradle project (correct?), I have to start with the lowest level project, convert it, then move out. Small painful step by small painful step.

With my gradle-converted eclipse project, the “Java Build Path” -> “Order and Export” -> “Project and External Dependencies” defaults to false. I need it to be true so the project “looks the same” to the dependent non-gradle projects. If I make it true manually, it is reset to false whenever gradle refreshes.

I presume that field corresponds to something in the gradle Eclipse model that I can configure, but I have not been able to find it. TIA.

I found an example that led me to a solution.

The following will export all jars:

eclipse {
	classpath {
			file {
				whenMerged { classpath ->
					classpath.entries.findAll { entry -> entry.kind == 'con' & path == 'org.eclipse.buildship.core.gradleclasspathcontainer'}*.exported = true
				}
			}
	}
}

The following will export the project’s “Project and External Dependencies”, which includes all jars:

eclipse {
	classpath {
			file {
				whenMerged { classpath ->
					classpath.entries.findAll { entry -> entry.kind == 'con' & path == 'org.eclipse.buildship.core.gradleclasspathcontainer'}*.exported = true
				}
			}
	}
}

P.S. Be sure to run the “ide->eclipse” task to make this change. The “build” task does not do the job. That was a little frustrating…

How do I run the “ide->eclipse” task?

Thank you for this helpful post!