Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling a powershell script with Gradle

I am new to Gradle, so bear with me.. I am simply trying to call a .ps1 file to execute with gradle. How would I go about setting up a build.gradle file to execute the .ps1 file within the same directory? Thanks in advance!

like image 854
Stacker Avatar asked Jun 25 '26 05:06

Stacker


1 Answers

You can use gradle Exec

Example:

task execPs(type:Exec) {
   commandLine 'cmd', '/c', 'Powershell  -File  sample.ps1'
}
// add this task to your build.gradle file and execute gradle execPs
// You can use a different name for this task 
// You can add a dependency to include this task as part of your normal build. (like below) 
// build.finalizedBy(execPs)
// with the above command gradle build will call your task at the end of build
like image 174
miskender Avatar answered Jun 28 '26 02:06

miskender



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!