How to grab increment class files after the java file is modifed

After the java file is modified, how to obtain the modified gradle incremental class file compiled, I want to find them and copy them to a folder,not all classes as long as the modified java file compiled;

i want to get a increment zip by this classes

i wrote below

compileJava {
    doLast {
        println  outputs.getFiles().getFiles()
    }
}

but get


:compileJava
[xxx\build\dependency-cache,xxx\build\classes\main]

BUILD SUCCESSFUL

Total time: 10.32 secs
I need help,thx

Hello, I had a similar Problem, maybe this helps:

https://discuss.gradle.org/t/get-list-of-java-files-that-changed/?source_topic_id=24771

The problem with your approach is that the source set / compile task output is only a set of directories, not a collection of single files.