Class: Warbler::Traits::JBundler

Inherits:
Object
  • Object
show all
Includes:
PathmapHelper, Warbler::Trait
Defined in:
lib/warbler/traits/jbundler.rb

Overview

The JBundler trait uses JBundler to determine jar dependencies to be added to the project.

Instance Attribute Summary

Attributes included from Warbler::Trait

#config

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PathmapHelper

#apply_pathmaps

Methods included from Warbler::Trait

#add_init_load_path, #add_main_rb, included, #initialize, #jruby_jars, #update_archive, #update_gem_path

Class Method Details

.detect?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/warbler/traits/jbundler.rb', line 16

def self.detect?
  File.exist?(ENV['JBUNDLE_JARFILE'] || "Jarfile")
end

.requirementsObject



20
21
22
# File 'lib/warbler/traits/jbundler.rb', line 20

def self.requirements
  [ Traits::War, Traits::Jar ]
end

Instance Method Details

#add_jbundler_jarsObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/warbler/traits/jbundler.rb', line 32

def add_jbundler_jars
  require 'jbundler/config'
  classpath = ::JBundler::Config.new.classpath_file
  if File.exists?( classpath )
    require File.expand_path( classpath )
  else
    raise 'jbundler support needs jruby to create a local config: jruby -S jbundle install'
  end
  # use only the jars from jbundler and jruby
  config.java_libs += jruby_jars
  config.java_libs += JBUNDLER_CLASSPATH
  config.java_libs.uniq! {|lib| lib.split(File::SEPARATOR).last }
  config.init_contents << "#{config.warbler_templates}/jbundler.erb"
end

#after_configureObject



28
29
30
# File 'lib/warbler/traits/jbundler.rb', line 28

def after_configure
  add_jbundler_jars if config.jbundler
end

#before_configureObject



24
25
26
# File 'lib/warbler/traits/jbundler.rb', line 24

def before_configure
  config.jbundler = true
end