将 -P 参数从 android studio 传递给 gradle [英] Passing -P parameters to gradle from android studio

查看:29
本文介绍了将 -P 参数从 android studio 传递给 gradle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

android studio 中是否有一个功能可以做这样的事情.基本上,我的 gradle 脚本读取名为 version 的参数,根据它设置某个库的依赖版本.因此,当我执行 gradlew -Pversion='1.2.3' 时,我会在 gradle 中得到这个字符串.但这只有在我从控制台调用 gradle 时才有效.

Is there a functionality inside android studio to do things like this. Basically my gradle script reads parameter named version based on which it sets dependency version of a certain library. So when I do gradlew -Pversion=‘1.2.3' I get this string inside gradle. But this only works if I invoke gradle from console.

在 Android Studio 中开始使用项目配置时,有没有办法将参数传递给 gradle(按小三角)?

Is there a way to pass parameters to gradle when started using configuration for project inside Android Studio (pressing little play triangle)?

注意:我确实在默认配置下找到了 Gradle VM 选项和脚本参数,但添加 -Pversion='1.2.3' 似乎没有效果.

NOTE:I did find Gradle VM options and Script prameters under default configs but adding -Pversion=‘1.2.3' there doesn't seem to have an effect.

推荐答案

为了给 Android Studio 的 run 选项提供参数,你应该在 AndroidStudios Compile Preferences 下设置它们

In order to provide parameter to run option of Android Studio you should setup them under AndroidStudios Compile Preferences

AndroidStudio > 偏好...

AndroidStudio > Preferences...

在编译器下:ComandLineOptions

Under Compiler: ComandLineOptions

这篇关于将 -P 参数从 android studio 传递给 gradle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