2

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=****
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
  • could you add the snippet of how you read that prop1, something like -> https://discuss.gradle.org/t/read-a-property-from-gradle-properties/27148/2 – sschrass Jul 13 '21 at 11:17
  • where are you using gradle?android project? –  Jul 13 '21 at 11:21
  • 1
    @Gabriel Aguiar - legacy java spring project – gstackoverflow Jul 13 '21 at 11:25
  • @gstackoverflow show me gradle.properties –  Jul 13 '21 at 11:26
  • @sschrass added requested information – gstackoverflow Jul 13 '21 at 11:29
  • 1
    @Gabriel Aguiar please read topic update – gstackoverflow Jul 13 '21 at 11:29
  • you hae a gradle-wrapper.properties? –  Jul 13 '21 at 11:37
  • @Gabriel Aguiar yes I have but I used `gradle clean` but not `gradlew clean` – gstackoverflow Jul 13 '21 at 11:40
  • @Gabriel Aguiar I don't have `local.properties` – gstackoverflow Jul 13 '21 at 11:53
  • @gstackoverflow add this to your gradle.properties and restart your IDE gradle.user.home=C:/Users/you user/.gradle and change system variable path to C:/Users/you user/.gradle –  Jul 13 '21 at 11:54
  • @Gabriel Aguiar could you please explain in details what should I do. From my point of view all env variabes are set correctly – gstackoverflow Jul 13 '21 at 12:16
  • @gstackoverflow change GRADLE_USER_HOME path to C:/Users/you user/.gradle –  Jul 13 '21 at 12:39
  • @gstackoverflow and add gradle.user.home=C:/Users/you user/.gradle to gradle.properties file –  Jul 13 '21 at 12:40
  • @Gabriel Aguiar GRADLE_USER_HOME is set properly according my initial post. Please reread. But this phrase is not clear **and add gradle.user.home=C:/Users/you user/.gradle to gradle.properties file** Sounds too complex. My teammates doesn't have it and it works for them properly – gstackoverflow Jul 13 '21 at 16:40
  • What `gradle clean --debug` produces? Does `Gradle user home:` value appears? – LMC Jul 22 '21 at 03:02
  • @LMC I see line 2021-07-22T11:19:56.963+0300 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] Setting project property: env.GRADLE_USER_HOME -> C:\Users\myusername\.gradle – gstackoverflow Jul 22 '21 at 08:21
  • @LMC Also I see: `2021-07-22T11:31:11.064+0300 [DEBUG] [org.gradle.initialization.ProjectPropertySettingBuildLoader] Looking for project properties from: C:\work\***\gradle.properties 2021-07-22T11:31:11.064+0300 [DEBUG] [org.gradle.initialization.ProjectPropertySettingBuildLoader] project property file does not exists. We continue! ` – gstackoverflow Jul 22 '21 at 08:35
  • `2021-07-22T11:31:11.064+0300 [DEBUG] [org.gradle.initialization.ProjectPropertySettingBuildLoader] Looking for project properties from: C:\work\***\c***\gradle.properties 2021-07-22T11:31:11.064+0300 [DEBUG] [org.gradle.initialization.ProjectPropertySettingBuildLoader] project property file does not exists. We continue!` – gstackoverflow Jul 22 '21 at 08:35
  • `2021-07-22T11:31:11.064+0300 [DEBUG] [org.gradle.initialization.ProjectPropertySettingBuildLoader] Looking for project properties from: C:\work***\***-common\gradle.properties 2021-07-22T11:31:11.064+0300 [DEBUG] [org.gradle.initialization.ProjectPropertySettingBuildLoader] project property file does not exists. We continue! 202` – gstackoverflow Jul 22 '21 at 08:36
  • wow! It doesn't find the file even being there. What if you try in a clean project? I mean, no previous gradle activity there before, with a different user if possible. Should work or, there's a phantom in your project lol – LMC Jul 22 '21 at 12:58
  • @LMC could you please provide detailed steps what to do ? I didn't get what should I do – gstackoverflow Jul 22 '21 at 17:54
  • I see two directories inside projects (Linux), `gradle` and `.gradle`. I say, copy your whole project, delete those directories there and run gradle. – LMC Jul 22 '21 at 17:57
  • 1. What do you get if you run the command “dir %GRADLE_USER_HOME%” , does it show the contents of your .gradle folder with gradle.properties file? 2. Does the .gradle folder have correct access rights? (You can try running the gradle command in a CMD terminal started in Administration mode.) 3. Does your .properties file use correct line endings e.g. CRLF or LF and does the last character in your properties end with CRLF or LF. (I have encountered once that a properties file could not be loaded into a java program running on a linux os because it ended with CRLF instead of LF.) – guicey Jul 22 '21 at 20:15

2 Answers2

0

build.gradle.kts

repositories {
    maven("url") {
        credentials {
            username = rootProject.properties["user"].toString()
            password = rootProject.properties["password"].toString()
        }
    }
    maven("url2")
    mavenLocal()
}
sschrass
  • 7,014
  • 6
  • 43
  • 62
0

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