# Renaming playBinary distribution scripts

**URL:** <https://discuss.gradle.org/t/renaming-playbinary-distribution-scripts/12757>\
**Category:** Help/Discuss\
**Created:** [November 13, 2015, 7:39pm UTC](https://discuss.gradle.org/t/renaming-playbinary-distribution-scripts/12757 "2015-11-13T19:39:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![eriwen](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/eriwen/32/4786_2.png) [@eriwen](https://discuss.gradle.org/u/eriwen)\
**Post date:** [November 13, 2015, 7:39pm UTC](https://discuss.gradle.org/t/renaming-playbinary-distribution-scripts/12757/1 "2015-11-13T19:39:29Z")

</div>

I’m sure I’m missing something obvious here. I simply want to rename ./bin/playBinary generated by gradle dist with the “play” plugin to ./bin/foobar to ease transition from SBT.

I thought something like this or some variant would work

```
model {
  distributions {
    playBinary {
      contents {
        from('bin') {
          rename '.*playBinary', 'foobar'
        }
      }
    }
  }
}

```

Any advice, Gradlers?

---

<div class="post-metadata">

**Author:** ![Travis\_Camechis](https://avatars.discourse-cdn.com/v4/letter/t/e19adc/32.png) [@Travis\_Camechis](https://discuss.gradle.org/u/Travis_Camechis)\
**Post date:** [November 13, 2015, 8:51pm UTC](https://discuss.gradle.org/t/renaming-playbinary-distribution-scripts/12757/2 "2015-11-13T20:51:56Z")

</div>

Had the same question.

---

<div class="post-metadata">

**Author:** ![Gary\_Hale](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/gary_hale/32/7647_2.png) [@Gary\_Hale](https://discuss.gradle.org/u/Gary_Hale)\
**Post date:** [November 16, 2015, 4:39pm UTC](https://discuss.gradle.org/t/renaming-playbinary-distribution-scripts/12757/3 "2015-11-16T16:39:03Z")

</div>

Well, a rename is only going to apply for the copyspec that is actually copying the file, which is actually created/configured by the PlayDistribution plugin. I don’t think trying to get a hold of that particular child spec would be easy. You could add the rename() to the main spec (outside of the from() statement). Another option would be to add an eachFile block to the main spec that specifically targets that file:

```
   distributions {
        playBinary {
            contents {
                  eachFile { details ->
                    if (details.path == "${baseName}/bin/playBinary") {
                        details.name = "foobar"
                    }
                  }
              }
        }
    }
```

---

<div class="post-metadata">

**Author:** ![eriwen](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/eriwen/32/4786_2.png) [@eriwen](https://discuss.gradle.org/u/eriwen)\
**Post date:** [November 16, 2015, 7:54pm UTC](https://discuss.gradle.org/t/renaming-playbinary-distribution-scripts/12757/4 "2015-11-16T19:54:10Z")

</div>

Interestingly, using the code sample here produces a distribution with both ./bin/playBinary and ./bin/foobar.

Also, users should note that the script itself uses an APP\_NAME variable that is hardcoded to “playBinary”.

---

<div class="post-metadata">

**Author:** ![Gary\_Hale](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/gary_hale/32/7647_2.png) [@Gary\_Hale](https://discuss.gradle.org/u/Gary_Hale)\
**Post date:** [November 16, 2015, 8:16pm UTC](https://discuss.gradle.org/t/renaming-playbinary-distribution-scripts/12757/5 "2015-11-16T20:16:19Z")

</div>

I’m not seeing the behavior with both playBinary and foobar. Is it possible that it’s picking up playBinary from a previous run? (i.e. IIRC, stagePlayBinaryDist is a Copy task, so it won’t remove the previous script without a clean)

---

<div class="post-metadata">

**Author:** ![eriwen](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/eriwen/32/4786_2.png) [@eriwen](https://discuss.gradle.org/u/eriwen)\
**Post date:** [November 16, 2015, 8:38pm UTC](https://discuss.gradle.org/t/renaming-playbinary-distribution-scripts/12757/6 "2015-11-16T20:38:03Z")

</div>

Now that I think about it, I ran `gradlew cleanDist dist` which probably doesn’t clean the build/stage directory. Ignore my comment about duplicate scripts.

The APP\_NAME inside is still something to be dealt with, though.
