jarbler 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b29152eb922ef6ae438fb5facfd9c3a7cc8df920ad350254729aca4ad1cccff2
4
- data.tar.gz: 632b9ca7b2663a563e5cecdad71c789b3c40f205ff8365c36f37d7b0abe284a6
3
+ metadata.gz: 97f5261d55e15e23454414413af5f467bfdf5c2554916574269d6fa99f4a411a
4
+ data.tar.gz: 5a77de393585a7fa444157ebc2e7835d6d39e2e0e004ade0f840d9f2f9abcff9
5
5
  SHA512:
6
- metadata.gz: 3e560cd914882b62e45ebe20f10b2d7cd9eb7170be0412008afb970dbc1c571fa776d26aa8bf11d49aa205fdd5e05def9d121c876ce897a79b6ddbb8e6df92a4
7
- data.tar.gz: 8275b73c22ea2c91cf1db36649a0510b8fbe41d85be39a1ba093f84c4b78adec0cb74ce5345ebe5c4a925f4393ddefa173aebed27b2decbf2eea57f7e4ec3ce0
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 | 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
- | includes | ["app", "bin", "config", ...] (see generated template file for whole content) | The files and dirs of the project to include in the jar file |
63
- | jar_name | &lt; Name of project dir &gt;.jar | The name of the generated jar file |
64
- | 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 | ["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 | &lt; Name of project dir &gt;.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
@@ -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
- status = JRuby::Compiler::compile_argv([full_file_name]) # compile the Ruby file
277
- raise "Error compiling Ruby file #{ruby_file}" if status != 0
278
- File.delete(full_file_name) # remove the original Ruby file to ensure that the compiled class file is used
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
@@ -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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jarbler
4
- VERSION = "0.2.0"
5
- VERSION_DATE = "2024-06-12"
4
+ VERSION = "0.2.1"
5
+ VERSION_DATE = "2024-06-13"
6
6
  end
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.0
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-12 00:00:00.000000000 Z
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'