Problem in adding new configuration for a new sourceset

I am adding a new configuration for my newly added sourceset.

Sourceset: tools configuration: toolsCompile

In the toolsCompile I am adding few java files as dependencies. The problem is since configuration flattens the fileTree all java files loses their package/folder structure. As a result compilation fails saying Package doesn’t exist.

You can’t depend on Java files, you need to depend on compiled class files.