How to generate the startup-script in Windows PowerShell?


(Masashi Fujita) #1

I use the application plugin to create startup script (on windows). Currently only for /bin/sh and cmd.exe version was generated, but I want to use PowerShell one directly.

I’ve written PowerShell version of startup like https://gist.github.com/objectx/e843854781e592a8ace1 . But I can’t find the way to integrate it to gradle. Digging into the grade source, I can’t find the easy way to do that.

Regards


Startup script using PowerShell
(Benjamin Muschko) #2

If you want to replace the contents of the Windows script that is usually generated, you can simply set the template used by the windowsStartScriptGenerator. Note: This is a Gradle 2.4 feature.

startScripts.windowsStartScriptGenerator.template = resources.text.fromFile('customWindowsStartScript.txt')

At the moment you cannot tell the task to use a different start script name. If you’d like to use a different script name, you could probably just rename it after the fact.

startScripts.doLast {
    // rename file by referencing startScripts.windowsScript
}