How to create a JNI task in gradle?

There is a java library which depends on some c++ libraries using JNI, So when compiling the c++ libraries header files need to be created using javah

In ant we can do the following and it works. Wanted to find a “gradle’ish” way to do the same.

<target name="jni" depends="compile">

found something similar here: but it says “hack” and is couple of years old so, want to check if there is a cleaner way to do it.

Gradle doesn’t currently ship with a ‘Javah’ task type. In such a case, using an existing Ant task (of course from a Gradle build script) is a good option, and hence it’s the first thing I’d try. If you wanted to take this to the next level, you could write a Gradle task class that calls the Ant task internally.