Multi-project dependency on plain Eclipse project without altering eclipse files

Hi,

We’d like to move some of our projects to Gradle (we use Eclipse/buildship) however
in a normal eclipse workspace we have several projects that often work together.
While some projects belong exclusively to a single EAR there’re a number of common
projects which are used as well in other contexts that are not ready to move to Gradle
and yet are still needed for the sake of build path or as libraries inside the ear.

Example

EclipseWorkspace
±-EarProjA
±-EJBProjA
±-WebProjA
±-JPAProjA
±-JPAProjCommon
±-CommonProj1
±-CommonProj2

Everything in this workspace is required for EarProjA and any other project which ends as “ProjA”
is used excusively for EarProjA so I could easily add a Gradle nature to them and manage
their build/dependencies via Gradle.
The problem are the common projects which are used for EarProjA as well as for other Ears in different
workspaces, I cannot add a Gradle nature to them because that would mess up their Eclipse files
and .classpath/.project/etc… causing a problem for other developers who are working with such projects in other workspaces and don’t use gradle.

I tried to refer to such projects via include, for example:

include ":CommonProj1"
project(':CommonProj1').projectDir = new File(settingsDir, '../CommonProj1') 

but the result is that when I Refresh the Gradle Project in Eclipse
it automatically turns CommonProj1 into a Gradle project altering its .project/.classpath/etc…

What’s the best way to handle such projects?

Many thanks

This is how Buildship works. When you import a project then all subprojects will be configured based on the configuration in the build scripts. However, if need to influence the .classpath file content you can do it in the eclipse.classpath.file.whenMerged {} block. You’ll find examples here.