# Distributions - strip top level directory

**URL:** <https://discuss.gradle.org/t/distributions-strip-top-level-directory/14873>\
**Category:** Help/Discuss\
**Created:** [March 2, 2016, 2:06pm UTC](https://discuss.gradle.org/t/distributions-strip-top-level-directory/14873 "2016-03-02T14:06:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cleankod](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/cleankod/32/4212_2.png) [@cleankod](https://discuss.gradle.org/u/cleankod)\
**Post date:** [March 2, 2016, 2:06pm UTC](https://discuss.gradle.org/t/distributions-strip-top-level-directory/14873/1 "2016-03-02T14:06:14Z")

</div>

Is there a way to strip a top level directory when creating a distribution archives using the distribution plugin?

My config:

```
distributions {
    main {
        baseName = 'my_app'
        contents {
            from {
                "$buildDir/distribution-files/application"
            }
        }
    }
}

```

And after I issue:

```
gradle distZip

```

The resulting archive has a top level directory with the same name as the archive itself:

```
my_app-1.0.0.zip
    my_app-1.0.0
        contents

```

And I must deliver the package as follows:

```
my_app-1.0.0.zip
    contents
```

---

<div class="post-metadata">

**Author:** ![Nikolay](https://avatars.discourse-cdn.com/v4/letter/n/a698b9/32.png) [@Nikolay](https://discuss.gradle.org/u/Nikolay)\
**Post date:** [March 2, 2016, 2:57pm UTC](https://discuss.gradle.org/t/distributions-strip-top-level-directory/14873/2 "2016-03-02T14:57:43Z")

</div>

Try [this](https://docs.gradle.org/current/javadoc/org/gradle/api/file/RelativePath.html):

```
distributions {
    main {
        baseName = 'my_app'
        contents {
            from {
                "$buildDir/distribution-files/application"
            }
            eachFile { FileCopyDetails fcp ->
              fcp.relativePath = new RelativePath(true, fcp.relativePath.pathString.replace('my_app-1.0.0/', ''))
            }
        }
    }
}
```

---

<div class="post-metadata">

**Author:** ![cleankod](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/cleankod/32/4212_2.png) [@cleankod](https://discuss.gradle.org/u/cleankod)\
**Post date:** [March 2, 2016, 3:43pm UTC](https://discuss.gradle.org/t/distributions-strip-top-level-directory/14873/3 "2016-03-02T15:43:38Z")

</div>

Naah. I found a better solution:

```
distributions {
    main {
        baseName = 'my_app'
        contents {
            from {
                "$buildDir/distribution-files/application"
            }
            into '/'
        }
    }
}

```

The following attribute is the key here:

```
into '/'

```

But thanks anyway.
