Classpath separation for source sets in Eclipse and IntelliJ using projects as source sets (multi-project build)

I wanted to explain how we solved classpath separation of source sets in inter-project dependency situations. Eclipse and IntelliJ like to include all source sets of a project at once when building from source. This is often really bad if a project you depend on has a test or graphical source set with a humongous classpath. You could use a class brought in from that project, commit, and Gradle will fail in your CI build because that class was actually not available.

We made a build plugin that solves this issue by making source sets (other than main) actually be supprojects in a multi-project build. In our plugin we actually go a mile further and use composite builds for actual inter-project dependencies. This includes a few hacks (using startParameter.searchUpwards) and a complex search algorithm to include builds during settings.gradle evaluation.

The project isn’t ready to go for general use, but we do use it for our 2M or so lines of Java code over 400+ projects across 3 companies, with around 2000 CI jobs cranking with it.

Feel free to browse the source here: https://github.com/ihmcrobotics/ihmc-build

What it ends up looking like in Eclipse and IntelliJ:

classpath1classpath2

Cheers,
Duncan Calvert
Research Associate
Florida Institute for Human and Machine Cognition
dcalvert@ihmc.us

1 Like