jarbler 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +11 -9
- data/lib/jarbler/builder.rb +22 -4
- data/lib/jarbler/config.rb +19 -8
- data/lib/jarbler/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c6eb4bd62cd4f241608b950e6cc12818efba108f75c79650a6ddcfa558315f6
|
4
|
+
data.tar.gz: 13574e8c87bcb8d8a3a3ed2a6263046559982d8de8572aaaa31a24ff81717c62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e87be06e969d43ec0584c96708456404d54011362a681a7f99617f72c3a7108a8e203e7a26279e5106f0f535b75cde0a2f1e3df10874b354816d519893d37161
|
7
|
+
data.tar.gz: 2bffe72a8c78ba10605de7da93002f10eb08018ca17c88f932d1da49abefbfa6b68898f6d3ab22a338435dc57564118c1cf525272c45e277e099182952f0ceb9
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.2.2] - 2024-06-13
|
4
|
+
|
5
|
+
- Exclude certain dirs or files from compilation with 'excludes_from_compile' option in config file
|
6
|
+
|
7
|
+
## [0.2.1] - 2024-06-13
|
8
|
+
|
9
|
+
- Ruby files remain originally in jar if compile fails for a single file.
|
10
|
+
- Gems are compiled only if include_gems_to_compile=true
|
11
|
+
|
3
12
|
## [0.2.0] - 2024-06-12
|
4
13
|
|
5
14
|
- Add ahead of time compilation support for JRuby
|
data/README.md
CHANGED
@@ -53,15 +53,17 @@ To create a template config file with information about all the supported config
|
|
53
53
|
The default configuration is focused on Ruby on Rails applications.<br>
|
54
54
|
|
55
55
|
### Configuration options
|
56
|
-
| Option
|
57
|
-
|
58
|
-
| compile_ruby_files| false | Ahead of time compilation of all .rb files of application and Gem dependencies to .class files. Only store .class files in jar. Requires JRuby runtime. |
|
59
|
-
| executable
|
60
|
-
| executable_params
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
| Option | Default value | Description |
|
57
|
+
|-------------------------|--------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
|
58
|
+
| compile_ruby_files | false | Ahead of time compilation of all .rb files of application and Gem dependencies to .class files. Only store .class files in jar. Requires JRuby runtime. |
|
59
|
+
| executable | "bin/rails" | The ruby start file to run at execution of jar file. File extension .class is used automatically if start file is .rb and AOT compilation is used. |
|
60
|
+
| executable_params | ["server", "-e", "production", "-p", "8080"] | Command line parameters to be used for the ruby executable |
|
61
|
+
| excludes_from_compile | ["config"] | The files and dirs of the project to exclude from the compilation of .rb files |
|
62
|
+
| excludes | ["tmp/cache", "tmp/pids", ...] (see generated template file for whole content) | The files and dirs of the project to exclude from the include option |
|
63
|
+
| include_gems_to_compile | false | Should .rb files of the project gems also be compiled if compile_ruby_files = true |
|
64
|
+
| includes | ["app", "bin", "config", ...] (see generated template file for whole content) | The files and dirs of the project to include in the jar file |
|
65
|
+
| jar_name | < Name of project dir >.jar | The name of the generated jar file |
|
66
|
+
| jruby_version | The current most recent JRuby version | The version of the JRuby runtime to use |
|
65
67
|
|
66
68
|
|
67
69
|
## Troubleshooting
|
data/lib/jarbler/builder.rb
CHANGED
@@ -269,13 +269,31 @@ module Jarbler
|
|
269
269
|
puts "Compiling .rb files to .class is done with JRuby version #{JRUBY_VERSION}, but intended runtime JRuby version for jar file is #{config.jruby_version}"
|
270
270
|
end
|
271
271
|
|
272
|
-
ruby_files = Find.find('.').select { |f| f =~ /\.rb$/ }
|
272
|
+
ruby_files = Find.find('.').select { |f| f =~ /\.rb$/ } # find all Ruby files in the current directory
|
273
|
+
|
274
|
+
if !config.include_gems_to_compile
|
275
|
+
ruby_files = ruby_files.select { |f| !(f =~ /\.#{File::SEPARATOR}gems#{File::SEPARATOR}/) } # Exclude ./gems/* directories from compiling
|
276
|
+
end
|
277
|
+
|
278
|
+
# Exclude named files or directories from compiling
|
279
|
+
config.excludes_from_compile.each do |exclude|
|
280
|
+
ruby_files = ruby_files.select { |f| !(f =~ /\.#{File::SEPARATOR}app_root#{File::SEPARATOR}#{exclude}/) }
|
281
|
+
end
|
282
|
+
|
273
283
|
ruby_files.each do |ruby_file|
|
274
284
|
debug "Compile Ruby file #{ruby_file}"
|
275
285
|
full_file_name = File.join(Dir.pwd, ruby_file) # full name including path is required by the JRuby compiler
|
276
|
-
|
277
|
-
|
278
|
-
|
286
|
+
begin
|
287
|
+
status = JRuby::Compiler::compile_argv([full_file_name]) # compile the Ruby file
|
288
|
+
if status == 0
|
289
|
+
File.delete(full_file_name) # remove the original Ruby file to ensure that the compiled class file is used
|
290
|
+
else
|
291
|
+
raise "Return status != 0"
|
292
|
+
end
|
293
|
+
rescue Exception => e
|
294
|
+
puts "Error compiling Ruby file '#{ruby_file}': #{e.class}:#{e.message}"
|
295
|
+
puts "'#{ruby_file}' is not compiled and will be included in the jar file as original Ruby file"
|
296
|
+
end
|
279
297
|
end
|
280
298
|
end
|
281
299
|
end
|
data/lib/jarbler/config.rb
CHANGED
@@ -3,7 +3,7 @@ require 'json'
|
|
3
3
|
|
4
4
|
module Jarbler
|
5
5
|
class Config
|
6
|
-
attr_accessor :jar_name, :includes, :excludes, :jruby_version, :executable, :executable_params, :compile_ruby_files
|
6
|
+
attr_accessor :jar_name, :includes, :excludes, :jruby_version, :executable, :executable_params, :compile_ruby_files, :include_gems_to_compile, :excludes_from_compile
|
7
7
|
|
8
8
|
CONFIG_FILE = 'config/jarble.rb'
|
9
9
|
# create instance of Config class with defaults or from config file
|
@@ -28,12 +28,14 @@ module Jarbler
|
|
28
28
|
|
29
29
|
def initialize
|
30
30
|
@compile_ruby_files = false
|
31
|
-
@jar_name = File.basename(Dir.pwd) + '.jar'
|
32
|
-
@includes = %w(app bin config config.ru db Gemfile Gemfile.lock lib log public Rakefile script vendor tmp)
|
33
31
|
@excludes = %w(tmp/cache tmp/pids tmp/sockets vendor/bundle vendor/cache vendor/ruby)
|
34
|
-
@
|
32
|
+
@excludes_from_compile = %w(config)
|
35
33
|
@executable = 'bin/rails'
|
36
34
|
@executable_params = %w(server -e production -p 8080)
|
35
|
+
@include_gems_to_compile = false
|
36
|
+
@includes = %w(app bin config config.ru db Gemfile Gemfile.lock lib log public Rakefile script vendor tmp)
|
37
|
+
@jar_name = File.basename(Dir.pwd) + '.jar'
|
38
|
+
@jruby_version = nil # determined automatically at runtime
|
37
39
|
# execute additional block if given
|
38
40
|
yield self if block_given?
|
39
41
|
end
|
@@ -41,10 +43,6 @@ module Jarbler
|
|
41
43
|
# Generate the template config file based on default values
|
42
44
|
def create_config_file
|
43
45
|
write_config_file("\
|
44
|
-
# Compile the ruby files of the project to Java .class files with JRuby's ahead-of-time compiler
|
45
|
-
# the original ruby files are not included in the jar file, so source code is not visible
|
46
|
-
# config.compile_ruby_files = #{compile_ruby_files}
|
47
|
-
|
48
46
|
# Name of the generated jar file
|
49
47
|
# config.jar_name = '#{jar_name}'
|
50
48
|
|
@@ -67,6 +65,17 @@ module Jarbler
|
|
67
65
|
|
68
66
|
# Additional command line parameters for the Ruby executable
|
69
67
|
# config.executable_params = #{executable_params}
|
68
|
+
|
69
|
+
# Compile the ruby files of the project to Java .class files with JRuby's ahead-of-time compiler?
|
70
|
+
# the original ruby files are not included in the jar file, so source code is not visible
|
71
|
+
# config.compile_ruby_files = #{compile_ruby_files}
|
72
|
+
|
73
|
+
# Compile also the .rb files of the gems of the project to Java .class files?
|
74
|
+
# config.include_gems_to_compile = #{include_gems_to_compile}
|
75
|
+
|
76
|
+
# Directories or files to exclude from the compilation if compile_ruby_files = true
|
77
|
+
# config.excludes_from_compile = #{excludes_from_compile}
|
78
|
+
|
70
79
|
".split("\n"))
|
71
80
|
end
|
72
81
|
|
@@ -131,6 +140,8 @@ module Jarbler
|
|
131
140
|
raise "Invalid config value for excludes: #{excludes}" unless excludes.is_a?(Array)
|
132
141
|
raise "Invalid config value for compile_ruby_files: #{compile_ruby_files}" unless [true, false].include?(compile_ruby_files)
|
133
142
|
raise "compile_ruby_files = true is supported only with JRuby! Current runtime is '#{RUBY_ENGINE}'" if compile_ruby_files && (defined?(RUBY_ENGINE) && RUBY_ENGINE != 'jruby')
|
143
|
+
raise "include_gems_to_compile = true is supported only if compile_ruby_files = true!" if include_gems_to_compile && !compile_ruby_files
|
144
|
+
raise "Invalid config value for excludes_from_compile: #{excludes_from_compile}" unless excludes_from_compile.is_a?(Array)
|
134
145
|
end
|
135
146
|
end
|
136
147
|
end
|
data/lib/jarbler/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jarbler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ramm
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Pack a Ruby app combined with JRuby runtime and all its Gem dependencies
|
14
14
|
into a jar file to simply run the app on any Java platform by '> java -jar file.jar'
|