〜/ .gradle / gradle.properties文件没有被读取 [英] ~/.gradle/gradle.properties file not being read
问题描述
这里有一个类似的问题: Gradle属性不是阅读〜/ .gradle / gradle.properties ,但它不能解决我的问题。
在我看来,gradle不读我的 我在 当我尝试构建我的项目时,它抱怨没有sonatypeUsername属性,因此: 以下是我的项目build.gradle的相关部分: 当我尝试通过调试来构建项目时,以下是我在属性中看到的内容: 问题是我做了一个假设,没错。如果您查看 Gradle文档的第14.2节,它会说: 您可以将Gradle.properties文件放入Gradle用户主目录(由GRADLE_USER_HOME环境变量定义,如果未将缺省值设置为USER_HOME / .gradle)或在您的项目目录中。 我的错误假设是USER_HOME只默认了标准的linux HOME环境变量。这是不正确的。 只要我 There is a similar question here: Gradle properties not being read from ~/.gradle/gradle.properties but it does not solve my problem. It seems to me that gradle is NOT reading my I have a gradle.properties file in When I try to build my project, it complains that there's no sonatypeUsername property, thus: Here's the relevant portion of my project's build.gradle: When I try to build the project with debugging, here's what I see regarding properties:
The problem was that I made an assumption that wasn't true. If you look at section 14.2 of the gradle documentation, it says: You can place a gradle.properties file in the Gradle user home directory (defined by the "GRADLE_USER_HOME" environment variable, which if not set defaults to USER_HOME/.gradle) or in your project directory. My incorrect assumption was that USER_HOME just defaulted to the standard linux HOME environment variable. This is not true. As soon as I 这篇关于〜/ .gradle / gradle.properties文件没有被读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!文件。
中有一个gradle.properties文件〜 /.gradle
,它具有在上传到maven central之前签署工件所需的属性。它看起来像这样:
signing.keyId = 12345678
signing.password = myPassword
signing.secretKeyRingFile = / home / me / .gnupg / secring.gpg
sonatypeUsername = me
sonatypePassword = myOtherPassword
>无法在根项目'yourProject'上找到属性'sonatypeUsername'。
uploadArchives {
repositories {
mavenDeployer {
//很多无趣的东西在这里
repository(url:https://oss.sonatype.org/service/local/staging/deploy/maven2/){
authentication(userName:project.property(sonatypeUsername),password: project.property(sonatypePassword))
}
}
}
}
$ ./gradlew --stacktrace --debug build
[INFO] [ogBuildLogger]开始构建
[DEBUG] [ogBuildLogger] Gradle用户home:/ home / me
[DEBUG] [ogBuildLogger]当前目录:/ home / me / dev / yourProject
[DEBUG] [ogBuildLogger]设置文件:null
[DEBUG] [ogBuildLogger] Build file:null
[DEBUG] [o.g.i.b.BuildSourceBuilder]开始构建构建源。
[DEBUG] [o.g.i.b.BuildSourceBuilder] Gradle源目录不存在。我们离开。
[DEBUG] [ogiDefaultGradlePropertiesLoader]找到env项目属性:[]
[DEBUG] [ogiDefaultGradlePropertiesLoader]找到系统项目属性:[]
[DEBUG] [ogaiamDefaultLocalMavenRepositoryLocator]在设置文件中定义。使用默认路径:/home/me/.m2/repository
[DEBUG] [o.g.i.ScriptEvaluatingSettingsProcessor]计时:处理设置花费:0.286秒
[INFO] [o.g.BuildLogger]使用空设置脚本评估的设置。
[DEBUG] [o.g.i.ProjectPropertySettingBuildLoader]从以下项目寻找项目属性:/home/me/dev/yourProject/gradle.properties
[调试] [o.g.i.ProjectPropertySettingBuildLoader]项目属性文件不存在。我们继续!
[INFO] [o.g.BuildLogger]已加载项目。使用构建文件/home/me/dev/yourProject/build.gradle的根项目。
导出USER_HOME = $ HOME
在我的 〜/ .bashrc
一切正常~/.gradle/gradle.properties
file.~/.gradle
, and it has properties needed to sign artifacts before uploading to maven central. It looks like this:signing.keyId=12345678
signing.password=myPassword
signing.secretKeyRingFile=/home/me/.gnupg/secring.gpg
sonatypeUsername=me
sonatypePassword=myOtherPassword
> Could not find property 'sonatypeUsername' on root project 'yourProject'.
uploadArchives {
repositories {
mavenDeployer {
// lots of non-interesting things here
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: project.property("sonatypeUsername"), password: project.property("sonatypePassword"))
}
}
}
}
$ ./gradlew --stacktrace --debug build
[INFO] [o.g.BuildLogger] Starting Build
[DEBUG] [o.g.BuildLogger] Gradle user home: /home/me
[DEBUG] [o.g.BuildLogger] Current dir: /home/me/dev/yourProject
[DEBUG] [o.g.BuildLogger] Settings file: null
[DEBUG] [o.g.BuildLogger] Build file: null
[DEBUG] [o.g.i.b.BuildSourceBuilder] Starting to build the build sources.
[DEBUG] [o.g.i.b.BuildSourceBuilder] Gradle source dir does not exist. We leave.
[DEBUG] [o.g.i.DefaultGradlePropertiesLoader] Found env project properties: []
[DEBUG] [o.g.i.DefaultGradlePropertiesLoader] Found system project properties: []
[DEBUG] [o.g.a.i.a.m.DefaultLocalMavenRepositoryLocator] No local repository in Settings file defined. Using default path: /home/me/.m2/repository
[DEBUG] [o.g.i.ScriptEvaluatingSettingsProcessor] Timing: Processing settings took: 0.286 secs
[INFO] [o.g.BuildLogger] Settings evaluated using empty settings script.
[DEBUG] [o.g.i.ProjectPropertySettingBuildLoader] Looking for project properties from: /home/me/dev/yourProject/gradle.properties
[DEBUG] [o.g.i.ProjectPropertySettingBuildLoader] project property file does not exists. We continue!
[INFO] [o.g.BuildLogger] Projects loaded. Root project using build file '/home/me/dev/yourProject/build.gradle'.
export USER_HOME=$HOME
in my ~/.bashrc
everything works