Can I have sourceSet include imported java files similar to how ant javac does?

I am migrating a legacy ant build to gradle which leans heavily on ant’s ability to pull in dependant imports on the javac task.

one.java:

import two;
import three;

In ant javac, when I include one.java only, one, two and three classes get compiled. We will then package up the output dir without having to specify every file.

I know the right thing to do is actually make the gradle build sane, but I would like to take an iterative approach and get the build working 1:1 in gradle. Then go and refactor things.

I have tried specifying a sourceSet with the same includes as my javac task, but it has compile errors as it doesn’t automatically bring in java imports.

Any ideas?

I think Ant accomplishes this by passing a sourcepath to javac.

Interesting… I will look into this, thanks!