jbundler 0.5.3 → 0.5.4

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.
Files changed (43) hide show
  1. data/Gemfile +4 -2
  2. data/Gemfile.lock +10 -18
  3. data/lib/jbundler/aether.rb +8 -4
  4. data/lib/jbundler/classpath_file.rb +1 -1
  5. data/lib/jbundler/cli.rb +25 -4
  6. data/lib/jbundler/config.rb +13 -5
  7. data/lib/jbundler/configurator.rb +23 -0
  8. data/lib/jbundler/executable.rb +13 -14
  9. data/lib/jbundler/executable_pom.rb +94 -133
  10. data/lib/jbundler/gemfile_lock.rb +1 -1
  11. data/lib/jbundler/lazy.rb +2 -2
  12. data/lib/jbundler/pom.rb +1 -1
  13. data/lib/jbundler/tree.rb +14 -32
  14. data/lib/jbundler/tree_pom.rb +19 -0
  15. data/lib/jbundler/vendor.rb +36 -0
  16. data/lib/jbundler.jar +0 -0
  17. data/lib/jbundler.rb +17 -7
  18. data/spec/config_spec.rb +153 -0
  19. data/spec/vendor_spec.rb +60 -0
  20. metadata +13 -31
  21. data/lib/jbundler/maven.rb +0 -27
  22. data/spec/executable_compile/Gemfile +0 -3
  23. data/spec/executable_compile/Gemfile.lock +0 -18
  24. data/spec/executable_compile/Jarfile +0 -1
  25. data/spec/executable_compile/Jarfile.lock +0 -2
  26. data/spec/executable_compile/start.rb +0 -1
  27. data/spec/executable_no_compile/Gemfile +0 -3
  28. data/spec/executable_no_compile/Gemfile.lock +0 -18
  29. data/spec/executable_no_compile/Jarfile +0 -1
  30. data/spec/executable_no_compile/Jarfile.lock +0 -2
  31. data/spec/executable_no_compile/start.rb +0 -1
  32. data/spec/executable_only_java_sources/Gemfile +0 -3
  33. data/spec/executable_only_java_sources/Gemfile.lock +0 -18
  34. data/spec/executable_only_java_sources/Jarfile +0 -3
  35. data/spec/executable_only_java_sources/Jarfile.lock +0 -2
  36. data/spec/executable_only_java_sources/start.rb +0 -6
  37. data/spec/executable_spec.rb +0 -43
  38. data/spec/tree/Gemfile +0 -3
  39. data/spec/tree/Jarfile +0 -5
  40. data/spec/tree/Jarfile.lock +0 -2
  41. data/spec/tree/myfirst.jar +0 -0
  42. data/spec/tree/ref.txt +0 -27
  43. data/spec/tree_spec.rb +0 -33
@@ -0,0 +1,36 @@
1
+ module JBundler
2
+ class Vendor
3
+
4
+ def initialize( dir )
5
+ @dir = File.expand_path( dir )
6
+ end
7
+
8
+ def vendored?
9
+ File.exists?( @dir ) && Dir[ File.join( @dir, '*' ) ].size > 0
10
+ end
11
+
12
+ def require_jars
13
+ Dir[ File.join( @dir, '*' ) ].each do |f|
14
+ require f
15
+ end
16
+ end
17
+
18
+ def clear
19
+ FileUtils.mkdir_p( @dir )
20
+ Dir[ File.join( @dir, '*' ) ].each do |f|
21
+ FileUtils.rm_f( f )
22
+ end
23
+ end
24
+
25
+ def setup( classpath_file )
26
+ classpath_file.require_classpath
27
+ FileUtils.mkdir_p( @dir )
28
+ JBUNDLER_CLASSPATH.each do |f|
29
+ FileUtils.cp( f, File.join( @dir,
30
+ File.basename( f ) ) )
31
+ end
32
+ end
33
+
34
+ end
35
+ end
36
+
data/lib/jbundler.jar CHANGED
Binary file
data/lib/jbundler.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (C) 2013 Kristian Meier
2
+ # Copyright (C) 2013 Christian Meier
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining a copy of
5
5
  # this software and associated documentation files (the "Software"), to deal in
@@ -20,6 +20,7 @@
20
20
  #
21
21
  require 'maven/tools/jarfile'
22
22
  require 'jbundler/classpath_file'
