android - How to run an exe file from gradle build during execution phase (Windows)
问题描述
I need to run an exe file during the execution phase of the build.
I know I can define something like this:
task executeScript(type:Exec) {
println 'Executing script...'
commandLine './script.sh'
}
But this is running the script during configuration phase. I tried to wrap the code with a doLast block:
task executeScript(type:Exec) {
doLast {
println 'Executing script...'
commandLine './script.sh'
}
}
But this return an error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:minifyAssets'.
> execCommand == null!
What should I do?
解决方案
我知道我可以定义这样的东西:
task executeScript(type:Exec) { println 'Executing script...' commandLine './script.sh' }
您的第一次尝试实际上是正确的。您的消息将在配置阶段打印,因为在配置println
任务时会评估调用executeScript
,但脚本本身在任务执行之前不会执行。
如果您想在任务执行之前打印一条消息,请尝试以下操作:
task executeScript(type:Exec) {
commandLine './script.sh'
doFirst {
println 'Executing script...'
}
}
推荐阅读
- c# - 为什么我不能在 Visual Studio 2012 和 2015 中添加对项目的引用?
- javascript - 减少函数中的变异累加器是否被认为是不好的做法?
- c# - 绑定到代码隐藏动态变量在多重绑定中不起作用
- pandas - 如何删除两列中的相同单词?两行重复
- reactjs - ReactJS:如何渲染对象集合
- git - github/git Checkout 在 Windows 上返回“错误:无效路径”
- c - 我一直在“hiddenLetters[i] = '_';”行中看到取消引用空指针警告?
- c# - 订阅热巧克力“RESULT_TYPE_NOT_SUPPORTED”
- apache-spark - 使用 dataframe.schema VS dataframe.printSchema() 比较 pyspark 模式
- android - WifiNetworkSpecifier 不会触发编译时错误