Is it ok to run gtest only when testing Java?
You could then do linkDebug and get *.so file without running gtests. Is this the intention?
For CI I think this does make any difference - the gtests will run a bit later. For local dev, you can use -Pskip-gtest gradle paramater.
The rest of the changes looks good.