# Any way to print currently used arguments/properties?

**URL:** <https://discuss.gradle.org/t/any-way-to-print-currently-used-arguments-properties/45623>\
**Category:** Help/Discuss\
**Created:** [May 18, 2023, 12:58pm UTC](https://discuss.gradle.org/t/any-way-to-print-currently-used-arguments-properties/45623 "2023-05-18T12:58:47Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![G00fY2](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/g00fy2/32/7584_2.png) [@G00fY2](https://discuss.gradle.org/u/G00fY2)\
**Post date:** [May 18, 2023, 12:58pm UTC](https://discuss.gradle.org/t/any-way-to-print-currently-used-arguments-properties/45623/1 "2023-05-18T12:58:47Z")

</div>

I would like to print a short kind of debugging log on CI when Gradle wrapper gets executed, to see which properties or arguments are used. Is there a way to do so?

Currently it is sometimes hard to track e.g. what org.gradle.jvmargs are used, when working with project gradle.properties, local gradle.properties and GRADLE\_OPTS.

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [May 18, 2023, 2:18pm UTC](https://discuss.gradle.org/t/any-way-to-print-currently-used-arguments-properties/45623/2 "2023-05-18T14:18:03Z")

</div>

You could have some init script that prints the debug log you want and use that when running builds on CI, e.g. by placing it to `<GRADLE_USER_HOME>/init.d/...` on the build agent where it will be automatically picked from for all builds.

---

<div class="post-metadata">

**Author:** ![G00fY2](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/g00fy2/32/7584_2.png) [@G00fY2](https://discuss.gradle.org/u/G00fY2)\
**Post date:** [May 18, 2023, 3:44pm UTC](https://discuss.gradle.org/t/any-way-to-print-currently-used-arguments-properties/45623/3 "2023-05-18T15:44:07Z")

</div>

Thanks for this direction. Is there an API to access e.g. the currently set jvmargs?

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [May 18, 2023, 5:05pm UTC](https://discuss.gradle.org/t/any-way-to-print-currently-used-arguments-properties/45623/4 "2023-05-18T17:05:46Z")

</div>

`project.findProperty("org.gradle.jvmargs")`?  
Or similar on `settings` or maybe `gradle`.

---

<div class="post-metadata">

**Author:** ![G00fY2](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/g00fy2/32/7584_2.png) [@G00fY2](https://discuss.gradle.org/u/G00fY2)\
**Post date:** [May 18, 2023, 5:23pm UTC](https://discuss.gradle.org/t/any-way-to-print-currently-used-arguments-properties/45623/5 "2023-05-18T17:23:45Z")

</div>

Thanks! I was able to achieve it by adding

```gradle
settingsEvaluated {
    println(providers.gradleProperty("org.gradle.jvmargs").get())
}

```

to my init.gradle.kts.

Seems to work fine.

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [May 18, 2023, 5:25pm UTC](https://discuss.gradle.org/t/any-way-to-print-currently-used-arguments-properties/45623/6 "2023-05-18T17:25:49Z")

</div>

Be careful.  
This only works if you give it as project property.  
It does not work if you give it as Gradle property.  
Even though the method is called `gradleProperty` it only gives you project properites and in your case you probably set it in some `gradle.properties` file which makes it a Gradle and project property at the same time which is why you get it.

---

<div class="post-metadata">

**Author:** ![G00fY2](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/g00fy2/32/7584_2.png) [@G00fY2](https://discuss.gradle.org/u/G00fY2)\
**Post date:** [May 18, 2023, 5:38pm UTC](https://discuss.gradle.org/t/any-way-to-print-currently-used-arguments-properties/45623/7 "2023-05-18T17:38:42Z")

</div>

Hmm, good hint. Maybe then this solution is somewhat error-prone.

In the end I would like to have a reliable output to see the actual setting for max heap size and max metaspace size the Gradle deamon will use/is using.

Was hoping for some Gradle API I can call somewhere.

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [May 18, 2023, 6:35pm UTC](https://discuss.gradle.org/t/any-way-to-print-currently-used-arguments-properties/45623/8 "2023-05-18T18:35:25Z")

</div>

I thought the solution I initially gave would work, but it indeed also does not work.  
Opposed to the provider methods it also looks at extra properties, but still not at Gradle properties.  
Both would also give you a value set via `-P` that is not considered for the daemon at all.

So better just use normal Java API, like `Runtime.getRuntime().maxMemory()` for max heap.

No idea how to get the max metaspace, but there is for sure also some API.

---

<div class="post-metadata">

**Author:** ![G00fY2](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/g00fy2/32/7584_2.png) [@G00fY2](https://discuss.gradle.org/u/G00fY2)\
**Post date:** [May 18, 2023, 6:41pm UTC](https://discuss.gradle.org/t/any-way-to-print-currently-used-arguments-properties/45623/9 "2023-05-18T18:41:29Z")

</div>

Thanks for your feedback.

I now ended up using these log messages in my root project: [net.twisterrob.gradle/runtime.init.gradle.kts at 51a2ace2991721b410bc8498a02dbce2b8208364 · TWiStErRob/net.twisterrob.gradle · GitHub](https://github.com/TWiStErRob/net.twisterrob.gradle/blob/51a2ace2991721b410bc8498a02dbce2b8208364/test/src/main/resources/net/twisterrob/gradle/test/runtime.init.gradle.kts#L32)

This covers basically all the infos I care about.