23
+ require 'jbundler/vendor'
23
24
  require 'jbundler/gemfile_lock'
24
25
  require 'jbundler/aether'
25
26
 
@@ -29,23 +30,32 @@ jarfile = Maven::Tools::Jarfile.new(config.jarfile)
29
30
  if config.skip
30
31
  warn "skip jbundler setup"
31
32
  else
33
+ vendor = JBundler::Vendor.new(config.vendor_dir)
32
34
  classpath_file = JBundler::ClasspathFile.new(config.classpath_file)
33
35
  gemfile_lock = JBundler::GemfileLock.new(jarfile, config.gemfile_lock)
34
36
 
35
- if classpath_file.needs_update?(jarfile, gemfile_lock)
37
+ if classpath_file.needs_update?(jarfile, gemfile_lock) && ! vendor.vendored?
36
38
  aether = JBundler::AetherRuby.new(config)
37
-
39
+
38
40
  jarfile.populate_unlocked(aether)
39
41
  gemfile_lock.populate_dependencies(aether)
40
42
  jarfile.populate_locked(aether)
41
-
43
+
42
44
  aether.resolve
43
-
45
+
44
46
  classpath_file.generate(aether.classpath_array)
45
47
  jarfile.generate_lockfile(aether.resolved_coordinates)
46
48
  end
47
49
 
48
- if classpath_file.exists? && jarfile.exists_lock?
50
+ if vendor.vendored?
51
+ jars = vendor.require_jars
52
+ if config.verbose
53
+ warn "jbundler classpath:"
54
+ jars.each do |path|
55
+ warn "\t#{path}"
56
+ end
57
+ end
58
+ elsif classpath_file.exists? && jarfile.exists_lock?
49
59
  require 'java'
50
60
  classpath_file.require_classpath
51
61
  if config.verbose
@@ -56,4 +66,4 @@ else
56
66
  end
57
67
  end
58
68
 
59
- end
69
+ end
@@ -0,0 +1,153 @@
1
+ load File.expand_path(File.join('spec', 'setup.rb'))
2
+ require 'jbundler/config'
3
+ require 'fileutils'
4
+
5
+ describe JBundler::Config do
6
+
7
+ before do
8
+ ENV.keys.each do |k|
9
+ ENV.delete( k ) if k.to_s.match /^(J?)BUNDLE/
10
+ end
11
+ if defined? JRUBY_VERSION
12
+ java.lang.System.properties.keys.each do |k|
13
+ java.lang.System.properties.delete( k ) if k.to_s.match /^(j?)bundle/
14
+ end
15
+ end
16
+ end
17
+
18
+ it 'has following defaults without home and without local config' do
19
+ ENV['HOME'] = '.'
20
+
21
+ FileUtils.cd( 'spec' ) do
22
+ c = JBundler::Config.new
23
+ c.verbose.must_equal nil
24
+ c.local_repository.must_equal nil
25
+ c.jarfile.must_equal 'Jarfile'
26
+ c.gemfile.must_equal 'Gemfile'
27
+ c.skip.must_equal nil
28
+ c.settings.must_equal nil
29
+ c.offline.must_equal false
30
+ c.work_dir.must_equal 'target'
31
+ c.vendor_dir.must_equal 'vendor/jars'
32
+ end
33
+ end
34
+
35
+ it 'has following defaults without home and with local config' do
36
+ ENV['HOME'] = '.'
37
+
38
+ FileUtils.cd( File.join( 'spec', 'project' ) ) do
39
+ c = JBundler::Config.new
40
+
41
+ c.verbose.must_equal true
42
+ c.local_repository.must_equal 'local'
43
+ c.jarfile.must_equal 'Jar_file'
44
+ c.gemfile.must_equal 'gemfile'
45
+ c.skip.must_equal false
46
+ c.settings.must_equal 'settings.xml'
47
+ c.offline.must_equal true
48
+ c.work_dir.must_equal 'pkg'
49
+ c.vendor_dir.must_equal 'vendor/myjars'
50
+ end
51
+ end
52
+
53
+ it 'has following defaults with home and without local config' do
54
+ ENV['HOME'] = File.join( 'home' )
55
+
56
+ FileUtils.cd( 'spec' ) do
57
+ c = JBundler::Config.new
58
+
59
+ c.verbose.must_equal false
60
+ c.local_repository.must_equal 'localrepo'
61
+ c.jarfile.must_equal 'jarfile'
62
+ c.gemfile.must_equal 'Gem_file'
63
+ c.skip.must_equal true
64
+ c.settings.must_equal 'Settings.xml'
65
+ c.offline.must_equal false
66
+ c.work_dir.must_equal 'target/pkg'
67
+ c.vendor_dir.must_equal 'vendor/my_jars'
68
+ end
69
+ end
70
+
71
+ it 'has following defaults with home and with local config' do
72
+ ENV['HOME'] = File.expand_path( File.join( 'spec', 'home' ) )
73
+
74
+ FileUtils.cd( File.join( 'spec', 'project' ) ) do
75
+ c = JBundler::Config.new
76
+
77
+ c.verbose.must_equal true
78
+ c.local_repository.must_equal 'local'
79
+ c.jarfile.must_equal 'Jar_file'
80
+ c.gemfile.must_equal 'gemfile'
81
+ c.skip.must_equal false
82
+ c.settings.must_equal 'settings.xml'
83
+ c.offline.must_equal true
84
+ c.work_dir.must_equal 'pkg'
85
+ c.vendor_dir.must_equal 'vendor/myjars'
86
+ end
87
+ end
88
+
89
+ describe 'ENV and java.lang.System.properties' do
90
+ before do
91
+ ENV[ 'JBUNDLE_VERBOSE' ] = 'true'
92
+ ENV[ 'JBUNDLE_LOCAL_REPOSITORY' ] = 'local_repository'
93
+ ENV[ 'JBUNDLE_JARFILE' ] = 'JarFile'
94
+ ENV[ 'BUNDLE_GEMFILE' ] = 'GemFile'
95
+ ENV[ 'JBUNDLE_SETTINGS' ] = 'Settings.xml'
96
+ ENV[ 'JBUNDLE_SKIP' ] = 'false'
97
+ ENV[ 'JBUNDLE_OFFLINE' ] = 'true'
98
+ ENV[ 'JBUNDLE_WORK_DIR' ] = 'pkg/work'
99
+ ENV[ 'JBUNDLE_VENDOR_DIR' ] = 'vendor/localjars'
100
+ end
101
+
102
+ [ 'spec', 'spec/home' ].each do |home|
103
+
104
+ [ 'spec', 'spec/project' ].each do |dir|
105
+
106
+ it "uses ENV with home #{home} and local dir #{dir}" do
107
+ ENV['HOME'] = eval "\"#{File.expand_path( home )}\""
108
+
109
+ FileUtils.cd eval "\"#{dir}\"" do
110
+ c = JBundler::Config.new
111
+ c.verbose.must_equal true
112
+ c.local_repository.must_equal 'local_repository'
113
+ c.jarfile.must_equal 'JarFile'
114
+ c.gemfile.must_equal 'GemFile'
115
+ c.skip.must_equal false
116
+ c.settings.must_equal 'Settings.xml'
117
+ c.offline.must_equal true
118
+ c.work_dir.must_equal 'pkg/work'
119
+ c.vendor_dir.must_equal 'vendor/localjars'
120
+ end
121
+ end
122
+
123
+ it 'uses java.lang.System.properties with home #{home} and local dir #{dir}' do
124
+ ENV['HOME'] = eval "\"#{File.expand_path( home )}\""
125
+
126
+ java.lang.System.set_property 'jbundle.verbose', 'false'
127
+ java.lang.System.set_property 'jbundle.local.repository', 'local_repo'
128
+ java.lang.System.set_property 'jbundle.jarfile', 'Jar_File'
129
+ java.lang.System.set_property 'bundle.gemfile', 'Gem_File'
130
+ java.lang.System.set_property 'jbundle.settings', 'settings.xml'
131
+ java.lang.System.set_property 'jbundle.skip', 'true'
132
+ java.lang.System.set_property 'jbundle.offline', 'false'
133
+ java.lang.System.set_property 'jbundle.work.dir', 'target/work'
134
+ java.lang.System.set_property 'jbundle.vendor.dir', 'vendor/local_jars'
135
+
136
+ FileUtils.cd eval "\"#{dir}\"" do
137
+ c = JBundler::Config.new
138
+ c.verbose.must_equal false
139
+ c.local_repository.must_equal 'local_repo'
140
+ c.jarfile.must_equal 'Jar_File'
141
+ c.gemfile.must_equal 'Gem_File'
142
+ c.skip.must_equal true
143
+ c.settings.must_equal 'settings.xml'
144
+ c.offline.must_equal false
145
+ c.work_dir.must_equal 'target/work'
146
+ c.vendor_dir.must_equal 'vendor/local_jars'
147
+ end
148
+ end
149
+ end
150
+ end
151
+ end
152
+ end
153
+
@@ -0,0 +1,60 @@
1
+ load File.expand_path(File.join('spec', 'setup.rb'))
2
+ require 'jbundler/classpath_file'
3
+ require 'jbundler/vendor'
4
+ require 'maven/tools/jarfile'
5
+ require 'jbundler/gemfile_lock'
6
+
7
+ JBUNDLER_CLASSPATH = []
8
+ describe JBundler::Vendor do
9
+
10
+ let( :workdir ) { File.join('pkg', 'tmp') }
11
+ let( :vdir ) { File.join(workdir, 'jars') }
12
+ let( :jfile ) { File.join(workdir, 'jarfile') }
13
+ let( :gfile_lock ) { File.join(workdir, 'gemfile.lock') }
14
+ let( :jfile_lock ) { jfile + ".lock"}
15
+ let( :cpfile ) { File.join(workdir, 'cp.rb') }
16
+ let( :jarfile ) { Maven::Tools::Jarfile.new(jfile) }
17
+ let( :gemfile_lock ) { JBundler::GemfileLock.new(jarfile, gfile_lock) }
18
+ let( :cp ) { JBundler::ClasspathFile.new(cpfile) }
19
+ let( :jars ) { [ '1.jar', '2.jar' ] }
20
+ subject { JBundler::Vendor.new( vdir ) }
21
+
22
+ before do
23
+ FileUtils.mkdir_p(workdir)
24
+ Dir[File.join(workdir, '*')].each { |f| FileUtils.rm_f f }
25
+ FileUtils.rm_rf(vdir)
26
+ FileUtils.mkdir_p(vdir)
27
+ jars.each do |f|
28
+ FileUtils.touch( File.join( workdir, f ) )
29
+ end
30
+ end
31
+
32
+ it 'is not vendored' do
33
+ subject.vendored?.must_equal false
34
+ subject.require_jars.size.must_equal 0
35
+ FileUtils.rm_rf( vdir )
36
+ subject.vendored?.must_equal false
37
+ end
38
+
39
+ it 'should copy jars on setup and delete them on clear' do
40
+ ::JBUNDLER_CLASSPATH.replace Dir[ File.join( workdir, "*.jar" )]
41
+ def cp.require_classpath
42
+ [ '1.jar', '2.jar' ]
43
+ end
44
+
45
+ subject.setup( cp )
46
+
47
+ j = Dir[ File.join( vdir, '*' ) ].collect do |f|
48
+ File.basename( f )
49
+ end
50
+ j.sort.must_equal jars.sort
51
+
52
+ subject.vendored?.must_equal true
53
+
54
+ subject.require_jars.size.must_equal 2
55
+
56
+ subject.clear
57
+ Dir[ File.join( vdir, '*' ) ].must_equal []
58
+ end
59
+
60
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jbundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-27 00:00:00.000000000 Z
12
+ date: 2013-12-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby-maven
@@ -17,19 +17,19 @@ dependencies:
17
17
  requirements:
18
18
  - - '>='
19
19
  - !ruby/object:Gem::Version
20
- version: 3.1.0.0.1
20
+ version: 3.1.1.0.1
21
21
  - - <
22
22
  - !ruby/object:Gem::Version
23
- version: 3.1.1
23
+ version: 3.1.2
24
24
  none: false
25
25
  requirement: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - '>='
28
28
  - !ruby/object:Gem::Version
29
- version: 3.1.0.0.1
29
+ version: 3.1.1.0.1
30
30
  - - <
31
31
  - !ruby/object:Gem::Version
32
- version: 3.1.1
32
+ version: 3.1.2
33
33
  none: false
34
34
  prerelease: false
35
35
  type: :runtime
@@ -116,42 +116,24 @@ files:
116
116
  - lib/jbundler.rb
117
117
  - lib/jbundler/aether.rb
118
118
  - lib/jbundler/classpath_file.rb
119
+ - lib/jbundler/tree_pom.rb
119
120
  - lib/jbundler/tree.rb
120
121
  - lib/jbundler/gemfile_lock.rb
121
122
  - lib/jbundler/executable_pom.rb
123
+ - lib/jbundler/configurator.rb
122
124
  - lib/jbundler/cli.rb
123
125
  - lib/jbundler/config.rb
124
126
  - lib/jbundler/pom.rb
