Gradle.properties not found

I’m placing gradle.properties in the root directory of my project but gradle is unable to pick properties while running build.

You’ll need to show exactly what you’re doing, and exactly what results you’re getting, and what you think is wrong with it.

And questions like this should go in the “Help/Discuss” category.

I’m trying to put this property -
org.gradle.daemon=true

Gradle is doing its build but there is no daemon started as everytime I get this message after the build is done -

This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.10/userguide/gradle_daemon.html

Also there is no message that a deamon is started for any of my builds.

build.gradle and gradle.properties are in the same root directory of the project. Please let me know if there is something obvious I’m missing.

As the user guide points out, you should add this specific property to the «USER_HOME»/.gradle/gradle.properties file, not the one in your root project directory.

The specific section of the User Guide is 6.1
https://docs.gradle.org/current/userguide/gradle_daemon.html

1 Like

It also says you can add gradle.properties in the project directory parallel to build.gradle.

I think I see the confusion. You’re probably looking at Chapter 11: The Build Environment where it says that properties are generally read from various different places (including the gradle.properties) in the project directory.

However, nowhere in Chapter 6: The Gradle Daemon does it suggest that you should add org.gradle.daemon=true to the gradle.properties file in the project directory. Every time that chapter talks about setting the property in a gradle.properties file, it explicitly mentions that this is the user’s gradle.properties file.

1 Like

Not only this, other properties are also not being picked from the gradle.properties in the project directory.

Which properties? The gradle.properties in the project directory is only for user-defined properties. Things like sourceCompatibility and targetCompatibility are apparently ignored.

Yeah I agree but same was working for me until yesterday when it stopped picking properties. Properties like -

org.gradle.parallel=true
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

Did something change? It’s very strange that this would stop working just like that. If nothing has changed, I assume the problem is environmental. Are there any daemons that are sticking around from the day before? If you define a custom build property in gradle.properties, is that being picked up in the build?

Rohit,

Can you provide the following information?
Gradle Version:
Gradle Command Line:
Contents of ${project}/gradle.properties:
Contents of $USER/.gradle/gradle.properties:
Description of expected behavior:
Description of observed behavior:

This information will help us reproduce the problem and confirm whether or not there has been a regression in Gradle or if there is something you can change locally to get the behavior you desire.

Thanks,
Pepper

Hi Pepper

Everything is working fine once I put contents in $USER/.gradle/gradle.properties but its not working if same is kept parallel to build.gradle. Same was working for me a day before.

@pledbrook

There is no daemons sticking around. Custom build property is being picked up in the build.

If you will provide the requested data, we will be more informed as we attempt to determine what might have changed between today and the day before. Without specific details of your environment, we are only able to make uninformed guesses.

Gradle Version: 2.10
Gradle Command Line: gradle clean build
Contents of ${project}/gradle.properties:
org.gradle.parallel=true
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

Contents of $USER/.gradle/gradle.properties: Not defined
Description of expected behavior: Daemon should be created and build should run parallely.
Description of observed behavior: No daemon is created neither build is run parallely and jvmargs are not set as well.

@eljobe Any help on this ?

Sorry for the delay in responding. One more question. Which JVM are you using?

@eljobe I’m using java 8.

Rohit, I am having no luck in reproducing your error.

Is it possible for you to share the project structure or source-code of your project with me? I understand this might not be an open-source project and that would prohibit you from sharing it.

I have reproduced the situation you describe and the gradle.properties file in the project directory is being read and all off the properties (daemon, parallel, jvmargs, etc.) are all being read and have an effect when I run gradle clean build.

Is it possible that you have an alias or something set up with might be overriding gradle’s ability to find the project’s gradle.properties file. For example, the -p, --project-dir option might be overriding the project directory and that might be causing the properties file to not be read.

I’m afraid I’ve exhausted the ideas I have on why this might be occurring for you. Maybe if you can give me more details, something else will reveal itself. Have you tried checking out the project in a fresh directory to make sure you haven’t accidentally messed up file only in your local client?