jarbler 0.2.3 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +11 -12
- data/lib/jarbler/builder.rb +1 -5
- data/lib/jarbler/config.rb +45 -33
- 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: ae7132c21c27b0d51a870c3e79470d83a4d4b6b088c474c8cdaf4cf4ed34a79c
|
4
|
+
data.tar.gz: 8e149011da1e3957f425f659a7ac35b47e1696b3896f1a617c6027d027a783bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0712390a6916ee50d063c3f9dcc92fc6389c3ca566bc0b089d5df0275e3044b0aee30d3dedbcaf8171642e8555958137ef8a1ab8d14123417af8bc4475fee44
|
7
|
+
data.tar.gz: b85408f04e6c496827c8fc78d34a78790e173721c6c10e9899e07a29c818d4986296bdfadf5cc79e1ff1de49ff5679d1982cfdc370c3bacca15786c62b7b9e85
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.3.1] - 2024-07-02
|
4
|
+
|
5
|
+
- Use file .ruby-version to define the JRuby version for the jar file only if .ruby-version contains a valid jRuby version
|
6
|
+
|
7
|
+
|
8
|
+
## [0.3.0] - 2024-06-18
|
9
|
+
|
10
|
+
- excludes_from_compile specifies paths as the location in the jar file
|
11
|
+
- Desupport of configuration attribute include_gems_to_compile
|
12
|
+
|
3
13
|
## [0.2.3] - 2024-06-13
|
4
14
|
|
5
15
|
- Show used configuration values in log output
|
data/README.md
CHANGED
@@ -53,21 +53,20 @@ 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 | Default value
|
57
|
-
|
58
|
-
| compile_ruby_files | false
|
59
|
-
| executable | "bin/rails"
|
60
|
-
| executable_params | ["server", "-e", "production", "-p", "8080"]
|
61
|
-
| excludes_from_compile | [
|
62
|
-
| excludes | ["tmp/cache", "tmp/pids", ...] (see generated template file for whole content)
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
| jruby_version | The current most recent JRuby version | The version of the JRuby runtime to use |
|
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 | [] | The files and dirs of the project to exclude from the compilation of .rb files. Paths specifies the location in the jar file (e.g. ["app_root/file.rb"] ) |
|
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
|
+
| 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 | A valid JRuby version from file '.ruby-version' or the current most recent version of the Gem 'jruby-jars' | The version of the JRuby runtime to use |
|
67
66
|
|
68
67
|
|
69
68
|
## Troubleshooting
|
70
|
-
* Set DEBUG=true in environment to get additional runtime information
|
69
|
+
* Set DEBUG=true in OS environment to get additional runtime information
|
71
70
|
* The temporary folder with the extracted app and JRuby runtime files is not deleted after execution if DEBUG is set.
|
72
71
|
|
73
72
|
### Possible error messages
|
data/lib/jarbler/builder.rb
CHANGED
@@ -271,13 +271,9 @@ module Jarbler
|
|
271
271
|
|
272
272
|
ruby_files = Find.find('.').select { |f| f =~ /\.rb$/ } # find all Ruby files in the current directory
|
273
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
274
|
# Exclude named files or directories from compiling
|
279
275
|
config.excludes_from_compile.each do |exclude|
|
280
|
-
ruby_files = ruby_files.select { |f| !(f =~ /\.#{File::SEPARATOR}
|
276
|
+
ruby_files = ruby_files.select { |f| !(f =~ /\.#{File::SEPARATOR}#{exclude}/) }
|
281
277
|
end
|
282
278
|
|
283
279
|
ruby_files.each do |ruby_file|
|
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, :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
|
@@ -31,13 +31,12 @@ module Jarbler
|
|
31
31
|
puts "No configuration file found at #{File.join(Dir.pwd, CONFIG_FILE)}. Using default values."
|
32
32
|
end
|
33
33
|
puts "Used configuration values are:"
|
34
|
-
puts " compile_ruby_files: #{config.compile_ruby_files}"
|
35
|
-
puts " excludes: #{config.excludes}"
|
36
|
-
puts " excludes_from_compile: #{config.excludes_from_compile}"
|
34
|
+
puts " compile_ruby_files: #{config.compile_ruby_files}"
|
35
|
+
puts " excludes: #{config.excludes}"
|
36
|
+
puts " excludes_from_compile: #{config.excludes_from_compile}"
|
37
37
|
puts " executable: #{config.executable}"
|
38
|
-
puts " executable_params: #{config.executable_params}"
|
39
|
-
puts "
|
40
|
-
puts " includes: #{config.includes}" unless config.includes.empty?
|
38
|
+
puts " executable_params: #{config.executable_params}"
|
39
|
+
puts " includes: #{config.includes}"
|
41
40
|
puts " jar_name: #{config.jar_name}"
|
42
41
|
puts " jruby_version: #{config.jruby_version}"
|
43
42
|
puts ""
|
@@ -47,10 +46,9 @@ module Jarbler
|
|
47
46
|
def initialize
|
48
47
|
@compile_ruby_files = false
|
49
48
|
@excludes = %w(tmp/cache tmp/pids tmp/sockets vendor/bundle vendor/cache vendor/ruby)
|
50
|
-
@excludes_from_compile =
|
49
|
+
@excludes_from_compile = []
|
51
50
|
@executable = 'bin/rails'
|
52
51
|
@executable_params = %w(server -e production -p 8080)
|
53
|
-
@include_gems_to_compile = false
|
54
52
|
@includes = %w(app bin config config.ru db Gemfile Gemfile.lock lib log public Rakefile script vendor tmp)
|
55
53
|
@jar_name = File.basename(Dir.pwd) + '.jar'
|
56
54
|
@jruby_version = nil # determined automatically at runtime
|
@@ -88,10 +86,8 @@ module Jarbler
|
|
88
86
|
# the original ruby files are not included in the jar file, so source code is not visible
|
89
87
|
# config.compile_ruby_files = #{compile_ruby_files}
|
90
88
|
|
91
|
-
# Compile also the .rb files of the gems of the project to Java .class files?
|
92
|
-
# config.include_gems_to_compile = #{include_gems_to_compile}
|
93
|
-
|
94
89
|
# Directories or files to exclude from the compilation if compile_ruby_files = true
|
90
|
+
# The paths map to the final location of files or dirs in the jar file, e.g. config.excludes_from_compile = ['gems', 'app_root/app/models']
|
95
91
|
# config.excludes_from_compile = #{excludes_from_compile}
|
96
92
|
|
97
93
|
".split("\n"))
|
@@ -121,35 +117,51 @@ module Jarbler
|
|
121
117
|
|
122
118
|
# define JRuby version if not set in config file
|
123
119
|
def define_jruby_version
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
120
|
+
if @jruby_version.nil? && File.exist?('.ruby-version') # not yet defined in config file but .ruby-version file exists
|
121
|
+
# read the file RAILS_ROOT/.ruby-version starting from char at position 6 to the end of the line
|
122
|
+
full_jruby_version_string = File.read('.ruby-version')
|
123
|
+
if full_jruby_version_string[0..5] == 'jruby-'
|
124
|
+
@jruby_version = full_jruby_version_string[6..20].strip
|
125
|
+
if @jruby_version =~ /\d+\.\d+\.\d+\.\d+/ # check if the version is valid with four digits
|
126
|
+
debug "Jarbler::Config.define_jruby_version: JRuby version used from .ruby-version file: #{@jruby_version}"
|
127
|
+
else
|
128
|
+
debug "Jarbler::Config.define_jruby_version: Invalid JRuby version in .ruby-version file (not four digits delimited by dot): #{full_jruby_version_string}"
|
129
|
+
@jruby_version = nil
|
130
|
+
end
|
129
131
|
else
|
130
|
-
|
131
|
-
# Fetch the gem specification from Rubygems.org
|
132
|
-
# search for the gem and get the JSON response
|
133
|
-
response = Gem::SpecFetcher.fetcher.search_for_dependency(Gem::Dependency.new('jruby-jars'))
|
134
|
-
# extract the versions from the response
|
135
|
-
self.jruby_version = response&.first&.first&.first&.version&.to_s
|
136
|
-
raise "Unable to determine the latest available version of jruby-jars gem!\Rsponse = #{response.inspect}" unless self.jruby_version
|
137
|
-
|
138
|
-
#command = "gem search --remote jruby-jars"
|
139
|
-
#lines = `#{command}`
|
140
|
-
#raise "Command \"#{command}\" failed with return code #{$?} and output:\n#{lines}" unless $?.success?
|
141
|
-
#jruby_jars_line = lines.match(/^jruby-jars \((.*)\)/)
|
142
|
-
#raise "No jruby-jars gem found in rubygems.org!" unless jruby_jars_line
|
143
|
-
#self.jruby_version = /\((.*?)\)/.match(jruby_jars_line.to_s)[1]
|
144
|
-
debug "JRuby version from latest jruby-jars gem: #{jruby_version}"
|
132
|
+
debug "Jarbler::Config.define_jruby_version: Version info from .ruby-version file not applicable: #{full_jruby_version_string}"
|
145
133
|
end
|
146
134
|
end
|
135
|
+
|
136
|
+
if @jruby_version.nil? # not yet defined in config file and .ruby-version file
|
137
|
+
# no .ruby-version file to be used, use JRuby version of the latest Gem
|
138
|
+
# Fetch the gem specification from Rubygems.org
|
139
|
+
# search for the gem and get the JSON response
|
140
|
+
response = Gem::SpecFetcher.fetcher.search_for_dependency(Gem::Dependency.new('jruby-jars'))
|
141
|
+
debug("Jarbler::Config.define_jruby_version: Response from search_for_dependency = #{response.inspect}")
|
142
|
+
# extract the versions from the response
|
143
|
+
@jruby_version = response&.first&.first&.first&.version&.to_s
|
144
|
+
raise "Unable to determine the latest available version of jruby-jars gem!\nResponse = #{response.inspect}" unless @jruby_version
|
145
|
+
|
146
|
+
#command = "gem search --remote jruby-jars"
|
147
|
+
#lines = `#{command}`
|
148
|
+
#raise "Command \"#{command}\" failed with return code #{$?} and output:\n#{lines}" unless $?.success?
|
149
|
+
#jruby_jars_line = lines.match(/^jruby-jars \((.*)\)/)
|
150
|
+
#raise "No jruby-jars gem found in rubygems.org!" unless jruby_jars_line
|
151
|
+
#self.jruby_version = /\((.*?)\)/.match(jruby_jars_line.to_s)[1]
|
152
|
+
debug "Jarbler::Config.define_jruby_version: JRuby version from latest jruby-jars gem: #{jruby_version}"
|
153
|
+
end
|
147
154
|
end
|
148
155
|
|
149
156
|
def debug(msg)
|
150
157
|
puts msg if ENV['DEBUG']
|
151
158
|
end
|
152
159
|
|
160
|
+
# Avoid exception if using depprecated config attribute include_gems_to_compile
|
161
|
+
def include_gems_to_compile=(_value)
|
162
|
+
puts "Configuration attribute 'include_gems_to_compile' is deprecated. Use 'excludes_from_compile = [\”gems\”]' instead."
|
163
|
+
end
|
164
|
+
|
153
165
|
def validate_values
|
154
166
|
raise "Invalid config value for jar name: #{jar_name}" unless jar_name =~ /\w+/
|
155
167
|
raise "Invalid config value for executable: #{executable}" unless executable =~ /\w+/
|
@@ -158,8 +170,8 @@ module Jarbler
|
|
158
170
|
raise "Invalid config value for excludes: #{excludes}" unless excludes.is_a?(Array)
|
159
171
|
raise "Invalid config value for compile_ruby_files: #{compile_ruby_files}" unless [true, false].include?(compile_ruby_files)
|
160
172
|
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')
|
161
|
-
raise "include_gems_to_compile = true is supported only if compile_ruby_files = true!" if include_gems_to_compile && !compile_ruby_files
|
162
173
|
raise "Invalid config value for excludes_from_compile: #{excludes_from_compile}" unless excludes_from_compile.is_a?(Array)
|
174
|
+
raise "Invalid config value for jruby_version: #{jruby_version}" unless jruby_version.nil? || jruby_version =~ /\d+\.\d+\.\d+\.\d+/
|
163
175
|
end
|
164
176
|
end
|
165
177
|
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.
|
4
|
+
version: 0.3.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-
|
11
|
+
date: 2024-07-02 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'
|