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

**URL:** <https://discuss.gradle.org/t/how-to-set-permissions-for-directories-created-by-into-in-an-archive-or-copy-task/52200>\
**Category:** Help/Discuss\
**Created:** [September 6, 2026, 5:41pm UTC](https://discuss.gradle.org/t/how-to-set-permissions-for-directories-created-by-into-in-an-archive-or-copy-task/52200 "2026-09-06T17:41:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gradle\_user](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/gradle_user/32/11971_2.png) [@gradle\_user](https://discuss.gradle.org/u/gradle_user)\
**Post date:** [September 6, 2026, 5:41pm UTC](https://discuss.gradle.org/t/how-to-set-permissions-for-directories-created-by-into-in-an-archive-or-copy-task/52200/1 "2026-09-06T17:41:27Z")

</div>

I have the following task to bundle my application:

```gradle
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.

```gradle
❯ 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?

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [September 7, 2026, 2:13pm UTC](https://discuss.gradle.org/t/how-to-set-permissions-for-directories-created-by-into-in-an-archive-or-copy-task/52200/2 "2026-09-07T14:13:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![gradle\_user](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/gradle_user/32/11971_2.png) [@gradle\_user](https://discuss.gradle.org/u/gradle_user)\
**Post date:** [September 7, 2026, 3:31pm UTC](https://discuss.gradle.org/t/how-to-set-permissions-for-directories-created-by-into-in-an-archive-or-copy-task/52200/3 "2026-09-07T15:31:16Z")

</div>

OK, thank you. After posting this I was looking more into it, and I was able to fix it (with some AI help 🙂 ) 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.
