I am working on Java/JNI project. Under parent, I have different modules for java and C codebase.Java module needs to generate JNI header file. Since, I couldn't find any existing task/plugin that supported javah, so I wrote my custom task for javah to generate JNI interface. So, when I do gradle javah
I am getting the desired output.
gradle build
, it should also execute javah task once either after classes are generated or build task ends. gradle build
? Currently, I have to do gradle <project-name>SharedLibrary
Part 1 : You can use finalizedBy
on task1
to execute task2
after task1
completes. For your case, you can try the following:
// 'javah' will be executed after 'classes' task executes.
classes.finalizedBy javah
// Make 'javah' task depend on 'classes' task,
// so that when 'classes' task fails, 'javah' is not executed.
javah.dependsOn classes
// Make 'build' depend on 'javah' task,
// so that executing 'build' task automatically executes 'javah'
build.dependsOn javah
Part 2 : You can use dependsOn
to wire up the <project-name>SharedLibrary
task as follows:
build.dependsOn "${project.name}SharedLibrary"
// Assuming the SharedLibrary task needs to depend on 'javah' task
tasks["${project.name}SharedLibrary"].dependsOn javah
I'm assuming that the the SharedLibarary task name is dynamic, hence using a slightly different syntax for that task.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.