Prevent Gradle CopyTask from copying

I have a function astDump that fills an output file with results computed from an input file. I want to run this on a source tree. The only solution I have found so far is the one below:

task pmdAstDump(type: Copy) {
    from('src/main/java') {
    rename '(.*)\\.java', '$1.ast'
    eachFile { FileCopyDetails fcd ->
        // println  "${fcd.file} => ${file('build/ast/'+fcd.getRelativePath()).absolutePath}"
        astDump(fcd.file, new File(file('build/ast/'+fcd.getRelativePath()).absolutePath))

Unfortunately the CopyTask copies files. I work around this by copying them to /tmp/junk for now. It would solve my problem if I could stop this. But the solution above is awkward anyway. Any better way is welcome.

I just learned about from Google Groups about


which will do what I need.

Actually imho you shouldn’t use a Copy task at all.
You do not actually want to copy files and also your task is not properly up-to-date, it might be recognized as up-to-date though it is out of date, for example if output files were deleted or modified, or it might be out-of-date when it should be up-to-date.

Better make an own task where you properly declare inputs and outputs.
You can do that as ad-hoc task, or maybe better as a proper task class in an included build or buildSrc.
You can then even make it a task with incremental input handling, so that if one file is added, modified, or deleted, only that file needs to be processed instead of all input files.