问题描述
我想为我的android项目中的脚本设置脚本路径,而不使用严格的路径(/User/Documents/MyApp/tools/script.sh
)和“工作目录” 。 / p>
我知道我可以使用“外部工具” ,但是此解决方案无效,因为所有项目开发人员都必须使用“外部工具”设置导入我的jar文件
我可以使用 $ ProjectFileDir $ 变量以某种方式写此路径吗?
解决方法
到目前为止,配置的路径值中有no direct way to use these variables。
或者,您可以在gradle
文件中创建一个task
app/gradle
来运行您的Shell脚本:
task runSS {
doLast{
exec {
// chmod u+rwx demo.sh to make file executable
executable "../demo.sh"
}
}
}
// other gradle tasks
请确保使用
chmod u+rwx file_name
将文件的权限更改为可执行文件。
现在运行文件:
输出: