gpt4 book ai didi

gradle - ~/.gradle/gradle.properties 文件未被读取

转载 作者:行者123 更新时间:2023-12-03 02:44:50 25 4
gpt4 key购买 nike

这里有一个类似的问题:Gradle properties not being read from ~/.gradle/gradle.properties,但它不能解决我的问题。

在我看来,gradle 没有读取我的 ~/.gradle/gradle.properties 文件。

我在 ~/.gradle 中有一个 gradle.properties 文件,它具有在上传到 Maven Central 之前对工件进行签名所需的属性。它看起来像这样:

signing.keyId=12345678
signing.password=myPassword
signing.secretKeyRingFile=/home/me/.gnupg/secring.gpg

sonatypeUsername=me
sonatypePassword=myOtherPassword

当我尝试构建我的项目时,它提示没有 sonatypeUsername 属性,因此:

> Could not find property 'sonatypeUsername' on root project 'yourProject'.

这是我的项目的 build.gradle 的相关部分:

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'.

最佳答案

问题是我做出了一个不正确的假设。如果你看section 14.2 of the gradle documentation ,它说:

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.

我的不正确假设是 USER_HOME 只是默认为标准 Linux HOME 环境变量。这不是真的。

一旦我在 ~/.bashrc导出 USER_HOME=$HOME 一切正常

关于gradle - ~/.gradle/gradle.properties 文件未被读取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28289172/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com