简体   繁体   中英

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM