jbundler 0.7.4 → 0.8.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/Gemfile.lock~ +46 -0
- data/Readme.md +15 -103
- data/bin/jbundle +41 -60
- data/lib/jbundler/executor.rb +107 -0
- data/lib/jbundler/pom.rb +27 -145
- data/lib/jbundler.rb +5 -47
- metadata +29 -74
- data/lib/jbundler/aether.rb +0 -139
- data/lib/jbundler/classpath_file.rb +0 -115
- data/lib/jbundler/cli.rb +0 -171
- data/lib/jbundler/config.rb +0 -191
- data/lib/jbundler/configurator.rb +0 -27
- data/lib/jbundler/context.rb +0 -34
- data/lib/jbundler/dependency_pom.rb +0 -29
- data/lib/jbundler/executable.rb +0 -41
- data/lib/jbundler/executable_pom.rb +0 -105
- data/lib/jbundler/gemfile_lock.rb +0 -69
- data/lib/jbundler/jarfile_lock.rb +0 -67
- data/lib/jbundler/jruby_complete.rb +0 -44
- data/lib/jbundler/jruby_complete_pom.rb +0 -31
- data/lib/jbundler/lazy.rb +0 -102
- data/lib/jbundler/lock_down.rb +0 -166
- data/lib/jbundler/pom_runner.rb +0 -71
- data/lib/jbundler/show.rb +0 -53
- data/lib/jbundler/tree.rb +0 -31
- data/lib/jbundler/vendor.rb +0 -52
- data/lib/jbundler.jar +0 -0
- data/spec/aether_spec.rb +0 -98
- data/spec/classpath_file_spec.rb +0 -138
- data/spec/config_spec.rb +0 -180
- data/spec/pom_spec.rb +0 -30
- data/spec/project/Settings.xml +0 -0
- data/spec/project/settings.xml +0 -0
- data/spec/setup.rb +0 -16
- data/spec/vendor_spec.rb +0 -60
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ac6a9fb5c574bba0b316c3a86a7779371a334cc
|
4
|
+
data.tar.gz: 750f10fa9bb8a767a3d0b850318bf57132c9f3cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55749212e56d0cb339dc95dca63ac6c2454dfbdeb3b5f4f6105e5c5183fc5fdb0218f5e3e08cf1ba0b9255038d1fc29c3e8bce5cfeaa90568f9fb609fb4ea25c
|
7
|
+
data.tar.gz: ff954ccee92c476835a455150ab6fd84b1aebef43f61c5c153614a537c3fab882e9d32216ba2531af8423ee8a840a9e02b47fe36005c27647a1f6cb04c068b78
|
data/Gemfile.lock
CHANGED
@@ -3,8 +3,8 @@ PATH
|
|
3
3
|
specs:
|
4
4
|
jbundler (0.7.3)
|
5
5
|
bundler (~> 1.5)
|
6
|
-
jar-dependencies (~> 0.1.
|
7
|
-
maven-tools (~> 1.0.
|
6
|
+
jar-dependencies (~> 0.1.11)
|
7
|
+
maven-tools (~> 1.0.8)
|
8
8
|
ruby-maven (>= 3.1.1.0.6, < 3.1.2)
|
9
9
|
|
10
10
|
GEM
|
@@ -20,7 +20,7 @@ GEM
|
|
20
20
|
thread_safe (~> 0.3, >= 0.3.1)
|
21
21
|
equalizer (0.0.9)
|
22
22
|
ice_nine (0.11.1)
|
23
|
-
jar-dependencies (0.1.
|
23
|
+
jar-dependencies (0.1.11)
|
24
24
|
maven-tools (1.0.8)
|
25
25
|
virtus (~> 1.0)
|
26
26
|
minitest (5.5.1)
|
data/Gemfile.lock~
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
jbundler (0.7.3)
|
5
|
+
bundler (~> 1.5)
|
6
|
+
jar-dependencies (~> 0.1.8)
|
7
|
+
maven-tools (~> 1.0.6)
|
8
|
+
ruby-maven (>= 3.1.1.0.6, < 3.1.2)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
axiom-types (0.1.1)
|
14
|
+
descendants_tracker (~> 0.0.4)
|
15
|
+
ice_nine (~> 0.11.0)
|
16
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
17
|
+
coercible (1.0.0)
|
18
|
+
descendants_tracker (~> 0.0.1)
|
19
|
+
descendants_tracker (0.0.4)
|
20
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
21
|
+
equalizer (0.0.9)
|
22
|
+
ice_nine (0.11.1)
|
23
|
+
jar-dependencies (0.1.8)
|
24
|
+
maven-tools (1.0.8)
|
25
|
+
virtus (~> 1.0)
|
26
|
+
minitest (5.5.1)
|
27
|
+
rake (10.4.2)
|
28
|
+
ruby-maven (3.1.1.0.11)
|
29
|
+
maven-tools (~> 1.0.8)
|
30
|
+
ruby-maven-libs (= 3.1.1)
|
31
|
+
ruby-maven-libs (3.1.1)
|
32
|
+
thread_safe (0.3.5-java)
|
33
|
+
virtus (1.0.4)
|
34
|
+
axiom-types (~> 0.1)
|
35
|
+
coercible (~> 1.0)
|
36
|
+
descendants_tracker (~> 0.0, >= 0.0.3)
|
37
|
+
equalizer (~> 0.0, >= 0.0.9)
|
38
|
+
|
39
|
+
PLATFORMS
|
40
|
+
java
|
41
|
+
|
42
|
+
DEPENDENCIES
|
43
|
+
copyright-header (= 1.0.8)
|
44
|
+
jbundler!
|
45
|
+
minitest (~> 5.3)
|
46
|
+
rake (~> 10.0)
|
data/Readme.md
CHANGED
@@ -7,9 +7,13 @@ manage jar dependencies similar than **bundler** manages gem dependencies.
|
|
7
7
|
* the DSL mimics the one from bundler
|
8
8
|
* you can use maven like version declaration or rubygems/bundler like version ranges
|
9
9
|
* it locks down the jar versions inside "Jarfile.lock"
|
10
|
-
* you can declare jar dependency within a
|
11
|
-
|
12
|
-
|
10
|
+
* you can declare jar dependency within a gem using the requirements directive of the gem specification. jbundler will include those jar dependencies into its classpath
|
11
|
+
|
12
|
+
the difference to **bundler**
|
13
|
+
|
14
|
+
* it is just a development gem - no need for it during runtime. just add ```Jars.require_jars_lock!``` to your code and for older JRuby add ```gem 'jar-dependencies', '~> 0.1.11'``` as runtime dependency.
|
15
|
+
* you need to run ```bundle install``` first if any of the gems has jar dependencies.
|
16
|
+
* all one command ```jbundle```, see ```jbundle --help``` on the possible options and how to update a single jar, etc.
|
13
17
|
|
14
18
|
## get started
|
15
19
|
|
@@ -19,91 +23,28 @@ install JBundler with
|
|
19
23
|
|
20
24
|
first create a **Jarfile**, something like
|
21
25
|
|
22
|
-
jar 'org.yaml:snakeyaml'
|
26
|
+
jar 'org.yaml:snakeyaml', '1.14'
|
23
27
|
jar 'org.slf4j:slf4j-simple', '>1.1'
|
24
28
|
|
25
|
-
### together with Bundler
|
26
|
-
|
27
|
-
just add it as **first** entry in your *Gemfile*
|
28
|
-
|
29
|
-
```gem 'jbundler'```
|
30
|
-
|
31
|
-
and now install the bundle both **gems and jars**
|
32
|
-
|
33
|
-
jbundle install
|
34
|
-
|
35
|
-
#### Building
|
36
|
-
|
37
|
-
building the jar
|
38
|
-
```rake jar```
|
39
|
-
|
40
|
-
building the gem
|
41
|
-
```rake build```
|
42
|
-
|
43
|
-
running the junit test
|
44
|
-
```rake junit```
|
45
|
-
|
46
|
-
running the minitest
|
47
|
-
```rake minitest```
|
48
|
-
|
49
|
-
make sure you use jruby ;)
|
50
|
-
|
51
|
-
#### Gemfile and Jarfile
|
52
|
-
|
53
|
-
if there is only a **Gemfile** and no Jarfile **jbundler** handles all the declared [jar dependencies of gems](https://github.com/mkristian/jbundler/wiki/Build) as well all the jars from the Jarfile. it will only look into gems which bundler loaded.
|
54
|
-
|
55
|
-
### without Bundler - Jarfile only
|
56
|
-
|
57
|
-
requiring **jbundler** will trigger the classpath setup
|
58
|
-
|
59
|
-
```require 'jbundler'```
|
60
|
-
|
61
|
-
this you can use with **rubygems** or **isolate** or . . .
|
62
|
-
|
63
29
|
### Jarfile
|
64
30
|
|
65
31
|
more info about the **[Jarfile](https://github.com/torquebox/maven-tools/wiki/Jarfile)** and about [versions](https://github.com/torquebox/maven-tools/wiki/Versions).
|
66
32
|
|
67
33
|
for adding a maven repository see [Jarfile](https://github.com/torquebox/maven-tools/wiki/Jarfile).
|
68
|
-
|
69
|
-
## console ##
|
70
|
-
|
71
|
-
like bundler there is a console which sets up the gems (if there is Gemfile otherwise that part get skipped) and sets up the classloader:
|
72
34
|
|
73
|
-
|
35
|
+
# Building the jbundler gem
|
74
36
|
|
75
|
-
|
37
|
+
running the integration test
|
76
38
|
|
77
|
-
|
39
|
+
./mvnw verify
|
78
40
|
|
79
|
-
|
41
|
+
building the gem (see ./pkg)
|
80
42
|
|
81
|
-
|
43
|
+
./mvnw package -Dinvoker.skip
|
82
44
|
|
83
|
-
|
45
|
+
or just
|
84
46
|
|
85
|
-
|
86
|
-
|
87
|
-
require 'jbundler/lazy'
|
88
|
-
include JBundler::Lazy
|
89
|
-
|
90
|
-
will offer the same `jar`/`jars` method than you have inside the console.
|
91
|
-
|
92
|
-
# extra commands
|
93
|
-
|
94
|
-
## jbundler tree
|
95
|
-
|
96
|
-
shows the dependency tree - without the locked version. i.e. an install or update would result in the shown version.
|
97
|
-
|
98
|
-
with locked down versions that tree is more hint then a real picture of the situation !!
|
99
|
-
|
100
|
-
## jruby executable -b start.rb
|
101
|
-
|
102
|
-
will create an executable jar file using the given ruby script as bootstrap script. it will include the comple jruby and all the dependent jars as well all the gems packed into it as well. the
|
103
|
-
|
104
|
-
jruby '1.7.4'
|
105
|
-
|
106
|
-
declaration in the *Jarfile* will determinate the jruby version to use for the executable jar.
|
47
|
+
gem build jbundler.gemspec
|
107
48
|
|
108
49
|
## example ##
|
109
50
|
|
@@ -117,37 +58,8 @@ execute *src/example/my_project/info.rb* to see it in action:
|
|
117
58
|
|
118
59
|
## limitations ##
|
119
60
|
|
120
|
-
update of single artifacts is not possible.
|
121
|
-
|
122
61
|
since the version resolution happens in two steps - first the gems 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)
|
123
62
|
|
124
|
-
**Jarfile** is **not** a DSL but it could use a ruby DSL to read the data (any contribution welcome).
|
125
|
-
|
126
|
-
jbundler does not completely obey the **$HOME/.m2/settings.xml** from maven where you usually declare proxies, mirrors, etc. see [jbundler configuration](https://github.com/mkristian/jbundler/wiki/Configuration) for what is already possible.
|
127
|
-
|
128
|
-
## RVM and/or rubygems-bundler ##
|
129
|
-
|
130
|
-
some tests did not work with RVM and/or rubygems-bundler - there are some weird classloader issue popping up. there is a problem with the way the classloader gets setup. but a manual jruby installion or using rbenv is just working fine.
|
131
|
-
|
132
|
-
those issue might pop up with ```jbundle tree``` and ```jbundle executable```
|
133
|
-
|
134
|
-
## running tests ##
|
135
|
-
|
136
|
-
* ```rake``` will execute all tests without integration tests
|
137
|
-
* ```rake all``` will execute all tests
|
138
|
-
* ```rake minitest``` runs the minitest specs
|
139
|
-
* ```rake integration``` runs the integration tests where poms are used (might fail due to hardcoded absolute paths)
|
140
|
-
* ```rake junit``` runs the junit java tests
|
141
|
-
* ```jruby spec/abc_spec.rb``` runs that given tests (just use the right file)
|
142
|
-
* ```mvn test``` will also run all tests
|
143
|
-
* ```rmvn test`` same as ```mvn test```
|
144
|
-
|
145
|
-
## update ##
|
146
|
-
|
147
|
-
update of a single artifact is not possible (yet). but to update the whole set of artifacts just delete the lockfile *Jarfile.lock*
|
148
|
-
|
149
|
-
if jbundler sees that **Gemfile.lock** or **Jarfile** is newer then the **.jbundler/classpath.rb** file then jbundler tries to gracefully upgrade towards the changes.
|
150
|
-
|
151
63
|
# special thanks #
|
152
64
|
|
153
65
|
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 no much left of the original code but many thanks to [ANithian](https://github.com/ANithian) for given the seed of that project.
|
data/bin/jbundle
CHANGED
@@ -1,70 +1,51 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
2
|
+
require 'jbundler'
|
3
|
+
require 'optparse'
|
4
|
+
options = {}
|
5
|
+
optparse = OptionParser.new do|opts|
|
6
|
+
|
7
|
+
opts.banner = "Usage: jbundle [options]"
|
8
|
+
|
9
|
+
opts.separator ''
|
10
|
+
opts.separator '* load jars: `Jars.require_jars_lock!`'
|
11
|
+
opts.separator '* classpath features: see `Jars::Classpath'
|
12
|
+
opts.separator ''
|
13
|
+
opts.separator 'NOTE: JBundler is not need during runtime !'
|
14
|
+
opts.separator ''
|
15
|
+
opts.separator 'Options:'
|
16
|
+
opts.separator ''
|
17
|
+
|
18
|
+
opts.on( '-v', '--verbose', 'Output more information' ) do |t|
|
19
|
+
options[:verbose] = t
|
15
20
|
end
|
16
21
|
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
22
|
+
opts.on( '-d', '--debug', 'Output debug information' ) do |t|
|
23
|
+
options[:debug] = t
|
24
|
+
end
|
33
25
|
|
34
|
-
|
26
|
+
opts.on( '-f', '--force', 'Force creation of Jars.lock' ) do |t|
|
27
|
+
options[:force] = t
|
28
|
+
end
|
35
29
|
|
36
|
-
|
37
|
-
|
30
|
+
opts.on( '-t', '--tree', 'Show dependency tree' ) do |t|
|
31
|
+
options[:tree] = t
|
32
|
+
end
|
38
33
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
ARGV.delete( '--skip-vendor' )
|
43
|
-
ARGV.delete( '--skip-debug' )
|
44
|
-
ARGV.delete( '--skip-verbose' )
|
45
|
-
|
46
|
-
# HACK get the module-class hierachy in place
|
47
|
-
gem 'bundler'
|
48
|
-
if Gem.loaded_specs['bundler'].version >= Gem::Version.new('1.9.0')
|
49
|
-
module Bundler
|
50
|
-
class Thor
|
51
|
-
module Actions
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
load Gem.bin_path('bundler', 'bundle')
|
57
|
-
|
58
|
-
ARGV.insert( 0, 'lock_down' ) if is_lock_down
|
59
|
-
ARGV.insert( 1, '--debug' ) if is_debug
|
60
|
-
ARGV.insert( 1, '--vendor' ) if is_vendor
|
61
|
-
end
|
34
|
+
opts.on( '-u', '--update JAR_COORDINATE', 'Resolves given dependency and use latest version' ) do |u|
|
35
|
+
options[:update] = u
|
36
|
+
end
|
62
37
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
require 'jbundler/cli'
|
67
|
-
JBundler::Cli.start
|
38
|
+
opts.on( '--vendor-dir DIRECTORY', 'Vendor directory where to copy the installed jars.', 'add this directory to $LOAD_PATH or set JARS_HOME respectively.' ) do |dir|
|
39
|
+
options[:vendor_dir] = dir
|
68
40
|
end
|
69
41
|
|
42
|
+
opts.on( '-h', '--help', 'Display this screen' ) do
|
43
|
+
puts opts
|
44
|
+
exit
|
45
|
+
end
|
70
46
|
end
|
47
|
+
optparse.parse!
|
48
|
+
|
49
|
+
require 'jbundler/executor'
|
50
|
+
mvn = JBundler::Executor.new( options[:debug], options[:verbose] )
|
51
|
+
mvn.lock_down( options )
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'maven/ruby/maven'
|
2
|
+
require 'maven/tools/artifact'
|
3
|
+
require 'maven/tools/gemspec_dependencies'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'jar_dependencies'
|
6
|
+
module JBundler
|
7
|
+
|
8
|
+
class Executor
|
9
|
+
|
10
|
+
attr_reader :debug, :verbose
|
11
|
+
|
12
|
+
def initialize( debug = false, verbose = false )
|
13
|
+
@debug = debug
|
14
|
+
@verbose = verbose
|
15
|
+
end
|
16
|
+
|
17
|
+
def maven_new
|
18
|
+
m = Maven::Ruby::Maven.new
|
19
|
+
m.property( 'jbundler.basedir', File.expand_path( basedir ) )
|
20
|
+
m.property( 'jbundler.jarfile', File.expand_path( JBundler.jarfile ) )
|
21
|
+
m.property( 'verbose', (debug || verbose) == true )
|
22
|
+
if debug
|
23
|
+
m.options[ '-X' ] = nil
|
24
|
+
elsif verbose
|
25
|
+
m.options[ '-e' ] = nil
|
26
|
+
else
|
27
|
+
m.options[ '-q' ] = nil
|
28
|
+
end
|
29
|
+
m.verbose = debug
|
30
|
+
attach_jar_coordinates( m )
|
31
|
+
m
|
32
|
+
end
|
33
|
+
private :maven_new
|
34
|
+
|
35
|
+
def maven
|
36
|
+
@maven ||= maven_new
|
37
|
+
end
|
38
|
+
|
39
|
+
def basedir
|
40
|
+
File.expand_path( '.' )
|
41
|
+
end
|
42
|
+
|
43
|
+
def exec( *args )
|
44
|
+
maven.options[ '-f' ] = File.expand_path( '../pom.rb', __FILE__ )
|
45
|
+
maven.exec( *args )
|
46
|
+
end
|
47
|
+
|
48
|
+
def attach_jar_coordinates( maven )
|
49
|
+
load_path = $LOAD_PATH.dup
|
50
|
+
require 'bundler/setup'
|
51
|
+
done = []
|
52
|
+
index = 0
|
53
|
+
Gem.loaded_specs.each do |name, spec|
|
54
|
+
# TODO get rid of this somehow
|
55
|
+
deps = Maven::Tools::GemspecDependencies.new( spec )
|
56
|
+
deps.java_dependency_artifacts.each do |a|
|
57
|
+
unless done.include? a.key
|
58
|
+
maven.property( "jbundler.jars.#{index}", a.to_s )
|
59
|
+
index += 1
|
60
|
+
done << a.key
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
rescue LoadError
|
65
|
+
warn "no bundler found - ignore Gemfile if exists"
|
66
|
+
ensure
|
67
|
+
$LOAD_PATH.replace( load_path )
|
68
|
+
end
|
69
|
+
|
70
|
+
def lock_down( options = {} )
|
71
|
+
vendor_dir = File.expand_path( options[ :vendor_dir ] ) if options[ :vendor_dir ]
|
72
|
+
out = File.expand_path( '.jbundler.output' )
|
73
|
+
tree = File.expand_path( '.jbundler.tree' )
|
74
|
+
maven.property( 'jars.outputFile', out )
|
75
|
+
maven.property( 'maven.repo.local', Jars.home )
|
76
|
+
maven.property( 'jars.home', vendor_dir ) if vendor_dir
|
77
|
+
# TODO move into jar-dependencies
|
78
|
+
maven.property( 'jars.lock', File.expand_path( Jars.lock ) )
|
79
|
+
maven.property( 'jars.force', options[ :force ] == true )
|
80
|
+
maven.property( 'jars.update', options[ :update ] ) if options[ :update ]
|
81
|
+
|
82
|
+
args = [ 'gem:jars-lock' ]
|
83
|
+
if options[ :tree ]
|
84
|
+
args += [ 'dependency:tree', '-P -gemfile.lock', '-DoutputFile=' + tree ]
|
85
|
+
end
|
86
|
+
|
87
|
+
puts
|
88
|
+
puts '-- jar root dependencies --'
|
89
|
+
puts
|
90
|
+
status = exec( *args )
|
91
|
+
exit 1 unless status
|
92
|
+
if File.exists?( tree )
|
93
|
+
puts
|
94
|
+
puts '-- jar dependency tree --'
|
95
|
+
puts
|
96
|
+
puts File.read( tree )
|
97
|
+
puts
|
98
|
+
end
|
99
|
+
puts
|
100
|
+
puts File.read( out ).gsub( /#{File.dirname(out)}\//, '' )
|
101
|
+
puts
|
102
|
+
ensure
|
103
|
+
FileUtils.rm_f out
|
104
|
+
FileUtils.rm_f tree
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
data/lib/jbundler/pom.rb
CHANGED
@@ -1,153 +1,35 @@
|
|
1
|
-
|
2
|
-
|
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 'fileutils'
|
22
|
-
require 'tempfile'
|
23
|
-
require 'maven/tools/coordinate'
|
24
|
-
require 'securerandom'
|
1
|
+
bdir = java.lang.System.getProperty( "jbundler.basedir" )
|
2
|
+
jfile = java.lang.System.getProperty( "jbundler.jarfile" )
|
25
3
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def temp_dir
|
35
|
-
@temp_dir ||=
|
36
|
-
begin
|
37
|
-
# on travis the mktmpdir failed
|
38
|
-
d = Dir.mktmpdir rescue FileUtils.mkdir( ".tmp" + SecureRandom.hex( 12) ).first
|
39
|
-
at_exit { FileUtils.rm_rf(d.dup) }
|
40
|
-
# for jruby-1.7.4 1.8 mode add expand_path
|
41
|
-
File.expand_path( d )
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def writeElement(xmlWriter,element_name, text)
|
46
|
-
xmlWriter.writeStartElement(element_name.to_java)
|
47
|
-
xmlWriter.writeCharacters(text.to_java)
|
48
|
-
xmlWriter.writeEndElement
|
49
|
-
end
|
50
|
-
|
51
|
-
def java_imports
|
52
|
-
%w(
|
53
|
-
javax.xml.stream.XMLStreamWriter
|
54
|
-
javax.xml.stream.XMLOutputFactory
|
55
|
-
javax.xml.stream.XMLStreamException
|
56
|
-
).each {|i| java_import i }
|
57
|
-
end
|
58
|
-
|
59
|
-
GROUP_ID = 'ruby.bundler'
|
60
|
-
|
61
|
-
def start_write_pom( out, name, version, packaging )
|
62
|
-
outputFactory = XMLOutputFactory.newFactory()
|
63
|
-
xmlStreamWriter = outputFactory.createXMLStreamWriter( out )
|
64
|
-
|
65
|
-
xmlStreamWriter.writeStartDocument
|
66
|
-
xmlStreamWriter.writeStartElement("project")
|
67
|
-
|
68
|
-
writeElement(xmlStreamWriter,"modelVersion","4.0.0")
|
69
|
-
writeElement(xmlStreamWriter,"groupId", GROUP_ID)
|
70
|
-
writeElement(xmlStreamWriter,"artifactId", name)
|
71
|
-
writeElement(xmlStreamWriter,"version", version.to_s.to_java)
|
72
|
-
writeElement(xmlStreamWriter,"packaging", packaging) if packaging
|
73
|
-
xmlStreamWriter
|
74
|
-
end
|
75
|
-
|
76
|
-
def to_classifier_version( coords )
|
77
|
-
if coords.size == 4
|
78
|
-
[ nil, coords[3] ]
|
79
|
-
else
|
80
|
-
[ coords[3], coords[4] ]
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def write_dep( xmlStreamWriter, coord )
|
85
|
-
coords = coord.split(/:/)
|
86
|
-
group_id = coords[0]
|
87
|
-
artifact_id = coords[1]
|
88
|
-
extension = coords[2]
|
89
|
-
classifier, version = to_classifier_version( coords )
|
90
|
-
|
91
|
-
xmlStreamWriter.writeStartElement("dependency".to_java)
|
92
|
-
writeElement(xmlStreamWriter,"groupId", group_id)
|
93
|
-
writeElement(xmlStreamWriter,"artifactId", artifact_id)
|
94
|
-
writeElement(xmlStreamWriter,"version", version)
|
95
|
-
|
96
|
-
writeElement(xmlStreamWriter,"type", extension) if extension != 'jar'
|
97
|
-
writeElement(xmlStreamWriter,"classifier", classifier) if classifier
|
98
|
-
xmlStreamWriter.writeEndElement #dependency
|
99
|
-
end
|
100
|
-
|
101
|
-
def write_dependencies( xmlStreamWriter, deps )
|
102
|
-
xmlStreamWriter.writeStartElement("dependencies".to_java)
|
103
|
-
|
104
|
-
deps.each do |line|
|
105
|
-
coord = to_coordinate(line)
|
106
|
-
write_dep( xmlStreamWriter, coord ) if coord
|
107
|
-
end
|
108
|
-
|
109
|
-
xmlStreamWriter.writeEndElement #dependencies
|
110
|
-
end
|
111
|
-
|
112
|
-
def end_write_pom( xmlStreamWriter )
|
113
|
-
xmlStreamWriter.writeEndElement #project
|
114
|
-
|
115
|
-
xmlStreamWriter.writeEndDocument
|
116
|
-
xmlStreamWriter.close
|
117
|
-
end
|
118
|
-
|
119
|
-
public
|
120
|
-
|
121
|
-
def coordinate
|
122
|
-
@coord ||= "#{GROUP_ID}:#{@name}:#{@packaging}:#{@version}"
|
123
|
-
end
|
124
|
-
|
125
|
-
def file
|
126
|
-
@file
|
127
|
-
end
|
4
|
+
basedir( bdir )
|
5
|
+
if basedir != bdir
|
6
|
+
# older maven-tools needs this
|
7
|
+
self.instance_variable_set( :@basedir, bdir )
|
8
|
+
end
|
128
9
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
10
|
+
( 0..10000 ).each do |i|
|
11
|
+
coord = java.lang.System.getProperty( "jbundler.jars.#{i}" )
|
12
|
+
break unless coord
|
13
|
+
artifact = Maven::Tools::Artifact.from_coordinate( coord.to_s )
|
14
|
+
# HACK around broken maven-tools
|
15
|
+
if artifact.exclusions
|
16
|
+
ex = artifact.classifier[1..-1] + ':' + artifact.exclusions.join(':')
|
17
|
+
artifact.classifier = nil
|
18
|
+
artifact.exclusions = ex.split /,/
|
19
|
+
end
|
20
|
+
dependency_artifact( artifact )
|
21
|
+
end
|
133
22
|
|
134
|
-
|
135
|
-
@packaging = packaging || 'jar'
|
136
|
-
@version = version
|
23
|
+
jarfile( jfile )
|
137
24
|
|
138
|
-
|
25
|
+
properties( 'project.build.sourceEncoding' => 'utf-8' )
|
139
26
|
|
140
|
-
|
27
|
+
plugin_repository :id => 'sonatype-snapshots', :url => 'https://oss.sonatype.org/content/repositories/snapshots'
|
28
|
+
jruby_plugin :gem, '1.0.10-SNAPSHOT'
|
141
29
|
|
142
|
-
|
143
|
-
|
144
|
-
write_dependencies( xmlStreamWriter, deps )
|
30
|
+
plugin :dependency, '2.8'
|
145
31
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
out.close
|
150
|
-
end
|
151
|
-
|
152
|
-
end
|
32
|
+
# some output
|
33
|
+
model.dependencies.each do |d|
|
34
|
+
puts " " + d.group_id + ':' + d.artifact_id + (d.classifier ? ":" + d.classifier : "" ) + ":" + d.version + ':' + (d.scope || 'compile')
|
153
35
|
end
|