I have a custom JavaCompile task to work on pre-processed (obfuscation etc.) java source files. First I copy the sources (including my own dependencies) in one place and then compile to make a fat jar with this step.
as there is no dependencies method on the JavaCompile task.
The next point is, that the compile configuration is deprecated since years, you should for example use implementation instead.
You need to add your external dependencies to the classpath property to have them on the class path during compilation. You want to add configurations.compileClasspath.