125
- - lib/jbundler/maven.rb
126
127
  - lib/jbundler/lazy.rb
127
128
  - lib/jbundler/executable.rb
129
+ - lib/jbundler/vendor.rb
128
130
  - lib/jbundler.jar
129
- - spec/executable_spec.rb
130
- - spec/tree_spec.rb
131
+ - spec/config_spec.rb
132
+ - spec/vendor_spec.rb
131
133
  - spec/pom_spec.rb
132
134
  - spec/setup.rb
133
135
  - spec/aether_spec.rb
134
136
  - spec/classpath_file_spec.rb
135
- - spec/tree/myfirst.jar
136
- - spec/tree/Jarfile
137
- - spec/tree/Jarfile.lock
138
- - spec/tree/Gemfile
139
- - spec/tree/ref.txt
140
- - spec/executable_only_java_sources/Jarfile
141
- - spec/executable_only_java_sources/Jarfile.lock
142
- - spec/executable_only_java_sources/Gemfile.lock
143
- - spec/executable_only_java_sources/Gemfile
144
- - spec/executable_only_java_sources/start.rb
145
- - spec/executable_no_compile/Jarfile
146
- - spec/executable_no_compile/Jarfile.lock
147
- - spec/executable_no_compile/Gemfile.lock
148
- - spec/executable_no_compile/Gemfile
149
- - spec/executable_no_compile/start.rb
150
- - spec/executable_compile/Jarfile
151
- - spec/executable_compile/Jarfile.lock
152
- - spec/executable_compile/Gemfile.lock
153
- - spec/executable_compile/Gemfile
154
- - spec/executable_compile/start.rb
155
137
  - MIT-LICENSE
156
138
  - Readme.md
157
139
  - Gemfile.lock
@@ -183,8 +165,8 @@ signing_key:
183
165
  specification_version: 3
184
166
  summary: managing jar dependencies
185
167
  test_files:
186
- - spec/executable_spec.rb
187
- - spec/tree_spec.rb
168
+ - spec/config_spec.rb
169
+ - spec/vendor_spec.rb
188
170
  - spec/pom_spec.rb
189
171
  - spec/aether_spec.rb
190
172
  - spec/classpath_file_spec.rb
