diff --git a/lib/jar_install_post_install_hook.rb b/lib/jar_install_post_install_hook.rb index ef3a7a6..9910a26 100644 --- a/lib/jar_install_post_install_hook.rb +++ b/lib/jar_install_post_install_hook.rb @@ -18,4 +18,10 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -require 'jars/post_install_hook' + +if defined?(JRUBY_VERSION) && Gem.post_install_hooks.empty? + Gem.post_install do |gem_installer| + require "jars/post_install_hook" + Jars.post_install_hook(gem_installer) + end +end diff --git a/lib/jars/post_install_hook.rb b/lib/jars/post_install_hook.rb index 94f3c39..90c2a5c 100644 --- a/lib/jars/post_install_hook.rb +++ b/lib/jars/post_install_hook.rb @@ -19,13 +19,13 @@ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -if defined?(JRUBY_VERSION) && Gem.post_install_hooks.empty? - Gem.post_install do |gem_installer| - unless (ENV['JARS_SKIP'] || ENV_JAVA['jars.skip']) == 'true' - require 'jars/installer' - jars = Jars::Installer.new(gem_installer.spec) - jars.ruby_maven_install_options = gem_installer.options || {} - jars.vendor_jars - end +module Jars + def self.post_install_hook(gem_installer) + return if (ENV["JARS_SKIP"] || ENV_JAVA["jars.skip"]) == "true" + + require "jars/installer" + jars = Jars::Installer.new(gem_installer.spec) + jars.ruby_maven_install_options = gem_installer.options || {} + jars.vendor_jars end end diff --git a/lib/rubygems_plugin.rb b/lib/rubygems_plugin.rb index ef3a7a6..2c7645c 100644 --- a/lib/rubygems_plugin.rb +++ b/lib/rubygems_plugin.rb @@ -18,4 +18,5 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -require 'jars/post_install_hook' + +require "jar_install_post_install_hook"