Class: Warbler::Traits::Jar
- Inherits:
-
Object
- Object
- Warbler::Traits::Jar
show all
- Includes:
- Warbler::Trait
- Defined in:
- lib/warbler/traits/jar.rb
Overview
The Jar trait sets up the archive layout for an executable jar
project, and adds the JRuby jar files and a JarMain class to the
archive.
Instance Attribute Summary
#config
Class Method Summary
collapse
Instance Method Summary
collapse
#add_init_load_path, #add_main_rb, included, #initialize, #jruby_jars, #update_gem_path
Class Method Details
.conflicts ⇒ Object
23
24
25
|
# File 'lib/warbler/traits/jar.rb', line 23
def self.conflicts
[ Traits::War ]
end
|
.detect? ⇒ Boolean
19
20
21
|
# File 'lib/warbler/traits/jar.rb', line 19
def self.detect?
!detect_any_conflicts?
end
|
Instance Method Details
35
36
37
|
# File 'lib/warbler/traits/jar.rb', line 35
def after_configure
config.init_contents << StringIO.new("require 'rubygems' unless defined?(Gem)\n")
end
|
27
28
29
30
31
32
33
|
# File 'lib/warbler/traits/jar.rb', line 27
def before_configure
config.gem_path = '/'
config.pathmaps = default_pathmaps
config.java_libs = default_jar_files
config.manifest_file = 'MANIFEST.MF' if File.exist?('MANIFEST.MF')
config.init_contents << "#{config.warbler_templates}/jar.erb"
end
|
#default_jar_files ⇒ Object
57
58
59
|
# File 'lib/warbler/traits/jar.rb', line 57
def default_jar_files
jruby_jars
end
|
#default_pathmaps ⇒ Object
47
48
49
50
51
52
53
54
55
|
# File 'lib/warbler/traits/jar.rb', line 47
def default_pathmaps
p = OpenStruct.new
p.java_libs = ["META-INF/lib/%f"]
p.java_classes = ["%p"]
p.application = ["#{config.jar_name}/%p"]
p.gemspecs = ["specifications/%f"]
p.gems = ["gems/%p"]
p
end
|
#update_archive(jar) ⇒ Object
39
40
41
42
43
44
45
|
# File 'lib/warbler/traits/jar.rb', line 39
def update_archive(jar)
unless config.manifest_file
manifest = Warbler::Jar::DEFAULT_MANIFEST.chomp + "Main-Class: JarMain\n"
jar.files['META-INF/MANIFEST.MF'] = StringIO.new(manifest)
end
jar.files['JarMain.class'] = jar.entry_in_jar(WARBLER_JAR, "JarMain.class")
end
|