Unfortunately, when I execute gradle clean compileJava no nativeLibs folder is created and it seems that nothing is unzipped. However, the path that is displayed for “FILE=” exists:
The statement is printed because that occurs at configuration time, as in the task is configured for execution and sets up its inputs and outputs. You need to add a task dependency, e.g. compileJava.dependsOn(extractApi) so that your task is executed as part of the build step.
Just set up the desired task dependency. The new task will only make sense in certain conditions, which only you know.
You have to add it to the classpath of tasks where appropriate. For example, I made a similar task to run jsr107’s tests by extracting the test jar and setting the test task’s testClassesDir.
I extract within the project’s buildDir, which a clean annihilates.
Thank you again for these information. One last question, is it possible to force gradle to execute my extractApi task when dependencies are resolved (if possible, dependencies defined with nativeBundle configuration)?
Not that I know of. I think your best bet is to understand what the task graph looks like for your build and ensure that the extractApi task relationship is setup. You could probably use cross-cutting logic like filtering and applying the relationship to allprojects.tasks but that’s overkill.