@@ -1,27 +0,0 @@
1
- require 'maven/ruby/maven'
2
- require 'maven/tools/visitor'
3
- module JBundler
4
- # mimic the new maven class - prepare for upgrade
5
- class MavenNG
6
-
7
- def initialize( project, temp_pom = nil )
8
- f = File.expand_path( File.join( temp_pom || '.pom.xml' ) )
9
- v = ::Maven::Tools::Visitor.new( File.open( f, 'w' ) )
10
- # parse block and write out pom4rake.xml file
11
- v.accept_project( project )
12
- # tell maven to use the generated file
13
- @rmvn = ::Maven::Ruby::Maven.new
14
- @rmvn.options[ '-f' ] = f
15
- @rmvn.options[ '-B' ] = nil
16
- end
17
-
18
- def exec( *args )
19
- @rmvn.exec_in( File.expand_path( '.' ), *args )
20
- end
21
-
22
- def method_missing( method, *args )
23
- @rmvn.exec( [ method ] + args )
24
- end
25
- end
26
- end
27
-
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'rspec', '<3.0'
@@ -1,18 +0,0 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- diff-lcs (1.2.4)
5
- rspec (2.14.1)
6
- rspec-core (~> 2.14.0)
7
- rspec-expectations (~> 2.14.0)
8
- rspec-mocks (~> 2.14.0)
9
- rspec-core (2.14.5)
10
- rspec-expectations (2.14.2)
11
- diff-lcs (>= 1.1.3, < 2.0)
12
- rspec-mocks (2.14.3)
13
-
14
- PLATFORMS
15
- java
16
-
17
- DEPENDENCIES
18
- rspec (< 3.0)
@@ -1 +0,0 @@
1
- jar 'junit:junit', '4.11'
@@ -1,2 +0,0 @@
1
- junit:junit:jar:4.11
2
- org.hamcrest:hamcrest-core:jar:1.3
@@ -1 +0,0 @@
1
- require 'app'
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'rspec', '<3.0'
@@ -1,18 +0,0 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- diff-lcs (1.2.4)
5
- rspec (2.14.1)
6
- rspec-core (~> 2.14.0)
7
- rspec-expectations (~> 2.14.0)
8
- rspec-mocks (~> 2.14.0)
9
- rspec-core (2.14.5)
10
- rspec-expectations (2.14.2)
11
- diff-lcs (>= 1.1.3, < 2.0)
12
- rspec-mocks (2.14.3)
13
-
14
- PLATFORMS
15
- java
16
-
17
- DEPENDENCIES
18
- rspec (< 3.0)
@@ -1 +0,0 @@
1
- jar 'junit:junit', '4.11'
@@ -1,2 +0,0 @@
1
- junit:junit:jar:4.11
2
- org.hamcrest:hamcrest-core:jar:1.3
@@ -1 +0,0 @@
1
- require 'app'
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'rspec', '<3.0'
@@ -1,18 +0,0 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- diff-lcs (1.2.4)
5
- rspec (2.14.1)
6
- rspec-core (~> 2.14.0)
7
- rspec-expectations (~> 2.14.0)
8
- rspec-mocks (~> 2.14.0)
9
- rspec-core (2.14.5)
10
- rspec-expectations (2.14.2)
11
- diff-lcs (>= 1.1.3, < 2.0)
12
- rspec-mocks (2.14.3)
13
-
14
- PLATFORMS
15
- java
16
-
17
- DEPENDENCIES
18
- rspec (< 3.0)
@@ -1,3 +0,0 @@
1
- # provide non https as well for travis
2
- repository 'central', 'http://repo.maven.apache.org/maven2/'
3
- jar 'junit:junit', '4.11'
@@ -1,2 +0,0 @@
1
- junit:junit:jar:4.11
2
- org.hamcrest:hamcrest-core:jar:1.3
@@ -1,6 +0,0 @@
1
- require 'java' #for jruby before 1.7.x
2
- import 'org.junit.runner.JUnitCore'
3
- import 'test.AppTest'
4
-
5
- java.lang.System.set_property( 'WORLD', 'world' )
6
- JUnitCore.run_classes( AppTest.java_class )
@@ -1,43 +0,0 @@
1
- load File.expand_path(File.join( File.dirname( __FILE__ ), 'setup.rb'))
2
- require 'jbundler/executable'
3
- require 'jbundler/config'
4
- require 'fileutils'
5
-
6
- describe JBundler::Executable do
7
-
8
- [
9
- 'executable_only_java_sources',
10
- 'executable_compile',
11
- 'executable_no_compile'
12
- ].each do |exec_dir|
13
-
14
- let( exec_dir.to_sym ) do
15
- dir = File.join( File.dirname( File.expand_path( __FILE__ ) ),
16
- exec_dir )
17
- java.lang.System.set_property( 'user.dir', dir )
18
- FileUtils.rm_rf( File.join( dir, 'target' ) )
19
- dir
20
- end
21
-
22
- it "should create #{exec_dir} jar" do
23
- skip 'rvm is not working properly' if ENV[ 'rvm_version' ]
24
- skip "jruby #{JRUBY_VERSION}" if JRUBY_VERSION < '1.6.'
25
- dir = eval "#{exec_dir}"
26
-
27
- FileUtils.chdir( dir ) do
28
- exec = JBundler::Executable.new( 'start.rb',
29
- JBundler::Config.new,
30
- File.basename( dir ) == 'executable_compile',
31
- false,
32
- :default )
33
- exec.packit
34
-
35
- `java -jar target/executable/#{exec_dir}.jar`.must_equal 'hello world'
36
-
37
- FileUtils.rm_rf( 'target' ) if ENV[ 'KEEP' ].nil?
38
- end
39
- end
40
- end
41
- end
42
-
43
- #FileUtils.rm_rf( File.join( File.expand_path( __FILE__ ).sub( /_spec.rb/, '' ), 'target' ) )
data/spec/tree/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'rspec', '<3.0'
data/spec/tree/Jarfile DELETED
@@ -1,5 +0,0 @@
1
- # provide non https as well for travis
2
- repository 'central', 'http://repo.maven.apache.org/maven2/'
3
- jar 'junit:junit', '4.11'
4
-
5
- local './myfirst.jar'
@@ -1,2 +0,0 @@
1
- junit:junit:jar:4.11
2
- org.hamcrest:hamcrest-core:jar:1.3
Binary file
data/spec/tree/ref.txt DELETED
@@ -1,27 +0,0 @@
1
- +- rubygems:rspec:gem:2.14.1:compile
2
- | +- rubygems:rspec-core:gem:2.14.5:compile (version selected from constraint [2.14.0,2.14.99999])
3
- | +- rubygems:rspec-expectations:gem:2.14.3:compile (version selected from constraint [2.14.0,2.14.99999])
4
- | | \- rubygems:diff-lcs:gem:1.2.4:compile (version selected from constraint [1.1.3,2.0))
5
- | \- rubygems:rspec-mocks:gem:2.14.3:compile (version selected from constraint [2.14.0,2.14.99999])
6
- +- org.jruby:jruby-core:jar:1.7.4:provided
7
- | +- org.jruby:jruby-stdlib:jar:1.7.4:provided
8
- | +- org.jruby.joni:joni:jar:2.0.0:provided
9
- | +- com.github.jnr:jnr-netdb:jar:1.1.2:provided
10
- | +- com.github.jnr:jnr-enxio:jar:0.4:provided
11
- | +- com.github.jnr:jnr-unixsocket:jar:0.3:provided
12
- | +- com.github.jnr:jnr-posix:jar:2.5.2:provided
13
- | +- org.jruby.extras:bytelist:jar:1.0.10:provided
14
- | +- com.github.jnr:jnr-constants:jar:0.8.4:provided
15
- | +- org.jruby.jcodings:jcodings:jar:1.0.10:provided
16
- | +- com.github.jnr:jffi:jar:1.2.5:provided
17
- | +- org.yaml:snakeyaml:jar:1.11:provided
18
- | +- jline:jline:jar:2.7:provided
19
- | +- joda-time:joda-time:jar:2.1:provided
20
- | +- com.jcraft:jzlib:jar:1.1.2:provided
21
- | +- com.headius:invokebinder:jar:1.2:provided
22
- | \- com.github.jnr:jnr-ffi:jar:1.0.4:provided
23
- | +- com.github.jnr:jffi:jar:native:1.2.7:provided (version selected from constraint [1.2.1,1.3.0))
24
- | \- com.github.jnr:jnr-x86asm:jar:1.0.2:provided (version selected from constraint [1.0.2,))
25
- +- junit:junit:jar:4.11:compile
26
- | \- org.hamcrest:hamcrest-core:jar:1.3:compile
27
- \- ruby.maven-tools.jar:myfirst:jar:0:system
data/spec/tree_spec.rb DELETED
@@ -1,33 +0,0 @@
1
- load File.expand_path(File.join( File.dirname( __FILE__ ), 'setup.rb'))
2
- require 'jbundler/tree'
3
- require 'jbundler/config'
4
- require 'stringio'
5
-
6
- describe JBundler::Tree do
7
-
8
- it 'should show dependency tree' do
9
-
10
- skip 'that spec does not execute properly with maven' if java.lang.System.get_property( 'jruby.script' ) == nil
11
-
12
- skip 'rvm is not working properly' if ENV[ 'rvm_version' ]
13
-
14
- dir = File.join( File.dirname( __FILE__ ), 'tree' )
15
- java.lang.System.set_property( 'user.dir', dir )
16
- FileUtils.cd( dir ) do
17
- exec = JBundler::Tree.new( JBundler::Config.new )
18
- output = StringIO.new
19
- $stdout = output
20
- exec.show_it( true )
21
- $stdout = STDOUT
22
- lines = output.string.split( /\n/ )
23
- lines = lines.select do |line|
24
- line =~ /:.+:.+:.+:/
25
- end
26
- lines.join( "\n" ).must_equal File.read( 'ref.txt' ).strip
27
- end
28
-
29
- end
30
-
31
- end
32
-
33
- FileUtils.rm_rf( File.join( File.expand_path( __FILE__ ).sub( /_spec.rb/, '' ), 'target' ) )