在 Android Studio 中的文件中使用 Gradle nexus 密码 - 创建全局属性



这是我的代码:

Build.Gradle (project(:

allprojects {
repositories {
jcenter()
mavenCentral()
maven {
url "${nexusUrl}/repository/maven-public/"
credentials {
username = nexusUsername
password = nexusPassword
}
}
}
}

gradle.properties (项目属性(:

nexusUrl=*********
nexusUsername=*********
nexusPassword=******

我想在全局变量而不是项目变量的外部文本文件中拥有 nexusUrl、nexus用户名

但是此错误不断显示:

Error:(24, 0) Could not get unknown property 'nexusUrl' for object of type org.gradle.api.internal.artifacts.repositories.DefaultMavenArtifactRepository

提前谢谢你

好的,我找到了解决方法。事实上,我想要的是将 gradle 属性作为全局变量而不是项目目录。

所以我把用户名和密码移到了'USER_HOME/.gradle'。

USER_HOME通常是指由操作系统确定的主目录。在 Windows 中,这是 C:\Users\。正如代码学徒在 https://stackoverflow.com/questions/39175388/where-is-the-user-home-folder-for-gradle-properties 中所述

有关全局变量的教程在这里: http://mrhaki.blogspot.fr/2015/10/gradle-goodness-setting-global.html

这是我的解决方案代码:

Build.Gradle (project(:

allprojects {
repositories {
jcenter()
mavenCentral()
maven {
url "${nexusUrl}/repository/maven-public/"
credentials {
username = nexusUsername
password = nexusPassword
}
}
}
}

gradle.properties (全局属性(:

nexusUrl=*********
nexusUsername=*********
nexusPassword=******

谢谢你们的帮助(我已经编辑了我的问题以反映问题(

最新更新