Your issue is you are using a ‘FileTree’ for your classes directory. A ‘FileTree’ is evaluated in this case as a collection of files. In this instance the paths returned by the ‘files()’ method are simply added to the classpath when calling ‘javac’. When adding .class files to your classpath you must point to a directory that contains .class files, not the individual files themselves. See the Oracle documentation for more info.
“For .class files in a named package, the class path ends with the directory that contains the “root” package (the first package in the full package name).”
Modify your script to simply point at the directory containing the class files.