jruby-bundler 0.9.5
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 +7 -0
- data/Gemfile +6 -0
- data/MIT-LICENSE +20 -0
- data/Readme.md +117 -0
- data/bin/jbundle +51 -0
- data/lib/jbundler/aether.rb +139 -0
- data/lib/jbundler/classpath_file.rb +115 -0
- data/lib/jbundler/cli.rb +148 -0
- data/lib/jbundler/config.rb +191 -0
- data/lib/jbundler/configurator.rb +27 -0
- data/lib/jbundler/context.rb +34 -0
- data/lib/jbundler/dependency_pom.rb +30 -0
- data/lib/jbundler/gemfile_lock.rb +69 -0
- data/lib/jbundler/jarfile_lock.rb +67 -0
- data/lib/jbundler/jruby_complete.rb +44 -0
- data/lib/jbundler/jruby_complete_pom.rb +31 -0
- data/lib/jbundler/lock_down.rb +166 -0
- data/lib/jbundler/pom.rb +153 -0
- data/lib/jbundler/pom_runner.rb +71 -0
- data/lib/jbundler/show.rb +53 -0
- data/lib/jbundler/tree.rb +31 -0
- data/lib/jbundler/vendor.rb +75 -0
- data/lib/jbundler.rb +73 -0
- data/spec/classpath_file_spec.rb +138 -0
- data/spec/config_spec.rb +180 -0
- data/spec/pom_spec.rb +30 -0
- data/spec/project/Settings.xml +0 -0
- data/spec/project/settings.xml +0 -0
- data/spec/setup.rb +16 -0
- data/spec/vendor_spec.rb +60 -0
- metadata +176 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4f3add68c62109a3250bcd286ccf61638a78cd778b0b9f58cc7b3c676898094c
|
4
|
+
data.tar.gz: 817023ab4df35852a5bae8142810f03f6ff57da0928e87b06775be887a7967ca
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2d903df8f998a8c188d727a9352f053c0e0209d8af4401ce675a801b14bf66ab230fd1eab120c3d47dc1c4e458df52c4848cd0392ed0ca9f2da77d81655b74da
|
7
|
+
data.tar.gz: 49e52ae1d3fb2a3cff153ec23e24060942b18d537da6bbcadfaacfe628aea6d7b99071605d37762a7cf0de75ba2462e04d018599918c88f3986a32f4937169b1
|
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Christian Meier
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Readme.md
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
# jbundler
|
2
|
+
|
3
|
+
* [](http://travis-ci.org/mkristian/jbundler)
|
4
|
+
|
5
|
+
Manage jar dependencies similar to how **bundler** manages gem dependencies:
|
6
|
+
|
7
|
+
* the DSL mimics the one from bundler
|
8
|
+
* you can use maven-like version declarations or rubygems/bundler version ranges
|
9
|
+
* it locks down the jar versions inside "Jarfile.lock"
|
10
|
+
* you can declare jar dependencies within a gem using the requirements directive of the gem specification. jbundler will include those jar dependencies into its classpath
|
11
|
+
|
12
|
+
differences compared to **bundler**
|
13
|
+
|
14
|
+
* you need to run ```bundle install``` first if any of the gems have jar dependencies.
|
15
|
+
* all one command ```jbundle```, see ```jbundle help``` on the possible options and how to update a single jar, etc.
|
16
|
+
|
17
|
+
## Get started
|
18
|
+
|
19
|
+
Install JBundler with:
|
20
|
+
```bash
|
21
|
+
jruby -S gem install jbundler
|
22
|
+
```
|
23
|
+
|
24
|
+
First, create a **Jarfile**, something like:
|
25
|
+
```bash
|
26
|
+
jar 'org.yaml:snakeyaml', '1.14'
|
27
|
+
jar 'org.slf4j:slf4j-simple', '>1.1'
|
28
|
+
```
|
29
|
+
|
30
|
+
Install jar dependencies
|
31
|
+
```bash
|
32
|
+
jruby -S jbundle install
|
33
|
+
```
|
34
|
+
|
35
|
+
Loading the jar files
|
36
|
+
```bash
|
37
|
+
require 'jbundler'
|
38
|
+
```
|
39
|
+
|
40
|
+
It will add all the jar dependencies in the java classpath from the `Jarfile.lock`.
|
41
|
+
|
42
|
+
### Jarfile
|
43
|
+
|
44
|
+
More info about the **[Jarfile](https://github.com/torquebox/maven-tools/wiki/Jarfile)** and about [versions](https://github.com/torquebox/maven-tools/wiki/Versions).
|
45
|
+
|
46
|
+
For adding a maven repository see [Jarfile](https://github.com/torquebox/maven-tools/wiki/Jarfile).
|
47
|
+
|
48
|
+
## Building the jbundler gem
|
49
|
+
|
50
|
+
Running the integration test
|
51
|
+
|
52
|
+
```bash
|
53
|
+
./mvnw verify
|
54
|
+
./mvnw clean verify
|
55
|
+
```
|
56
|
+
or a single integration test
|
57
|
+
```bash
|
58
|
+
./mvnw verify -Dinvoker.test=running_rspec_via_rake
|
59
|
+
./mvnw clean verify -Dinvoker.test=running_rspec_via_rake
|
60
|
+
```
|
61
|
+
|
62
|
+
Building the gem (see ./pkg)
|
63
|
+
```bash
|
64
|
+
./mvnw package -Dinvoker.skip
|
65
|
+
```
|
66
|
+
|
67
|
+
Or just
|
68
|
+
```bash
|
69
|
+
gem build jbundler.gemspec
|
70
|
+
```
|
71
|
+
|
72
|
+
## Usage
|
73
|
+
|
74
|
+
Here is an example usage of the AliasEvent class from the snakeyaml package
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
#test_file.rb
|
78
|
+
require 'jbundler'
|
79
|
+
require 'java'
|
80
|
+
|
81
|
+
java_import 'org.yaml.snakeyaml.events.AliasEvent'
|
82
|
+
|
83
|
+
class TestClass
|
84
|
+
def my_method
|
85
|
+
puts AliasEvent.methods
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
TestClass.new.my_method
|
90
|
+
```
|
91
|
+
|
92
|
+
## Limitations
|
93
|
+
|
94
|
+
Since the version resolution happens in two steps - first the gems, and then the jars/poms - it is possible in case of a failure that there is a valid gems/jars version resolution which satisfies all version contraints. So there is plenty of space for improvements (like maven could resolve the gems as well, etc).
|
95
|
+
|
96
|
+
## Special thanks
|
97
|
+
|
98
|
+
The whole project actually started with a controversial discussion on a [pull request on bundler](https://github.com/carlhuda/bundler/pull/1683). This very same pull request were the starting point of that project here. Probably by now there is not much left of the original code, but many thanks to [ANithian](https://github.com/ANithian) for giving the seed of that project.
|
99
|
+
|
100
|
+
License
|
101
|
+
-------
|
102
|
+
|
103
|
+
Almost all code is under the MIT license but the java class (AetherSettings.java)[https://github.com/mkristian/jbundler/blob/master/src/main/java/jbundler/AetherSettings.java] which was derived from EPL licensed code.
|
104
|
+
|
105
|
+
Contributing
|
106
|
+
------------
|
107
|
+
|
108
|
+
1. Fork it
|
109
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
110
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
111
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
112
|
+
5. Create new Pull Request
|
113
|
+
|
114
|
+
Meta-fu
|
115
|
+
-------
|
116
|
+
|
117
|
+
enjoy :)
|
data/bin/jbundle
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
if ARGV[0] == 'help'
|
3
|
+
|
4
|
+
# ensure we use the right version
|
5
|
+
gem 'ruby-maven', '>=3.3.3'
|
6
|
+
|
7
|
+
require 'jbundler/cli'
|
8
|
+
|
9
|
+
JBundler::Cli.start
|
10
|
+
|
11
|
+
else
|
12
|
+
|
13
|
+
if ARGV == [] || ARGV.all?{ |a| a.match( /^-/ ) }
|
14
|
+
ARGV.unshift 'install'
|
15
|
+
end
|
16
|
+
|
17
|
+
if ARGV[0] == 'console'
|
18
|
+
# ensure we use the right version
|
19
|
+
gem 'ruby-maven', '>=3.3.3'
|
20
|
+
|
21
|
+
require 'irb'
|
22
|
+
require 'jbundler'
|
23
|
+
require 'jbundler/lazy'
|
24
|
+
include JBundler::Lazy
|
25
|
+
|
26
|
+
ARGV.shift
|
27
|
+
require 'jbundler'
|
28
|
+
if defined? JBUNDLER_CLASSPATH
|
29
|
+
warn 'Jarfile dependencies loaded'
|
30
|
+
else
|
31
|
+
warn 'Could not locate a Jarfile'
|
32
|
+
end
|
33
|
+
|
34
|
+
if defined? JBUNDLER_CLASSPATH
|
35
|
+
warn 'Jarfile dependencies loaded'
|
36
|
+
else
|
37
|
+
warn 'Could not locate a Jarfile'
|
38
|
+
end
|
39
|
+
|
40
|
+
IRB.start
|
41
|
+
|
42
|
+
else
|
43
|
+
# ensure we use the right version
|
44
|
+
gem 'ruby-maven', '>=3.3.3'
|
45
|
+
|
46
|
+
require 'jbundler/cli'
|
47
|
+
JBundler::Cli.start
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
@@ -0,0 +1,139 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2013 Christian Meier
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
5
|
+
# this software and associated documentation files (the "Software"), to deal in
|
6
|
+
# the Software without restriction, including without limitation the rights to
|
7
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
8
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
9
|
+
# subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
16
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
17
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
18
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
19
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
#
|
21
|
+
require 'yaml'
|
22
|
+
require 'jbundler/config'
|
23
|
+
require 'maven/ruby'
|
24
|
+
|
25
|
+
module JBundler
|
26
|
+
|
27
|
+
class AetherRuby
|
28
|
+
|
29
|
+
def self.setup_classloader
|
30
|
+
require 'java'
|
31
|
+
|
32
|
+
Dir.glob( File.join( Maven.lib, '*.jar' ) ).each do |path|
|
33
|
+
require path
|
34
|
+
end
|
35
|
+
begin
|
36
|
+
require 'jbundler.jar'
|
37
|
+
rescue LoadError
|
38
|
+
# allow the classes already be added to the classloader
|
39
|
+
begin
|
40
|
+
java_import 'jbundler.Aether'
|
41
|
+
rescue NameError
|
42
|
+
# assume this happens only when working on the git clone
|
43
|
+
raise "jbundler.jar is missing - maybe you need to build it first ? use\n$ rmvn prepare-package -Dmaven.test.skip\n"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
java_import 'jbundler.Aether'
|
47
|
+
end
|
48
|
+
|
49
|
+
def initialize( config = Config.new )
|
50
|
+
unless defined? Aether
|
51
|
+
self.class.setup_classloader
|
52
|
+
end
|
53
|
+
@aether = Aether.new( config.verbose )
|
54
|
+
@aether.add_proxy( config.proxy ) if config.proxy
|
55
|
+
@aether.add_mirror( config.mirror ) if config.mirror
|
56
|
+
@aether.offline = config.offline
|
57
|
+
if config.settings
|
58
|
+
@aether.user_settings = java.io.File.new( config.settings )
|
59
|
+
end
|
60
|
+
if config.local_repository
|
61
|
+
@aether.local_repository = java.io.File.new(config.local_repository)
|
62
|
+
end
|
63
|
+
rescue NativeException => e
|
64
|
+
e.cause.print_stack_trace
|
65
|
+
raise e
|
66
|
+
end
|
67
|
+
|
68
|
+
def local_jars
|
69
|
+
@local_jars ||= []
|
70
|
+
end
|
71
|
+
|
72
|
+
def add_local_jar( path )
|
73
|
+
local_jars << File.expand_path( path )
|
74
|
+
end
|
75
|
+
|
76
|
+
def add_artifact(coordinate, extension = nil)
|
77
|
+
if extension
|
78
|
+
coord = coordinate.split(/:/)
|
79
|
+
coord.insert(2, extension)
|
80
|
+
@aether.add_artifact(coord.join(":"))
|
81
|
+
else
|
82
|
+
@aether.add_artifact(coordinate)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def add_repository(name, url)
|
87
|
+
@aether.add_repository(name, url)
|
88
|
+
end
|
89
|
+
|
90
|
+
def add_snapshot_repository(name, url)
|
91
|
+
@aether.add_snapshot_repository(name, url)
|
92
|
+
end
|
93
|
+
|
94
|
+
def resolve
|
95
|
+
@aether.resolve unless artifacts.empty?
|
96
|
+
rescue NativeException => e
|
97
|
+
e.cause.print_stack_trace
|
98
|
+
raise e
|
99
|
+
end
|
100
|
+
|
101
|
+
def classpath
|
102
|
+
if artifacts.empty? and local_jars.empty?
|
103
|
+
''
|
104
|
+
else
|
105
|
+
path = [ @aether.classpath ]
|
106
|
+
path = path + @local_jars if @local_jars
|
107
|
+
path.join( File::PATH_SEPARATOR )
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def classpath_array
|
112
|
+
classpath.split(/#{File::PATH_SEPARATOR}/)
|
113
|
+
end
|
114
|
+
|
115
|
+
def repositories
|
116
|
+
@aether.repositories
|
117
|
+
end
|
118
|
+
|
119
|
+
def artifacts
|
120
|
+
@aether.artifacts
|
121
|
+
end
|
122
|
+
|
123
|
+
def resolved_coordinates
|
124
|
+
if @aether.artifacts.empty?
|
125
|
+
[]
|
126
|
+
else
|
127
|
+
@aether.resolved_coordinates
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def install(coordinate, file)
|
132
|
+
@aether.install(coordinate, file)
|
133
|
+
rescue NativeException => e
|
134
|
+
e.cause.print_stack_trace
|
135
|
+
raise e
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2013 Christian Meier
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
5
|
+
# this software and associated documentation files (the "Software"), to deal in
|
6
|
+
# the Software without restriction, including without limitation the rights to
|
7
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
8
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
9
|
+
# subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
16
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
17
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
18
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
19
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
#
|
21
|
+
module JBundler
|
22
|
+
|
23
|
+
class ClasspathFile
|
24
|
+
|
25
|
+
def initialize(classpathfile = '.jbundler/classpath.rb')
|
26
|
+
@classpathfile = classpathfile
|
27
|
+
end
|
28
|
+
|
29
|
+
def file
|
30
|
+
@classpathfile
|
31
|
+
end
|
32
|
+
|
33
|
+
def load_classpath
|
34
|
+
load File.expand_path @classpathfile
|
35
|
+
end
|
36
|
+
|
37
|
+
def require_classpath
|
38
|
+
load_classpath
|
39
|
+
JBUNDLER_CLASSPATH.each { |c| require c }
|
40
|
+
end
|
41
|
+
|
42
|
+
def require_test_classpath
|
43
|
+
load_classpath
|
44
|
+
JBUNDLER_TEST_CLASSPATH.each { |c| require c }
|
45
|
+
end
|
46
|
+
|
47
|
+
def mtime
|
48
|
+
File.mtime(@classpathfile)
|
49
|
+
end
|
50
|
+
|
51
|
+
def exists?
|
52
|
+
File.exists?(@classpathfile)
|
53
|
+
end
|
54
|
+
|
55
|
+
def missing?( jarfile )
|
56
|
+
!exists? || !jarfile.exists_lock?
|
57
|
+
end
|
58
|
+
|
59
|
+
def jarfile_newer?( jarfile )
|
60
|
+
jarfile.exists? && (jarfile.mtime > mtime)
|
61
|
+
end
|
62
|
+
|
63
|
+
def jarlock_newer?( jarfile )
|
64
|
+
jarfile.exists_lock? && (jarfile.mtime_lock > mtime)
|
65
|
+
end
|
66
|
+
|
67
|
+
def needs_update?(jarfile, gemfile_lock)
|
68
|
+
if ( jarfile.exists? || gemfile_lock.exists? || jarfile.exists_lock? )
|
69
|
+
missing?( jarfile ) || jarfile_newer?( jarfile ) || jarlock_newer?( jarfile ) || gemfile_lock.newer?( mtime )
|
70
|
+
else
|
71
|
+
false
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def generate( classpath_array, test_array = [], jruby_array = [], local_repo = nil )
|
76
|
+
FileUtils.mkdir_p(File.dirname(@classpathfile))
|
77
|
+
File.open(@classpathfile, 'w') do |f|
|
78
|
+
if local_repo
|
79
|
+
local_repo = File.expand_path( local_repo )
|
80
|
+
f.puts "require 'jar_dependencies'"
|
81
|
+
f.puts "JBUNDLER_LOCAL_REPO = Jars.home"
|
82
|
+
end
|
83
|
+
dump_array( f, jruby_array || [], 'JRUBY_', local_repo )
|
84
|
+
dump_array( f, test_array || [], 'TEST_', local_repo )
|
85
|
+
dump_array( f, classpath_array || [], '', local_repo )
|
86
|
+
f.close
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
def dump_array( file, array, prefix, local_repo )
|
92
|
+
file.puts "JBUNDLER_#{prefix}CLASSPATH = []"
|
93
|
+
array.each do |path|
|
94
|
+
dump_jar( file, path, prefix, local_repo )
|
95
|
+
end
|
96
|
+
file.puts "JBUNDLER_#{prefix}CLASSPATH.freeze"
|
97
|
+
end
|
98
|
+
|
99
|
+
def dump_jar( file, path, prefix, local_repo )
|
100
|
+
return if path =~ /pom$/
|
101
|
+
if local_repo
|
102
|
+
path = path.sub( /#{local_repo}/, '' )
|
103
|
+
unless File.exists?( path )
|
104
|
+
file.puts "JBUNDLER_#{prefix}CLASSPATH << (JBUNDLER_LOCAL_REPO + '#{path}')"
|
105
|
+
path = nil
|
106
|
+
end
|
107
|
+
end
|
108
|
+
if path
|
109
|
+
# either we do not have a local_repo or the path is a absolute
|
110
|
+
# path from system artifact
|
111
|
+
file.puts "JBUNDLER_#{prefix}CLASSPATH << '#{path}'"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
data/lib/jbundler/cli.rb
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2013 Christian Meier
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
5
|
+
# this software and associated documentation files (the "Software"), to deal in
|
6
|
+
# the Software without restriction, including without limitation the rights to
|
7
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
8
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
9
|
+
# subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
16
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
17
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
18
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
19
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
#
|
21
|
+
require 'bundler/vendored_thor'
|
22
|
+
require 'jbundler/config'
|
23
|
+
require 'jbundler/tree'
|
24
|
+
require 'jbundler/lock_down'
|
25
|
+
require 'jbundler/jruby_complete'
|
26
|
+
module JBundler
|
27
|
+
# As of v1.9.0, bundler's vendored version of thor is namespaced
|
28
|
+
Thor = Bundler::Thor if Gem.loaded_specs['bundler'].version >= Gem::Version.new('1.9.0')
|
29
|
+
|
30
|
+
class Cli < Thor
|
31
|
+
no_tasks do
|
32
|
+
def config
|
33
|
+
@config ||= JBundler::Config.new
|
34
|
+
end
|
35
|
+
|
36
|
+
def unvendor
|
37
|
+
vendor = JBundler::Vendor.new( config.vendor_dir )
|
38
|
+
vendor.clear
|
39
|
+
end
|
40
|
+
|
41
|
+
def vendor
|
42
|
+
vendor = JBundler::Vendor.new( config.vendor_dir )
|
43
|
+
if vendor.vendored?
|
44
|
+
raise "already vendored. please 'jbundle install --no-deployment before."
|
45
|
+
else
|
46
|
+
vendor.setup( JBundler::ClasspathFile.new( config.classpath_file ) )
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def say_bundle_complete
|
51
|
+
puts ''
|
52
|
+
puts 'Your jbundle is complete! Use `jbundle show` to see where the bundled jars are installed.'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
desc 'tree', 'display a graphical representation of the dependency tree'
|
57
|
+
#method_option :details, :type => :boolean, :default => false
|
58
|
+
def tree
|
59
|
+
JBundler::Tree.new( config ).show_it
|
60
|
+
end
|
61
|
+
|
62
|
+
desc 'install', "first `bundle install` is called and then the jar dependencies will be installed. for more details see `bundle help install`, jbundler will ignore most options. the install command is also the default when no command is given."
|
63
|
+
method_option :vendor, :type => :boolean, :default => false, :desc => 'vendor jars into vendor directory (jbundler only).'
|
64
|
+
method_option :debug, :type => :boolean, :default => false, :desc => 'enable maven debug output (jbundler only).'
|
65
|
+
method_option :verbose, :type => :boolean, :default => false, :desc => 'enable maven output (jbundler only).'
|
66
|
+
method_option :deployment, :type => :boolean, :default => false, :desc => "copy the jars into the vendor/jars directory (or as configured). these vendored jars have preference before the classpath jars !"
|
67
|
+
method_option :no_deployment, :type => :boolean, :default => false, :desc => 'clears the vendored jars'
|
68
|
+
method_option :path, :type => :string
|
69
|
+
method_option :without, :type => :array
|
70
|
+
method_option :system, :type => :boolean
|
71
|
+
method_option :local, :type => :boolean
|
72
|
+
method_option :binstubs, :type => :string
|
73
|
+
method_option :trust_policy, :type => :string
|
74
|
+
method_option :gemfile, :type => :string
|
75
|
+
method_option :jobs, :type => :string
|
76
|
+
method_option :retry, :type => :string
|
77
|
+
method_option :no_cache, :type => :boolean
|
78
|
+
method_option :quiet, :type => :boolean
|
79
|
+
def install
|
80
|
+
msg = JBundler::LockDown.new( config ).lock_down( options[ :vendor ],
|
81
|
+
options[ :debug ] ,
|
82
|
+
options[ :verbose ] )
|
83
|
+
config.verbose = ! options[ :quiet ]
|
84
|
+
Show.new( config ).show_classpath
|
85
|
+
unless options[ :quiet ]
|
86
|
+
puts 'jbundle complete !'
|
87
|
+
puts
|
88
|
+
end
|
89
|
+
puts msg if msg
|
90
|
+
end
|
91
|
+
|
92
|
+
desc 'console', 'irb session with gems and/or jars and with lazy jar loading.'
|
93
|
+
def console
|
94
|
+
# dummy - never executed !!!
|
95
|
+
end
|
96
|
+
|
97
|
+
desc 'lock_down', "first `bundle install` is called and then the jar dependencies will be installed. for more details see `bundle help install`, jbundler will ignore all options. the install command is also the default when no command is given. that is kept as fall back in cases where the new install does not work as before."
|
98
|
+
method_option :deployment, :type => :boolean, :default => false, :desc => "copy the jars into the vendor/jars directory (or as configured). add the vendor/jars $LOAD_PATH and Jars.require_jars_lock! - no need for any jbundler files at runtime !"
|
99
|
+
method_option :no_deployment, :type => :boolean, :default => false, :desc => 'clears the vendored jars'
|
100
|
+
method_option :path, :type => :string
|
101
|
+
method_option :without, :type => :array
|
102
|
+
method_option :system, :type => :boolean
|
103
|
+
method_option :local, :type => :boolean
|
104
|
+
method_option :binstubs, :type => :string
|
105
|
+
method_option :trust_policy, :type => :string
|
106
|
+
method_option :gemfile, :type => :string
|
107
|
+
method_option :jobs, :type => :string
|
108
|
+
method_option :retry, :type => :string
|
109
|
+
method_option :no_cache, :type => :boolean
|
110
|
+
method_option :quiet, :type => :boolean
|
111
|
+
def lock_down
|
112
|
+
require 'jbundler'
|
113
|
+
|
114
|
+
unvendor if options[ :no_deployment ]
|
115
|
+
|
116
|
+
vendor if options[ :deployment ]
|
117
|
+
|
118
|
+
config.verbose = ! options[ :quiet ]
|
119
|
+
|
120
|
+
Show.new( config ).show_classpath
|
121
|
+
|
122
|
+
say_bundle_complete unless options[ :quiet ]
|
123
|
+
end
|
124
|
+
|
125
|
+
desc 'update', "first `bundle update` is called and if there are no options then the jar dependencies will be updated. for more details see `bundle help update`."
|
126
|
+
method_option :debug, :type => :boolean, :default => false, :desc => 'enable maven debug output (jbundler only).'
|
127
|
+
method_option :verbose, :type => :boolean, :default => false, :desc => 'enable maven output (jbundler only).'
|
128
|
+
method_option :quiet, :type => :boolean
|
129
|
+
def update
|
130
|
+
msg = JBundler::LockDown.new( config ).update( options[ :debug ] ,
|
131
|
+
options[ :verbose ] )
|
132
|
+
|
133
|
+
config.verbose = ! options[ :quiet ]
|
134
|
+
Show.new( config ).show_classpath
|
135
|
+
unless options[ :quiet ]
|
136
|
+
puts ''
|
137
|
+
puts 'Your jbundle is updated! Use `jbundle show` to see where the bundled jars are installed.'
|
138
|
+
end
|
139
|
+
puts msg if msg
|
140
|
+
end
|
141
|
+
|
142
|
+
desc 'show', "first `bundle show` is called and if there are no options then the jar dependencies will be displayed. for more details see `bundle help show`."
|
143
|
+
def show
|
144
|
+
config.verbose = true
|
145
|
+
Show.new( config ).show_classpath
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|