Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify what "Gradle installation directory" means for gradlew #26088

Closed
joffrey-bion opened this issue Aug 11, 2023 · 8 comments · Fixed by #26590
Closed

Clarify what "Gradle installation directory" means for gradlew #26088

joffrey-bion opened this issue Aug 11, 2023 · 8 comments · Fixed by #26590
Assignees
Labels
a:documentation Documentation content in:build-environment Gradle, project, system and environment properties, CLI flags
Milestone

Comments

@joffrey-bion
Copy link

Issue type

Missing information

Problem description

In the list for the order of precedence of Gradle properties, the last location is specified as the Gradle installation directory.

What does it mean when using the Gradle wrapper mechanism in a project? Is there such a location at all in that case? It would be nice for this information to be present in the doc, as I couldn't find it so far.

Context (optional)

No response

Page with the problem

https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties

@joffrey-bion joffrey-bion added a:documentation Documentation content to-triage labels Aug 11, 2023
@jbartok
Copy link
Member

jbartok commented Aug 14, 2023

Thank you for your interest in Gradle!

This is a valid documentation issue that we will address.

@jbartok jbartok added in:build-environment Gradle, project, system and environment properties, CLI flags and removed to-triage labels Aug 14, 2023
@joffrey-bion
Copy link
Author

joffrey-bion commented Aug 14, 2023

By the way, as a derived question, how can I specify a default value for the whole machine for a given property (say, org.gradle.java.installations.fromEnv) for all projects (even those using the Gradle wrapper), and that is still overridable on per-project basis? (I cannot use the user home's gradle.properties because it must not have precedence over the project's decision in the project's gradle.properties).

This would be a typical use case for CI runners that provide multiple JDK installations, looping back to:
#14903 (comment)

@lkasso lkasso linked a pull request Sep 29, 2023 that will close this issue
@lkasso lkasso self-assigned this Sep 29, 2023
bot-gradle added a commit that referenced this issue Oct 2, 2023
### Context
Handles Github issues and a few internal issues in sections that have been recently updated in the Gradle User Manual.

This is a documentation change ONLY.

### Fixes:
- Continuous build description - #26252
- Document GRADLE_LIBS_REPO_OVERRIDE - #24217
- Deprecated alternative to `setOutputFile` - #25586
- Fix build order preference - #26088
- How to use system file watch with symlinks - #26201
- Update *Centralizing repositories declaration* section of [Dependency Management](https://docs.gradle.org/current/userguide/dependency_management.html) for @erichaagdev
- Update admonition block CSS for @alllex
- Fix javadocs CSS for search background color for @lkasso

### Reviewers:
Under development.

Co-authored-by: Laura Kassovic <lkassovic@gradle.com>
@ov7a ov7a removed the to-triage label Oct 10, 2023
@ov7a ov7a added this to the 8.5 RC1 milestone Oct 10, 2023
@asteiner-psh
Copy link

Looking at the PR that closed this ticket, I do not see any changes that addresses the reported issue (Clarify what "Gradle installation directory" means for gradlew)

Also, in the PR, this issue is mentioned with an incorrect label: "Fix build order preference - #26088"

Is it possible this issue was incorrectly referenced in that PR?

@lkasso
Copy link
Member

lkasso commented Oct 19, 2023

Hey @asteiner-psh, the changes aren't public yet.

I updated the two files with this question in mind (note this is still not released on https://docs.gradle.org/current):

Gradle and the Gradle wrapper use the same order preference.

Is there something I did not answer for you and @joffrey-bion? Please let me know so I can make further updates.

@joffrey-bion
Copy link
Author

joffrey-bion commented Oct 20, 2023

From the new formulation, it seems that we don't actually need a Gradle installation in the directory that GRADLE_HOME points to. Is this true?

If I create a /gradle_defaults/gradle.properties file with some properties, and set GRADLE_HOME=/gradle_defaults (where /gradle_defaults does not contain a gradle installation), will it be used in prio order 3.2 by projects using the wrapper?

If yes, this mean I could use it to define default properties that can be overriden on a per-project basis.

@lkasso
Copy link
Member

lkasso commented Nov 1, 2023

@joffrey-bion, Gradle will automatically store all downloaded versions of Gradle in GRADLE_USER_HOME. That way, as you switch Gradle versions in your projects, you don't have to download a fresh copy.

This is not to be confused with GRADLE_HOME.

The GRADLE_HOME is entirely optionally and very rarely used. It cannot be used with Gradle Wrapper.
When GRADLE_HOME is used, it is to specify a local Gradle version.

this mean I could use it to define default properties that can be overriden on a per-project basis.

What you want to do is put your gradle.properties file in GRADLE_USER_HOME, not GRADLE_HOME.

@asteiner-psh, Gradle and the Wrapper don't use GRADLE_HOME.

@joffrey-bion
Copy link
Author

joffrey-bion commented Nov 1, 2023

this mean I could use it to define default properties that can be overriden on a per-project basis

What you want to do is put your gradle.properties file in GRADLE_USER_HOME, not GRADLE_HOME.

No, GRADLE_USER_HOME doesn't work for me, because properties defined there would override properties from the project's gradle.properties. I want the opposite: I want to specify some default properties for my machine, but still let the project's gradle.properties override them as needed.

The only place to do that in the list is the GRADLE_HOME, not the GRADLE_USER_HOME.

Gradle and the Wrapper don't use GRADLE_HOME.

What do you mean? Then why is this part of the list of places where gradle.properties are searched?

You said Gradle and the Gradle wrapper use the same order preference. If this is true, then the Gradle Wrapper should also look at GRADLE_HOME. If this is not the case, it needs to be made very clear in the table IMO.

@joffrey-bion
Copy link
Author

Also, I think it would be rather important not to conflate the types of properties and the mechanisms to set them. It is irrelevant to consider the precedence between 2 different properties. We should see 3 independent tables of priorities: one for system properties, one for gradle properties, one for project properties. And in each table, list all mechanisms to set such properties (which will be similar but not the same).

I expanded much more in the Precedence section in this issue: #26107

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:documentation Documentation content in:build-environment Gradle, project, system and environment properties, CLI flags
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants