Renaming playBinary distribution scripts

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?

Had the same question.

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"
                    }
                  }
              }
        }
    }
1 Like

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”.

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)

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.