How to set permissions for directories created by into() in an Archive or Copy task

I have the following task to bundle my application:

tasks.register<Tar>("bundleApp") {
    archiveFileName = "myapp.tar"
    dirPermissions { unix("0750") }
    into("webapps/myapp") {
        with(tasks.war.get())
    }
}

Directories specified in into() and directories created internally by the War task take the default permissions, instead of the ones specified in the task.

❯ tar -tvf myapp.tar | grep 'drwxr-xr-x'
drwxr-xr-x 0/0               0 2026-09-06 13:39 webapps/
drwxr-xr-x 0/0               0 2026-09-06 13:39 webapps/myapp/
drwxr-xr-x 0/0               0 2026-09-06 13:39 webapps/myapp/META-INF/
drwxr-xr-x 0/0               0 2026-09-06 13:39 webapps/myapp/WEB-INF/
drwxr-xr-x 0/0               0 2026-09-06 13:39 webapps/myapp/WEB-INF/classes/
drwxr-xr-x 0/0               0 2026-09-06 13:39 webapps/myapp/WEB-INF/lib/

I also tried setting the permissions on the AbstractArchiveTask, but that didn’t make any difference. Is there a way to set all directory permissions consistently?

I also don’t see who this could be done.
Maybe this is a bug.
I’d recommend you open an issue ticket about it if there is none yet.
Even with the old dirMode and fileMode the behavior was the same.

OK, thank you. After posting this I was looking more into it, and I was able to fix it (with some AI help :slight_smile: ) for the Copy task, which has the same problem. But the Zip/Tar tasks are still not working correctly, so that will require some more looking.