How to include a list of java source files from an external directory

Hi. I have a java/groovy project with the default structure (/src/main/groovy, /src/main/java, etc) in which I need to include a bunch of .java files from an external directory.

It’s a small project that uses some files from another project. I don’t want to add directories, as that would force me to include all the main project’s dependencies and they are a lot.

Is there an easy way to do that? I’ve searched everywhere but I haven’t found anything like that.


You could simply add them directly as source to the compileJava task.

compileJava {
    source '/dir/', '/dir/'

Hi, sorry for the delay. Thanks for your reply.