The process cannot access the file since gradle 8

Hi,
since I updated my build to gradle 8, so 8.2.1 at the moment, but also earlier on, my build construct does not work anymore.
The construct looks like this:

	task buildFeature(type: Zip) {
    	from buildNative
    	exclude '**/*project*.zip'
	}

	task buildTemplate(type: Zip) {
    	dependsOn buildNative
    	archiveClassifier = 'template'
    	from {
        	buildNative.outputs.files.asFileTree.filter {file->file.name.endsWith('_template.zip')}.collect{zipTree(it)}
    	}
	}

	task buildNative {
    	outputs.dir('out')
    	if (OperatingSystem.current().isWindows()) {
        	dependsOn 'buildwindows'
    	}
    	if (OperatingSystem.current().isLinux()) {
        	dependsOn 'buildunix'
    	}
	}

	task buildwindows(type: Exec) {
    	dependsOn extractDeps
    	commandLine 'cmd','/c', 'build.bat', version.replaceAll("-.*","")
	}

	artifacts {
    	template buildTemplate
    	feature buildFeature
	}

build.bat calls a 3rd Party Java tool to compile stuff.
With gradle 7 everythig works fine, so it was with gradle 5 and 6, but now I get

The process cannot access the file because another process has locked a portion of the file
java.io.IOException: The process cannot access the file because another process has locked a portion of the file
	at java.io.FileInputStream.readBytes(Native Method)
	at java.io.FileInputStream.read(FileInputStream.java:233)

So I suspect the outputs.dir statement in buildNative, but this is necessarry, without it, in buildTemplate there is nothing to work with.

Is there anything I could do to at least debug a little more? Some parameter to see, what file is the problem, or what folder. Or maybe someone knows about the change in gradle 8 that results in this?
Of cause this is a windows only problem, there is no issue when running this on linux.

Thanks, Stefan