jarbler 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +10 -9
- data/lib/jarbler/builder.rb +17 -4
- data/lib/jarbler/config.rb +14 -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: 97f5261d55e15e23454414413af5f467bfdf5c2554916574269d6fa99f4a411a
|
|
4
|
+
data.tar.gz: 5a77de393585a7fa444157ebc2e7835d6d39e2e0e004ade0f840d9f2f9abcff9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ad30f274db2a26f844df82f295b95f9bdcd9a023f35bbc83a6d2b7ec44b77a4dd0b8ca5ca66bb3f46818acf927d2e72efefb0f8b2669b058f5f51b9dacdb6d49
|
|
7
|
+
data.tar.gz: e07c531aa6082b3d186d2d3687d6a784b9b07593f4145e4d51bdd28247f57c710a35ed15196c18a0d3cb5a9f503808b242833709780b71442e0f293de1fe0db4
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.2.1] - 2024-06-13
|
|
4
|
+
|
|
5
|
+
- Ruby files remain originally in jar if compile fails for a single file.
|
|
6
|
+
- Gems are compiled only if include_gems_to_compile=true
|
|
7
|
+
|
|
3
8
|
## [0.2.0] - 2024-06-12
|
|
4
9
|
|
|
5
10
|
- Add ahead of time compilation support for JRuby
|
data/README.md
CHANGED
|
@@ -53,15 +53,16 @@ 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
|
-
| excludes
|
|
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 | ["tmp/cache", "tmp/pids", ...] (see generated template file for whole content) | The files and dirs of the project to exlude from the include option |
|
|
62
|
+
| include_gems_to_compile | false | Should .rb files of the project gems also be compiled if compile_ruby_files = true |
|
|
63
|
+
| includes | ["app", "bin", "config", ...] (see generated template file for whole content) | The files and dirs of the project to include in the jar file |
|
|
64
|
+
| jar_name | < Name of project dir >.jar | The name of the generated jar file |
|
|
65
|
+
| jruby_version | The current most recent JRuby version | The version of the JRuby runtime to use |
|
|
65
66
|
|
|
66
67
|
|
|
67
68
|
## Troubleshooting
|
data/lib/jarbler/builder.rb
CHANGED
|
@@ -269,13 +269,26 @@ 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
|
+
|
|
273
278
|
ruby_files.each do |ruby_file|
|
|
274
279
|
debug "Compile Ruby file #{ruby_file}"
|
|
275
280
|
full_file_name = File.join(Dir.pwd, ruby_file) # full name including path is required by the JRuby compiler
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
281
|
+
begin
|
|
282
|
+
status = JRuby::Compiler::compile_argv([full_file_name]) # compile the Ruby file
|
|
283
|
+
if status == 0
|
|
284
|
+
File.delete(full_file_name) # remove the original Ruby file to ensure that the compiled class file is used
|
|
285
|
+
else
|
|
286
|
+
raise "Return status != 0"
|
|
287
|
+
end
|
|
288
|
+
rescue Exception => e
|
|
289
|
+
puts "Error compiling Ruby file '#{ruby_file}': #{e.class}:#{e.message}"
|
|
290
|
+
puts "'#{ruby_file}' is not compiled and will be included in the jar file as original Ruby file"
|
|
291
|
+
end
|
|
279
292
|
end
|
|
280
293
|
end
|
|
281
294
|
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
|
|
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,13 @@ 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
|
-
@jruby_version = nil # determined automatically at runtime
|
|
35
32
|
@executable = 'bin/rails'
|
|
36
33
|
@executable_params = %w(server -e production -p 8080)
|
|
34
|
+
@include_gems_to_compile = false
|
|
35
|
+
@includes = %w(app bin config config.ru db Gemfile Gemfile.lock lib log public Rakefile script vendor tmp)
|
|
36
|
+
@jar_name = File.basename(Dir.pwd) + '.jar'
|
|
37
|
+
@jruby_version = nil # determined automatically at runtime
|
|
37
38
|
# execute additional block if given
|
|
38
39
|
yield self if block_given?
|
|
39
40
|
end
|
|
@@ -41,10 +42,6 @@ module Jarbler
|
|
|
41
42
|
# Generate the template config file based on default values
|
|
42
43
|
def create_config_file
|
|
43
44
|
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
45
|
# Name of the generated jar file
|
|
49
46
|
# config.jar_name = '#{jar_name}'
|
|
50
47
|
|
|
@@ -67,6 +64,14 @@ module Jarbler
|
|
|
67
64
|
|
|
68
65
|
# Additional command line parameters for the Ruby executable
|
|
69
66
|
# config.executable_params = #{executable_params}
|
|
67
|
+
|
|
68
|
+
# Compile the ruby files of the project to Java .class files with JRuby's ahead-of-time compiler?
|
|
69
|
+
# the original ruby files are not included in the jar file, so source code is not visible
|
|
70
|
+
# config.compile_ruby_files = #{compile_ruby_files}
|
|
71
|
+
|
|
72
|
+
# Compile also the .rb files of the gems of the project to Java .class files?
|
|
73
|
+
# config.include_gems_to_compile = #{include_gems_to_compile}
|
|
74
|
+
|
|
70
75
|
".split("\n"))
|
|
71
76
|
end
|
|
72
77
|
|
|
@@ -131,6 +136,7 @@ module Jarbler
|
|
|
131
136
|
raise "Invalid config value for excludes: #{excludes}" unless excludes.is_a?(Array)
|
|
132
137
|
raise "Invalid config value for compile_ruby_files: #{compile_ruby_files}" unless [true, false].include?(compile_ruby_files)
|
|
133
138
|
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')
|
|
139
|
+
raise "include_gems_to_compile = true is supported only if compile_ruby_files = true!" if include_gems_to_compile && !compile_ruby_files
|
|
134
140
|
end
|
|
135
141
|
end
|
|
136
142
|
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.1
|
|
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'
|