Reference resources/java files between modules?

While migrating an ant build to a gradle build i came across the following pattern quite often: - module A generates java sources - module B compiles those sources

The current approach is the same like the one in ant, copy over the files or reference the files in module A from module B.

Are there better approaches to that? - Is it possible to reference a source set from a different module with additional filters? - How is the general approach to reference resources from other modules? – Those resources are often used during generation – As an example is a generation configuration file which is used in several places

PS: Is there a way to preview a post before posting it?