jarbler 0.3.5 → 0.3.6
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/lib/jarbler/JarMain.java +50 -19
- 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: 1496bf31678cf15945cd367d656a6717df35552c3deacf4e44d0f0d8267e26a0
|
4
|
+
data.tar.gz: 401efdc3ab67e9e913de4550ea108dc13899ececc0ab1b14267451e731803159
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39a464b266c5f06ebf2270e117ba0f81a7fae012c70d5a18737b89e72ab9c3f99ea44d0aa5d898e55b4381789a21e7b2c2e1a1abbc3e781a0d10da12f272cce2
|
7
|
+
data.tar.gz: 449426ef9a89c170efc469fc87ad179c2c89438580fac0cecbf19c6b06d7af048f0e345f3569aa46a6d4578ef3422602ea5f6acc84b3102544da8a43f7b4863c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.3.6] - 2025-03-31
|
4
|
+
|
5
|
+
- remove temporary folder with extracted jar content after termination of Ruby code even if Ruby code terminates the JVM hard with 'exit' or 'System.exit'
|
6
|
+
- provide exit code of Ruby code as exit code of the jar file execution
|
7
|
+
|
3
8
|
## [0.3.5] - 2025-03-22
|
4
9
|
|
5
10
|
- new config attribute "config.compile_java_version" allows control of setting for "javac -source and -target" for AOT compilation
|
data/lib/jarbler/JarMain.java
CHANGED
@@ -33,6 +33,9 @@ import java.security.ProtectionDomain;
|
|
33
33
|
|
34
34
|
class JarMain {
|
35
35
|
|
36
|
+
// declare as class variable to be used in addShutdownHook
|
37
|
+
private static URLClassLoader classLoader = null;
|
38
|
+
|
36
39
|
// executed by java -jar <jar file name>
|
37
40
|
public static void main(String[] args) {
|
38
41
|
debug("Start java process in jar file "+jar_file_name());
|
@@ -113,7 +116,7 @@ class JarMain {
|
|
113
116
|
create_bundle_config(app_root, gem_home);
|
114
117
|
|
115
118
|
// Load the Jar file
|
116
|
-
|
119
|
+
classLoader = new URLClassLoader(new URL[]{
|
117
120
|
jrubyCoreFile.toURI().toURL(),
|
118
121
|
jrubyStdlibFile.toURI().toURL()
|
119
122
|
//new URL("file:/" + jrubyCoreFile.getAbsolutePath()),
|
@@ -159,19 +162,39 @@ class JarMain {
|
|
159
162
|
debug(" - " + arg);
|
160
163
|
}
|
161
164
|
|
165
|
+
// Add code to execute at System.exit
|
166
|
+
// ensure cleanup of the temporary directory also at hard exit in Ruby code like 'exit' or 'System.exit'
|
167
|
+
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
168
|
+
debug("Execute shutdown hook");
|
169
|
+
try {
|
170
|
+
if (classLoader != null) {
|
171
|
+
// Free the JRuby jars to allow deletion of the temporary directory
|
172
|
+
classLoader.close();
|
173
|
+
classLoader = null; // Remove reference
|
174
|
+
System.gc(); // Suggest garbage collection
|
175
|
+
}
|
176
|
+
// remove the temp directory newFolder if not DEBUG mode
|
177
|
+
if (debug_active()) {
|
178
|
+
System.out.println("DEBUG mode is active, temporary folder is not removed at process termination: "+ newFolder.getAbsolutePath());
|
179
|
+
} else {
|
180
|
+
deleteFolder(newFolder);
|
181
|
+
}
|
182
|
+
} catch (Exception e) {
|
183
|
+
System.err.println("Exception in shutdown hook: "+ e.getMessage());
|
184
|
+
e.printStackTrace();
|
185
|
+
}
|
186
|
+
}));
|
187
|
+
|
162
188
|
// call the method org.jruby.Main.main
|
163
189
|
debug("Calling org.jruby.Main.main with: "+ mainArgs);
|
164
190
|
mainMethod.invoke(null, (Object)mainArgs.toArray(new String[mainArgs.size()]));
|
165
|
-
// TODO: evaluate return value
|
166
191
|
} catch (Exception e) {
|
167
192
|
e.printStackTrace();
|
193
|
+
System.exit(1); // signal unsuccessful termination
|
168
194
|
} finally {
|
169
|
-
//
|
170
|
-
if
|
171
|
-
|
172
|
-
} else {
|
173
|
-
deleteFolder(newFolder);
|
174
|
-
}
|
195
|
+
// Called only if the JVM is not terminated by System.exit before, see addShutdownHook
|
196
|
+
// This code is not executed if called 'exit' or 'System.exit' in Ruby code before
|
197
|
+
debug("Applicaton finished in finalize block");
|
175
198
|
}
|
176
199
|
}
|
177
200
|
|
@@ -240,24 +263,32 @@ class JarMain {
|
|
240
263
|
|
241
264
|
}
|
242
265
|
|
266
|
+
private static boolean debug_active() {
|
267
|
+
String debug = System.getenv("DEBUG");
|
268
|
+
return debug != null && debug.toUpperCase().equals("TRUE");
|
269
|
+
}
|
270
|
+
|
243
271
|
private static void debug(String msg) {
|
244
|
-
if (
|
272
|
+
if (debug_active()) {
|
245
273
|
System.err.println(msg);
|
246
274
|
}
|
247
275
|
}
|
248
276
|
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
277
|
+
private static void deleteFolder(File file) {
|
278
|
+
try
|
279
|
+
{
|
280
|
+
if (file.isDirectory()) {
|
281
|
+
File[] entries = file.listFiles();
|
282
|
+
for (File currentFile: entries) {
|
283
|
+
deleteFolder(currentFile);
|
284
|
+
}
|
285
|
+
}
|
286
|
+
file.delete();
|
287
|
+
} catch(Throwable t) {
|
288
|
+
System.err.println("Could not DELETE file: " + file.getAbsolutePath() + " - " + t.getMessage());
|
289
|
+
}
|
258
290
|
}
|
259
291
|
|
260
|
-
|
261
292
|
private static void create_bundle_config(String app_root, String gem_path) throws IOException {
|
262
293
|
File bundle_config = new File(app_root + File.separator + ".bundle");
|
263
294
|
bundle_config.mkdir();
|
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.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ramm
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-04-01 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'
|