Gradle 看不到来自 GRADLE_USER_HOME 的 gradle.properties

问题描述

注意:我已阅读所有出现相同错误主题,但没有找到解决方法

我在 Windows PC 上本地安装了 gradle,并尝试运行 execute C:\work\onsolve\acadia>gradle clean Starting a Gradle Daemon (subsequent builds will be faster) FAILURE: Build Failed with an exception. * Where: Build file 'C:\work\****\build.gradle' line: 7 * What went wrong: A problem occurred evaluating root project 'a****a'. > Could not get unkNown property 'prop1' for Credentials [username: null] of type org.gradle.internal.credentials.DefaultPasswordCredentials_Decorated. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD Failed in 3s 命令

gradle.properties

但是如果我将 C:\work\onsolve\acadia>gradle -v ------------------------------------------------------------ Gradle 6.9 ------------------------------------------------------------ Build time: 2021-05-07 07:28:53 UTC Revision: afe2e24ababc7b0213ccffff44970aa18035fc0e Kotlin: 1.4.20 Groovy: 2.5.12 Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020 JVM: 1.8.0_291 (Oracle Corporation 25.291-b10) OS: Windows 10 10.0 amd64 C:\work\***\***>set GRADLE_USER_HOME GRADLE_USER_HOME=C:\Users\***\.gradle GRADLE_USER_HOME(C:\Users***.gradle) 复制到项目文件夹 - 错误就会消失。

来自 cmd 的一些附加信息:

buildscript {
    repositories {
        mavenCentral()
        maven {
            url "https://artifactory.***.****.com/artifactory/maven" 
            credentials {
                username = "${artifactory_user}"
                password = "${artifactory_password}"
            }
        }
    }
    ...

我错过了什么?

附言

来自 build.gradle 的片段:

org.gradle.daemon=false
artifactory_user=****
artifactory_password=****

gradle.properties

'in-stock'

解决方法

build.gradle.kts

repositories {
    maven("url") {
        credentials {
            username = rootProject.properties["user"].toString()
            password = rootProject.properties["password"].toString()
        }
    }
    maven("url2")
    mavenLocal()
}

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...