问题描述
我在 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()
}