小编Abo*_*asi的帖子

如何读取setting.gradle中的local.properties文件

在此之前,我们在build.gradle中使用了此代码,但在 Gradle 更新后,存储库移至了setting.gradle。目前,我不知道如何读取setting.gradle文件中的属性。

def propFile = rootProject.file("./local.properties")
def properties = new Properties()
properties.load(new FileInputStream(propFile))

ext.alias = properties['mavenprivate.alias']
ext.key = properties['mavenprovate.key']
Run Code Online (Sandbox Code Playgroud)

并将它们用于 Maven 存储库:

credentials {
   username = alias
   password = key
}
Run Code Online (Sandbox Code Playgroud)

我收到这个错误:

无法获取 org.gradle.internal.credentials.DefaultPasswordCredentials_Decolated 类型的凭证 [用户名:null] 的未知属性“别名”。

Android 工作室北极狐,Gradle 7.0.2

android gradle android-studio

6
推荐指数
0
解决办法
407
查看次数

标签 统计

android ×1

android-studio ×1

gradle ×1