Application plugin very inflexible w.r.t. start scripts

Hello. First, this is not technically a bug, but this seemed like the most relevant place to post this. If it belongs elsewhere then I apologize.

I recently ported a heavily customized Ant-based build system to Gradle and one frustration I had involved the default behavior around start scripts as configured by the Application plugin.

  1. The start scripts’ install/include location is not customizable. We have an existing distro layout that we want to keep, in which start scripts are at the root instead of /bin, but because this is not configurable you are left with two options: eachFile (see #2) or disabling startScripts and including your own separately (then you hit #3).

  2. You can work around the lack of configurability by using an eachFile closure on your distribution to selectively modify the relative path just for the start scripts. This works for the zip/tar distributions, but causes installDist (and installApp) to fail (see #3).

  3. installDist is hard-coded to run chmod a+x on $destDir/bin/$appName. This will cause the task to fail if the file doesn’t exist, perhaps because you moved it or you disabled startScripts.

What we ended up doing was

  • disabling startScripts entirely (so the default scripts would not be included in any distributions)
  • including our own custom scripts as normal files in the distributions
  • creating a dummy script before installDist and then deleting it and /bin afterward (see here)

There are two ways things could be better:

  1. The bin dir could be set via a property, so that one could include custom scripts by customizing the output of startScripts but leave everything else as default, and/or
  2. In case you want to simply disable startScripts and handle things yourself, installDist could be made to not attempt to modify permissions of nonexistent files.