I am new to gradle and groovy. Here is my task that generates JNI headers:
apply plugin: 'java' apply plugin: 'application' mainClassName = "com.my.example.HelloG" task GenerateJniHeaders(dependsOn: 'classes') << { def classpath = "build/classes/main" def nativeIncludes = "src/native/include" "javah -d ${nativeIncludes} -classpath ${classpath} ${mainClassName}".execute() } classes.finalizedBy GenerateJniHeaders build.dependsOn GenerateJniHeaders
It works fine, but I feel it is a little ugly. How can I improve it? I appreciate any suggestions, especially those that help me remove variables that are hard-coded by me. I would also like to make this task more universal - now it only generates a JNI header for the main class, but I want to run it for all java files. Moreover, when this task fails (for example, the path to the class is incorrect), it does not print error messages and does not create errors, which is misleading.
source share