How can the version number be incremented automatically with Perforce?

I am new to Gradle. We use Perforce as our source control system at work. When I execute a “release” target I would like the “version” property to use the value of a Perforce counter. How can I do this? I assume I need to somehow fork the ‘p4 counters’ call and parse the output. I am pretty sure this would be a pain in the butt in Java, is there an easy way in Gradle / Grovvy?

Thanks, Chris

You can use Gradle’s Exec task or method, redirect standard out with ‘exec.setStandardOut()’ to a ‘’, construct a ‘String’ from that, and parse it. In other words, it’s not very different from how you would do it in plain Java.