Fix gem reinstallations (bad path) and support gems with java extensions (e.g. thread_safe)

This was tested manually with another project, I'm not unfortunately not
certain how to write good Groovy tests for this

Fixes #61