# Gradle -version invoke through script not as CLI command as it may take another process creation overhead and not debuggable

**URL:** <https://discuss.gradle.org/t/gradle-version-invoke-through-script-not-as-cli-command-as-it-may-take-another-process-creation-overhead-and-not-debuggable/51353>\
**Category:** Help/Discuss\
**Created:** [July 19, 2025, 4:33am UTC](https://discuss.gradle.org/t/gradle-version-invoke-through-script-not-as-cli-command-as-it-may-take-another-process-creation-overhead-and-not-debuggable/51353 "2025-07-19T04:33:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raja\_Nagendra\_Kumar1](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/raja_nagendra_kumar1/32/10491_2.png) [@Raja\_Nagendra\_Kumar1](https://discuss.gradle.org/u/Raja_Nagendra_Kumar1)\
**Post date:** [July 19, 2025, 4:33am UTC](https://discuss.gradle.org/t/gradle-version-invoke-through-script-not-as-cli-command-as-it-may-take-another-process-creation-overhead-and-not-debuggable/51353/1 "2025-07-19T04:33:11Z")

</div>

Is it possible to invoke gradle -version from gradle script without overhead of another process, i.e. is there any relavant task to say dependsOn and invoke version info etc.. or just call `versionTask` etc

I don’t want to explicity define one function for version myself. why not reuse or extend what is already provided?

---

<div class="post-metadata">

**Author:** ![Raja\_Nagendra\_Kumar1](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/raja_nagendra_kumar1/32/10491_2.png) [@Raja\_Nagendra\_Kumar1](https://discuss.gradle.org/u/Raja_Nagendra_Kumar1)\
**Post date:** [July 20, 2025, 9:06am UTC](https://discuss.gradle.org/t/gradle-version-invoke-through-script-not-as-cli-command-as-it-may-take-another-process-creation-overhead-and-not-debuggable/51353/2 "2025-07-20T09:06:12Z")

</div>

Lack of any inputs, I am settling with this script.. for future reference to remove once I find one

```gradle
tasks.withType<Test>().configureEach {
    afterSuite(
	KotlinClosure2<TestDescriptor, TestResult, Unit>({ desc, result ->
							     if (desc.parent == null)
							     {
								 println("\n🔧 Java (used by Gradle): ${
								     System.getProperty("java.runtime.version")
								 }")
								 println("🧠 Java VM: ${
								     System.getProperty("java.vm.name")
								 } (${System.getProperty("java.vm.version")})")
								 println(
								     "🛠 Gradle Version: ${gradle.gradleVersion}\n\n")

								 println("🔍 Test Summary:")
								 println(" - ${result.testCount} tests executed")
								 println(
								     " - ${result.successfulTestCount} succeeded")
								 println(" - ${result.failedTestCount} failed")
								 println(" - ${result.skippedTestCount} skipped")
								 println(
								     "\nTest Report: file:///" + reports.html.entryPoint.absolutePath.replace(
									 File.separatorChar, '/'))
							     }
							 }))
}

```

Look at the name closure name - ‘KotlinClosure2’ - No way, I could have known such a script without LLMs..
