jlauncher 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jlauncher.rb +88 -52
- data/lib/jlauncher/version.rb +1 -1
- 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: 3e2c517f35ed329bfd9c4914ce46c9cb73b9acf41997f20bba71a6ad38c1919b
|
4
|
+
data.tar.gz: 9a07409710858691cb51d53d4d3559f2682a7576bbf98000159dc0f9d8e6d3cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fba8f573953cbe2f396408f4de14d92d477420d35a51e9ba88f6c024f3d2b4c4ad3c8cfe883b65660f04c6854f02261455a4e779219682352eb43c0f6f1e3d9f
|
7
|
+
data.tar.gz: 800674218c910be02e8410e6d3ac24169b23652b91762a1d32dc7541ed1413c789dadfb5f6ea034f528b3dfc4678f8cf70f2e337b66e36e1420e250aff78727d
|
data/lib/jlauncher.rb
CHANGED
@@ -10,40 +10,37 @@ require 'colorize'
|
|
10
10
|
module JLauncher
|
11
11
|
|
12
12
|
def JLauncher.do_it(argv)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
parser = Optimist::Parser.new
|
14
|
+
parser.stop_on_unknown
|
15
|
+
parser.stop_on %w(run install)
|
16
|
+
parser.version VERSION
|
17
|
+
parser.banner <<-EOS
|
18
18
|
Starts a jar with a j-manifest.json description fetching (and caching) all dependencies.
|
19
19
|
|
20
20
|
Usage:
|
21
21
|
.. j [options] <run|install> <jarfile|manifestfile|mavencoordinates> args...
|
22
22
|
where [options] are:
|
23
23
|
EOS
|
24
|
-
|
24
|
+
parser.opt :verbose, "Print debugging info to stderr"
|
25
25
|
|
26
26
|
begin
|
27
|
-
opts =
|
27
|
+
opts =parser.parse(argv)
|
28
28
|
rescue Optimist::CommandlineError => e
|
29
|
-
|
29
|
+
parser.die(e.message, nil, e.error_code)
|
30
30
|
rescue Optimist::HelpNeeded
|
31
|
-
|
31
|
+
parser.educate
|
32
32
|
exit
|
33
33
|
rescue Optimist::VersionNeeded
|
34
|
-
|
34
|
+
putsparser.version
|
35
35
|
exit
|
36
36
|
end
|
37
37
|
|
38
38
|
verbose = opts[:verbose]
|
39
39
|
|
40
|
-
remaining_args =
|
40
|
+
remaining_args =parser.leftovers
|
41
41
|
|
42
42
|
subcommand = remaining_args.shift
|
43
43
|
|
44
|
-
start_coordinates = remaining_args.shift
|
45
|
-
|
46
|
-
program_args = remaining_args[0..-1]
|
47
44
|
|
48
45
|
resolver = Resolver.new(
|
49
46
|
MavenRepo.new(File.join(Dir.home, ".m2", "repository")),
|
@@ -52,64 +49,60 @@ where [options] are:
|
|
52
49
|
verbose
|
53
50
|
)
|
54
51
|
|
55
|
-
full_config = if File.exist?(start_coordinates)
|
56
|
-
if (start_coordinates.end_with?(".jar"))
|
57
|
-
STDERR.puts("Starting local jar") if verbose
|
58
52
|
|
59
|
-
start_coordinates = File.expand_path(start_coordinates)
|
60
53
|
|
61
|
-
|
54
|
+
if subcommand == "run"
|
55
|
+
start_coordinates = remaining_args.shift
|
62
56
|
|
57
|
+
full_config = resolve_full_config(resolver, start_coordinates, verbose)
|
63
58
|
|
64
|
-
|
65
|
-
FullConfig.new(manifest, extra_class_path)
|
66
|
-
else
|
67
|
-
STDERR.puts("Starting local manifest") if verbose
|
59
|
+
program_args = remaining_args[0..-1]
|
68
60
|
|
69
|
-
|
61
|
+
launch_config = full_config.launch_config(resolver)
|
70
62
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
63
|
+
launch_config.run(program_args)
|
64
|
+
else
|
65
|
+
if subcommand == "install"
|
66
|
+
subcommand_parser = Optimist::Parser.new
|
67
|
+
subcommand_parser.opt :executable_name, "Name of the executable script.", :type => :string
|
76
68
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
69
|
+
begin
|
70
|
+
opts = subcommand_parser.parse(remaining_args)
|
71
|
+
rescue Optimist::HelpNeeded
|
72
|
+
subcommand_parser.educate
|
73
|
+
exit
|
74
|
+
end
|
81
75
|
|
82
|
-
|
76
|
+
start_coordinates = subcommand_parser.leftovers.first
|
83
77
|
|
84
|
-
|
85
|
-
extra_class_path = "maven:" + start_coordinates
|
86
|
-
FullConfig.new(manifest, extra_class_path)
|
87
|
-
end
|
78
|
+
full_config = resolve_full_config(resolver, start_coordinates, verbose)
|
88
79
|
|
89
|
-
|
90
|
-
|
80
|
+
executable_name = full_config.manifest.executable_name || opts[:executable_name]
|
81
|
+
|
82
|
+
if ! executable_name
|
83
|
+
raise "Manifest does not contain executable name, please specify one on the commandline like so:\n" +
|
84
|
+
"jlauncher install --executable-name myexecutablename #{full_config.start_coordinates}"
|
85
|
+
end
|
91
86
|
|
92
|
-
launch_config.run(program_args)
|
93
|
-
else
|
94
|
-
if subcommand == "install"
|
95
87
|
bin_dir = File.expand_path("~/.config/jlauncher/bin")
|
96
|
-
|
88
|
+
|
89
|
+
executable_path = bin_dir + "/" + (executable_name)
|
97
90
|
FileUtils.mkdir_p(bin_dir)
|
98
91
|
File.write(executable_path, <<~HEREDOC
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
92
|
+
#!/usr/bin/env bash
|
93
|
+
|
94
|
+
set -e
|
95
|
+
set -u
|
96
|
+
set -o pipefail
|
104
97
|
|
105
|
-
|
98
|
+
jlauncher run #{full_config.start_coordinates} "$@"
|
106
99
|
HEREDOC
|
107
100
|
)
|
108
101
|
|
109
102
|
File.chmod(0755, executable_path)
|
110
103
|
check_path(bin_dir)
|
111
104
|
|
112
|
-
STDERR.puts("'#{start_coordinates}' has been installed as #{
|
105
|
+
STDERR.puts("'#{full_config.start_coordinates}' has been installed as #{executable_name.bold}.")
|
113
106
|
else
|
114
107
|
raise "'#{subcommand}' is not a valid subcommand."
|
115
108
|
end
|
@@ -151,12 +144,16 @@ where [options] are:
|
|
151
144
|
# plus an optional extra_class_path element, which contains either
|
152
145
|
# maven coordinates or a local file containing a jar
|
153
146
|
class FullConfig
|
154
|
-
|
147
|
+
attr_reader :manifest, :start_coordinates
|
148
|
+
|
149
|
+
def initialize(manifest, extra_class_path, start_coordinates)
|
155
150
|
@manifest = manifest
|
156
151
|
@extra_class_path = extra_class_path
|
152
|
+
@start_coordinates = start_coordinates
|
157
153
|
|
158
154
|
end
|
159
155
|
|
156
|
+
|
160
157
|
def launch_config(resolver)
|
161
158
|
class_path_from_manifest = @manifest.dependencies.map {
|
162
159
|
|c| resolver.get(c)
|
@@ -201,4 +198,43 @@ where [options] are:
|
|
201
198
|
@json_map['executableName']
|
202
199
|
end
|
203
200
|
end
|
201
|
+
|
202
|
+
private
|
203
|
+
|
204
|
+
def self.resolve_full_config(resolver, start_coordinates, verbose)
|
205
|
+
full_config = if File.exist?(start_coordinates)
|
206
|
+
if (start_coordinates.end_with?(".jar"))
|
207
|
+
STDERR.puts("Starting local jar") if verbose
|
208
|
+
|
209
|
+
start_coordinates = File.expand_path(start_coordinates)
|
210
|
+
|
211
|
+
extra_class_path = "file:" + File.expand_path(start_coordinates)
|
212
|
+
|
213
|
+
|
214
|
+
manifest = read_manifest(start_coordinates)
|
215
|
+
FullConfig.new(manifest, extra_class_path, start_coordinates)
|
216
|
+
else
|
217
|
+
STDERR.puts("Starting local manifest") if verbose
|
218
|
+
|
219
|
+
manifest = Manifest.new(JSON.parse(File.read(start_coordinates)))
|
220
|
+
|
221
|
+
extra_class_path = nil
|
222
|
+
FullConfig.new(manifest, extra_class_path, start_coordinates)
|
223
|
+
end
|
224
|
+
else
|
225
|
+
STDERR.puts("Starting from repo jar") if verbose
|
226
|
+
|
227
|
+
components = start_coordinates.split(":")
|
228
|
+
if components.length != 3
|
229
|
+
raise "'#{start_coordinates}' is not a valid coordinate use <groupId>:<artifactId>:<version>"
|
230
|
+
end
|
231
|
+
|
232
|
+
main_jar = resolver.get(Coordinates.new(start_coordinates))
|
233
|
+
|
234
|
+
manifest = read_manifest(main_jar)
|
235
|
+
extra_class_path = "maven:" + start_coordinates
|
236
|
+
FullConfig.new(manifest, extra_class_path, start_coordinates)
|
237
|
+
end
|
238
|
+
full_config
|
239
|
+
end
|
204
240
|
end
|
data/lib/jlauncher/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jlauncher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felix Leipold
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|