jarbler 0.1.0 → 0.1.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 +1 -0
- data/jarbler.gemspec +3 -3
- data/lib/jarbler/JarMain.java +31 -12
- data/lib/jarbler/builder.rb +17 -30
- data/lib/jarbler/version.rb +2 -2
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff7c6489ae577a03079ca5976e6f8ea2c311593aa2754590b83e37a446f68bc9
|
4
|
+
data.tar.gz: 840b7720151675d538e08473857d7fae6a4342f478cf84473ffc231f2414fc46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 444d52de14b8316967b5184c9e814e40d52bcb780d84ef74dc148befea457232182bf83b01ec8c64540959af7d2522d2e20417ed9589771e8cd63779ffd60266
|
7
|
+
data.tar.gz: 991f7a004c5383846504ff98c7b0c0cb508e50530d64887e4418dd7b9ec2e788764303fa7358eb43d8d66ec3143118da038ee8cf8b03e5743dbc7b83175ff87b
|
data/CHANGELOG.md
CHANGED
@@ -3,3 +3,12 @@
|
|
3
3
|
## [0.1.0] - 2023-04-12
|
4
4
|
|
5
5
|
- Initial release
|
6
|
+
|
7
|
+
## [0.1.1] - 2023-04-24
|
8
|
+
|
9
|
+
- Fixed the bug 'java.lang.ClassNotFoundException: org.jruby.Main' with Windows
|
10
|
+
|
11
|
+
## [0.1.2] - 2023-04-24
|
12
|
+
|
13
|
+
- extract valid Gem paths from Bundler instead of using the environment variable GEM_PATH
|
14
|
+
|
data/README.md
CHANGED
@@ -53,6 +53,7 @@ The default executable parameters are "server -p 8080 -e production".
|
|
53
53
|
|
54
54
|
## Troubleshooting
|
55
55
|
* Set DEBUG=true in environment to get additional runtime information
|
56
|
+
* The temporary folder with the extracted app and jRuby runtime files is not deleted after execution if DEBUG is set.
|
56
57
|
|
57
58
|
## Contributing
|
58
59
|
|
data/jarbler.gemspec
CHANGED
@@ -8,12 +8,12 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["Peter Ramm"]
|
9
9
|
spec.email = ["Peter@ramm-oberhermsdorf.de"]
|
10
10
|
|
11
|
-
spec.summary = "
|
12
|
-
spec.description = "Pack
|
11
|
+
spec.summary = "Pack a Ruby app into a Java jar file"
|
12
|
+
spec.description = "Pack Ruby combined with jRuby runtime into a jar file to simply run the app on any Java platform by '> java -jar file.jar'"
|
13
13
|
spec.homepage = "https://github.com/rammpeter/jarbler"
|
14
14
|
spec.license = "MIT"
|
15
15
|
spec.required_ruby_version = ">= 2.6.0"
|
16
|
-
|
16
|
+
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
18
18
|
spec.metadata["source_code_uri"] = "https://github.com/rammpeter/jarbler"
|
19
19
|
spec.metadata["changelog_uri"] = "https://github.com/rammpeter/jarbler/CHANGELOG.md"
|
data/lib/jarbler/JarMain.java
CHANGED
@@ -23,7 +23,10 @@ import java.lang.ClassNotFoundException;
|
|
23
23
|
import java.lang.NoSuchMethodException;
|
24
24
|
import java.lang.IllegalAccessException;
|
25
25
|
import java.lang.InstantiationException;
|
26
|
-
|
26
|
+
import java.util.Map;
|
27
|
+
import java.util.HashMap;
|
28
|
+
import java.lang.reflect.Field;
|
29
|
+
import java.io.FileWriter;
|
27
30
|
|
28
31
|
class JarMain {
|
29
32
|
|
@@ -55,6 +58,7 @@ class JarMain {
|
|
55
58
|
System.out.println("Extracting files from "+jarPath+" to "+ newFolder.getAbsolutePath());
|
56
59
|
unzip(jarPath, newFolder.getAbsolutePath());
|
57
60
|
|
61
|
+
String app_root = newFolder.getAbsolutePath()+File.separator+"app_root";
|
58
62
|
|
59
63
|
// get the file name of the jruby jar file in newFolder
|
60
64
|
File[] files = newFolder.listFiles();
|
@@ -86,15 +90,15 @@ class JarMain {
|
|
86
90
|
throw new RuntimeException("Property 'executable' definition missing in jarbler.properties");
|
87
91
|
}
|
88
92
|
|
89
|
-
|
90
|
-
|
91
|
-
System.setProperty("BUNDLE_PATH", newFolder.getAbsolutePath()+File.separator+"gems"); // this drives bundler for rails app
|
92
|
-
System.setProperty("BUNDLE_WITHOUT", "test:development"); // exclude test and development dependencies from Gemfile check
|
93
|
+
// create the bundle config file with the path of the gems
|
94
|
+
create_bundle_config(app_root, newFolder.getAbsolutePath()+File.separator+"gems");
|
93
95
|
|
94
96
|
// Load the Jar file
|
95
97
|
URLClassLoader classLoader = new URLClassLoader(new URL[]{
|
96
|
-
|
97
|
-
|
98
|
+
jrubyCoreFile.toURI().toURL(),
|
99
|
+
jrubyStdlibFile.toURI().toURL()
|
100
|
+
//new URL("file:/" + jrubyCoreFile.getAbsolutePath()),
|
101
|
+
//new URL("file:/" + jrubyStdlibFile.getAbsolutePath())
|
98
102
|
});
|
99
103
|
|
100
104
|
// Load the class
|
@@ -128,15 +132,18 @@ class JarMain {
|
|
128
132
|
debug(" - " + arg);
|
129
133
|
}
|
130
134
|
|
131
|
-
System.setProperty("user.dir",
|
135
|
+
System.setProperty("user.dir", app_root);
|
132
136
|
// call the method org.jruby.Main.main
|
133
137
|
mainMethod.invoke(null, (Object)mainArgs.toArray(new String[mainArgs.size()]));
|
134
138
|
} catch (Exception e) {
|
135
|
-
e.
|
139
|
+
e.printStackTrace();
|
136
140
|
} finally {
|
137
|
-
// remove the temp directory newFolder
|
138
|
-
|
139
|
-
|
141
|
+
// remove the temp directory newFolder if not DEBUG mode
|
142
|
+
if (System.getenv("DEBUG") != null) {
|
143
|
+
System.out.println("DEBUG mode is active, temporary folder is not removed at process termination: "+ newFolder.getAbsolutePath());
|
144
|
+
} else {
|
145
|
+
deleteFolder(newFolder);
|
146
|
+
}
|
140
147
|
}
|
141
148
|
}
|
142
149
|
|
@@ -206,4 +213,16 @@ class JarMain {
|
|
206
213
|
file.delete();
|
207
214
|
}
|
208
215
|
|
216
|
+
|
217
|
+
private static void create_bundle_config(String app_root, String gem_path) throws IOException {
|
218
|
+
File bundle_config = new File(app_root + File.separator + ".bundle");
|
219
|
+
bundle_config.mkdir();
|
220
|
+
File bundle_config_file = new File(bundle_config.getAbsolutePath() + File.separator + "config");
|
221
|
+
bundle_config_file.createNewFile();
|
222
|
+
FileWriter fw = new FileWriter(bundle_config_file);
|
223
|
+
fw.write("---\n");
|
224
|
+
fw.write("BUNDLE_PATH: " + gem_path + "\n");
|
225
|
+
fw.write("BUNDLE_WITHOUT: test:development\n");
|
226
|
+
fw.close();
|
227
|
+
}
|
209
228
|
}
|
data/lib/jarbler/builder.rb
CHANGED
@@ -86,28 +86,28 @@ module Jarbler
|
|
86
86
|
# @param [String] app_root Application root directory
|
87
87
|
# @return [Array] Array of Gem locations
|
88
88
|
def collect_gem_search_locations(app_root)
|
89
|
-
#
|
90
|
-
|
91
|
-
|
92
|
-
possible_gem_search_locations << bundle_config_bundle_path(app_root) if bundle_config_bundle_path(app_root)
|
93
|
-
ENV['GEM_PATH'].split(':').each do |gem_path|
|
94
|
-
possible_gem_search_locations << gem_path
|
95
|
-
end
|
89
|
+
# All active search locations for Gems
|
90
|
+
Bundler.setup
|
91
|
+
possible_gem_search_locations = Gem.paths.path
|
96
92
|
debug "Possible Gem locations: #{possible_gem_search_locations}"
|
97
93
|
gem_search_locations = []
|
98
94
|
# Check where inside this location the gems may be installed
|
99
95
|
possible_gem_search_locations.each do |gem_search_location|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
96
|
+
if File.exist?(gem_search_location) && File.directory?(gem_search_location)
|
97
|
+
valid_gem_search_location = nil # No valid path found yet
|
98
|
+
Find.find(gem_search_location) do |path|
|
99
|
+
if File.directory?(path) && File.exist?("#{path}/specifications") && File.exist?("#{path}/gems")
|
100
|
+
valid_gem_search_location = path # Found a valid path
|
101
|
+
Find.prune # Do not search deeper
|
102
|
+
end
|
103
|
+
end
|
104
|
+
if valid_gem_search_location
|
105
|
+
gem_search_locations << valid_gem_search_location
|
106
|
+
else
|
107
|
+
debug "No valid gem location found in #{gem_search_location}"
|
105
108
|
end
|
106
|
-
end
|
107
|
-
if valid_gem_search_location
|
108
|
-
gem_search_locations << valid_gem_search_location
|
109
109
|
else
|
110
|
-
debug
|
110
|
+
debug("Gem location #{gem_search_location} does not exist or is not a directory")
|
111
111
|
end
|
112
112
|
end
|
113
113
|
debug "Valid Gem locations: #{gem_search_locations}"
|
@@ -193,19 +193,6 @@ module Jarbler
|
|
193
193
|
@config
|
194
194
|
end
|
195
195
|
|
196
|
-
# Check if there is an additional local bundle path in .bundle/config
|
197
|
-
def bundle_config_bundle_path(rails_root)
|
198
|
-
bundle_path = nil # default
|
199
|
-
if File.exist?("#{rails_root}/.bundle/config")
|
200
|
-
bundle_config = YAML.load_file("#{rails_root}/.bundle/config")
|
201
|
-
if bundle_config && bundle_config['BUNDLE_PATH']
|
202
|
-
bundle_path = "#{rails_root}/#{bundle_config['BUNDLE_PATH']}"
|
203
|
-
debug "Local Gem path configured in #{rails_root}/.bundle/config: #{bundle_path}"
|
204
|
-
end
|
205
|
-
end
|
206
|
-
bundle_path
|
207
|
-
end
|
208
|
-
|
209
196
|
# Copy the jruby-jars to the staging directory
|
210
197
|
# @param [String] staging_dir Path to the staging directory
|
211
198
|
# @param [Array] gem_search_locations Array of Gem locations to look for jRuby jars
|
@@ -219,7 +206,7 @@ module Jarbler
|
|
219
206
|
break
|
220
207
|
end
|
221
208
|
end
|
222
|
-
raise "Could not determine location of jRuby jars for release '#{config.jruby_version}' in the following
|
209
|
+
raise "Could not determine location of jRuby jars for release '#{config.jruby_version}' in the following locations:\n#{gem_search_locations}" unless jruby_jars_location
|
223
210
|
file_utils_copy("#{jruby_jars_location}/lib/jruby-core-#{config.jruby_version}-complete.jar", staging_dir)
|
224
211
|
file_utils_copy("#{jruby_jars_location}/lib/jruby-stdlib-#{config.jruby_version}.jar", staging_dir)
|
225
212
|
|
data/lib/jarbler/version.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jarbler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ramm
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: Pack
|
13
|
+
description: Pack Ruby combined with jRuby runtime into a jar file to simply run the
|
14
|
+
app on any Java platform by '> java -jar file.jar'
|
14
15
|
email:
|
15
16
|
- Peter@ramm-oberhermsdorf.de
|
16
17
|
executables:
|
@@ -40,7 +41,7 @@ metadata:
|
|
40
41
|
homepage_uri: https://github.com/rammpeter/jarbler
|
41
42
|
source_code_uri: https://github.com/rammpeter/jarbler
|
42
43
|
changelog_uri: https://github.com/rammpeter/jarbler/CHANGELOG.md
|
43
|
-
post_install_message:
|
44
|
+
post_install_message:
|
44
45
|
rdoc_options: []
|
45
46
|
require_paths:
|
46
47
|
- lib
|
@@ -55,8 +56,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
56
|
- !ruby/object:Gem::Version
|
56
57
|
version: '0'
|
57
58
|
requirements: []
|
58
|
-
rubygems_version: 3.
|
59
|
-
signing_key:
|
59
|
+
rubygems_version: 3.3.26
|
60
|
+
signing_key:
|
60
61
|
specification_version: 4
|
61
|
-
summary:
|
62
|
+
summary: Pack a Ruby app into a Java jar file
|
62
63
|
test_files: []
|