Gradle doesn't see gradle.properties from GRADLE_USER_HOME

1.3k Views Asked by At

CAUTION: I've read all topics with the same error but didn't found the way to fix

I've installed gradle locally on my windows PC and I try to run execute gradle clean command

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

But if I copy gradle.properties from GRADLE_USER_HOME(C:\Users***.gradle) to the project folder - error disappears.

Some additional info from cmd:

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

What have I missed ?

P.S.

snippet from build.gradle:

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

gradle.properties :

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

There are 2 best solutions below

2
On

build.gradle.kts

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

In my case, the issue was because org.gradle.unsafe.configuration-cache=truein gradle.properties. When I removed this line it started to work.