What's a good pattern for separating API from implementation?

I just added a sample to our source tree that shows one way to do this:

https://github.com/gradle/gradle/tree/master/subprojects/docs/src/samples/java/apiAndImpl

However, none of the current IDEs can handle this without a lot of manual tweaking. That is, you can’t use the current Gradle IDEA or Eclipse integration with projects like this. If you want IDE support, your only real option is to split into multiple projects.

To my taste, this would be the ideal way to structure a project that is logically one thing but you do want to separate api from impl. That said, I’d probably split into multiple projects just for the IDE support.

You’ll also notice there is quite a lot of wiring in there. In the future we’ll have a DSL to express this kind of thing which would reduce all of this to just a few lines.