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
data/lib/jbundler/lazy.rb
DELETED
@@ -1,102 +0,0 @@
|
|
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 'jbundler/aether'
|
22
|
-
require 'maven/tools/coordinate'
|
23
|
-
module JBundler
|
24
|
-
module Lazy
|
25
|
-
|
26
|
-
include Maven::Tools::Coordinate
|
27
|
-
|
28
|
-
def self.included(clazz)
|
29
|
-
begin
|
30
|
-
require 'java'
|
31
|
-
warn ''
|
32
|
-
warn 'lazy jar loading does NOT garantee the consistency of the classloader.'
|
33
|
-
warn 'duplicated jars with different version and other dependency conflicts can easily occur.'
|
34
|
-
warn ''
|
35
|
-
warn 'add new jars with:'
|
36
|
-
warn ''
|
37
|
-
warn "\tjar 'org.yaml:snakeyaml'"
|
38
|
-
warn "\tjar 'org.slf4j:slf4j-simple', '>1.1'"
|
39
|
-
warn ''
|
40
|
-
warn 'show loaded jars with:'
|
41
|
-
warn "\tjars"
|
42
|
-
warn ''
|
43
|
-
rescue LoadError
|
44
|
-
warn 'no jar support possible without JRuby - just launching an IRB session'
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def jars
|
49
|
-
if jb_classpath.empty?
|
50
|
-
puts "\tno jars loaded via jbundler"
|
51
|
-
else
|
52
|
-
jb_classpath.each do |path|
|
53
|
-
puts "\t#{path}"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
nil
|
57
|
-
end
|
58
|
-
|
59
|
-
def jar(name, *version)
|
60
|
-
unless defined? JRUBY_VERSION
|
61
|
-
warn 'no jar support possible without JRuby'
|
62
|
-
return
|
63
|
-
end
|
64
|
-
aether.add_artifact("#{name}:#{to_version(*version)}")
|
65
|
-
aether.resolve
|
66
|
-
result = false
|
67
|
-
aether.classpath_array.each do |path|
|
68
|
-
if result ||= (require path)
|
69
|
-
warn "added #{path} to classloader"
|
70
|
-
jb_classpath << path
|
71
|
-
else
|
72
|
-
warn "already loaded: #{path}"
|
73
|
-
end
|
74
|
-
end
|
75
|
-
result
|
76
|
-
end
|
77
|
-
|
78
|
-
private
|
79
|
-
|
80
|
-
def jb_classpath
|
81
|
-
@jb_cp ||= defined?(JBUNDLER_CLASSPATH) ? JBUNDLER_CLASSPATH.dup : []
|
82
|
-
end
|
83
|
-
|
84
|
-
def jb_config
|
85
|
-
@_jb_c ||= JBundler::Config.new
|
86
|
-
end
|
87
|
-
|
88
|
-
def aether
|
89
|
-
@_aether ||=
|
90
|
-
begin
|
91
|
-
aether = JBundler::AetherRuby.new(jb_config)
|
92
|
-
jarfile = Maven::Tools::Jarfile.new(jb_config.jarfile)
|
93
|
-
gemfile_lock = JBundler::GemfileLock.new(jarfile,
|
94
|
-
jb_config.gemfile_lock)
|
95
|
-
jarfile.populate_unlocked(aether)
|
96
|
-
gemfile_lock.populate_dependencies(aether) if gemfile_lock.exists?
|
97
|
-
jarfile.populate_locked(aether)
|
98
|
-
aether
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
data/lib/jbundler/lock_down.rb
DELETED
@@ -1,166 +0,0 @@
|
|
1
|
-
require 'jbundler/configurator'
|
2
|
-
require 'jbundler/classpath_file'
|
3
|
-
require 'jbundler/vendor'
|
4
|
-
require 'jbundler/gemfile_lock'
|
5
|
-
require 'jbundler/show'
|
6
|
-
require 'maven/tools/gemspec_dependencies'
|
7
|
-
require 'maven/tools/jarfile'
|
8
|
-
require 'maven/ruby/maven'
|
9
|
-
require 'fileutils'
|
10
|
-
require 'jar_installer'
|
11
|
-
|
12
|
-
module JBundler
|
13
|
-
class LockDown
|
14
|
-
|
15
|
-
def initialize( config )
|
16
|
-
@config = config
|
17
|
-
@configurator = Configurator.new( config )
|
18
|
-
end
|
19
|
-
|
20
|
-
def vendor
|
21
|
-
@vendor ||= JBundler::Vendor.new( @config.vendor_dir )
|
22
|
-
end
|
23
|
-
|
24
|
-
def update( debug = false, verbose = false )
|
25
|
-
if vendor.vendored?
|
26
|
-
raise 'can not update vendored jars'
|
27
|
-
end
|
28
|
-
|
29
|
-
FileUtils.rm_f( @config.jarfile_lock )
|
30
|
-
|
31
|
-
lock_down( false, debug, verbose )
|
32
|
-
end
|
33
|
-
|
34
|
-
def lock_down( needs_vendor = false, debug = false, verbose = false )
|
35
|
-
jarfile = Maven::Tools::Jarfile.new( @config.jarfile )
|
36
|
-
classpath = JBundler::ClasspathFile.new( @config.classpath_file )
|
37
|
-
if jarfile.exists_lock? && classpath.exists?
|
38
|
-
needs_update = false
|
39
|
-
else
|
40
|
-
needs_update = needs_update?( jarfile, classpath )
|
41
|
-
end
|
42
|
-
if ( ! needs_update && ! needs_vendor ) || vendor.vendored?
|
43
|
-
|
44
|
-
puts 'Jar dependencies are up to date !'
|
45
|
-
|
46
|
-
if needs_update?( jarfile, classpath )
|
47
|
-
f = classpath.file.sub(/#{Dir.pwd}#{File::SEPARATOR}/, '' )
|
48
|
-
"the #{f} is stale, i.e. Gemfile or Jarfile is newer. `jbundle update` will update it"
|
49
|
-
end
|
50
|
-
else
|
51
|
-
|
52
|
-
puts '...'
|
53
|
-
|
54
|
-
deps = install_dependencies( debug, verbose, jarfile.exists_lock? )
|
55
|
-
|
56
|
-
update_files( classpath, collect_jars( deps ) ) if needs_update
|
57
|
-
|
58
|
-
vendor_it( vendor, deps ) if needs_vendor
|
59
|
-
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
private
|
64
|
-
|
65
|
-
def needs_update?( jarfile, classpath )
|
66
|
-
gemfile_lock = JBundler::GemfileLock.new( jarfile,
|
67
|
-
@config.gemfile_lock )
|
68
|
-
classpath.needs_update?( jarfile, gemfile_lock )
|
69
|
-
end
|
70
|
-
|
71
|
-
def vendor_it( vendor, deps )
|
72
|
-
puts "vendor directory: #{@config.vendor_dir}"
|
73
|
-
vendor.vendor_dependencies( deps )
|
74
|
-
puts
|
75
|
-
end
|
76
|
-
|
77
|
-
def collect_jars( deps )
|
78
|
-
jars = {}
|
79
|
-
deps.each do |d|
|
80
|
-
case d.scope
|
81
|
-
when :provided
|
82
|
-
( jars[ :jruby ] ||= [] ) << d
|
83
|
-
when :test
|
84
|
-
( jars[ :test ] ||= [] ) << d
|
85
|
-
else
|
86
|
-
( jars[ :runtime ] ||= [] ) << d
|
87
|
-
end
|
88
|
-
end
|
89
|
-
jars
|
90
|
-
end
|
91
|
-
|
92
|
-
def update_files( classpath_file, jars )
|
93
|
-
if jars.values.flatten.size == 0
|
94
|
-
FileUtils.rm_f @config.jarfile_lock
|
95
|
-
else
|
96
|
-
lock = Maven::Tools::DSL::JarfileLock.new( @config.jarfile )
|
97
|
-
lock.replace( jars )
|
98
|
-
lock.dump
|
99
|
-
end
|
100
|
-
classpath_file.generate( (jars[ :runtime ] || []).collect { |j| j.file },
|
101
|
-
(jars[ :test ] || []).collect { |j| j.file },
|
102
|
-
(jars[ :jruby ] || []).collect { |j| j.file },
|
103
|
-
@config.local_repository )
|
104
|
-
end
|
105
|
-
|
106
|
-
def install_dependencies( debug, verbose, exclude_transitive = false )
|
107
|
-
deps_file = File.join( File.expand_path( @config.work_dir ),
|
108
|
-
'dependencies.txt' )
|
109
|
-
|
110
|
-
exec_maven( debug, verbose, deps_file, exclude_transitive )
|
111
|
-
|
112
|
-
result = []
|
113
|
-
File.read( deps_file ).each_line do |line|
|
114
|
-
dep = Jars::JarInstaller::Dependency.new( line )
|
115
|
-
result << dep if dep
|
116
|
-
end
|
117
|
-
result
|
118
|
-
ensure
|
119
|
-
FileUtils.rm_f( deps_file ) if deps_file
|
120
|
-
end
|
121
|
-
|
122
|
-
def exec_maven( debug, verbose, output, exclude_transitive = false )
|
123
|
-
m = Maven::Ruby::Maven.new
|
124
|
-
m.options[ '-f' ] = File.join( File.dirname( __FILE__ ),
|
125
|
-
'dependency_pom.rb' )
|
126
|
-
m.property( 'verbose', debug || verbose )
|
127
|
-
m.options[ '-q' ] = nil if !debug and !verbose
|
128
|
-
m.options[ '-e' ] = nil if !debug and verbose
|
129
|
-
m.options[ '-X' ] = nil if debug
|
130
|
-
m.options[ '-DexcludeTransitive' ] = exclude_transitive
|
131
|
-
m.verbose = debug
|
132
|
-
m.property( 'jbundler.outputFile', output )
|
133
|
-
|
134
|
-
@configurator.configure( m )
|
135
|
-
|
136
|
-
attach_jar_coordinates( m )
|
137
|
-
|
138
|
-
m.exec( 'dependency:list' )
|
139
|
-
end
|
140
|
-
|
141
|
-
private
|
142
|
-
|
143
|
-
def attach_jar_coordinates( maven )
|
144
|
-
load_path = $LOAD_PATH.dup
|
145
|
-
require 'bundler/setup'
|
146
|
-
done = []
|
147
|
-
index = 0
|
148
|
-
Gem.loaded_specs.each do |name, spec|
|
149
|
-
# TODO get rid of this somehow
|
150
|
-
deps = Maven::Tools::GemspecDependencies.new( spec )
|
151
|
-
deps.java_dependency_artifacts.each do |a|
|
152
|
-
unless done.include? a.key
|
153
|
-
maven.property( "jbundler.jars.#{index}", a.to_s )
|
154
|
-
index += 1
|
155
|
-
done << a.key
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
if index > 0
|
160
|
-
maven.property( "jbundler.jars.size", index )
|
161
|
-
end
|
162
|
-
ensure
|
163
|
-
$LOAD_PATH.replace( load_path )
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
data/lib/jbundler/pom_runner.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
require 'maven/ruby/maven'
|
2
|
-
module JBundler
|
3
|
-
|
4
|
-
class PomRunner
|
5
|
-
|
6
|
-
def initialize( config )
|
7
|
-
@config = config
|
8
|
-
end
|
9
|
-
|
10
|
-
def method_missing( m, *args )
|
11
|
-
result = @config[ m ] || @config[ m.to_s ]
|
12
|
-
result.nil? ? super : result
|
13
|
-
end
|
14
|
-
|
15
|
-
def maven_new
|
16
|
-
m = Maven::Ruby::Maven.new
|
17
|
-
m.property( 'base.dir', File.expand_path( basedir ) )
|
18
|
-
m.property( 'work.dir', File.expand_path( workdir ) ) if workdir
|
19
|
-
m.property( 'verbose', debug || verbose )
|
20
|
-
if debug
|
21
|
-
m.options[ '-X' ] = nil
|
22
|
-
elsif verbose
|
23
|
-
m.options[ '-e' ] = nil
|
24
|
-
else
|
25
|
-
m.options[ '-q' ] = nil
|
26
|
-
end
|
27
|
-
m.verbose = debug
|
28
|
-
m
|
29
|
-
end
|
30
|
-
private :maven_new
|
31
|
-
|
32
|
-
def maven
|
33
|
-
@m ||= maven_new
|
34
|
-
end
|
35
|
-
|
36
|
-
def basedir
|
37
|
-
File.expand_path( '.' )
|
38
|
-
end
|
39
|
-
|
40
|
-
def workdir
|
41
|
-
@config[ 'workdir' ]
|
42
|
-
end
|
43
|
-
|
44
|
-
def work_dir
|
45
|
-
# needs default here
|
46
|
-
workdir || 'pkg'
|
47
|
-
end
|
48
|
-
|
49
|
-
def debug
|
50
|
-
@config[ 'debug' ] || false
|
51
|
-
end
|
52
|
-
|
53
|
-
def verbose
|
54
|
-
@config[ 'verbose' ] || false
|
55
|
-
end
|
56
|
-
|
57
|
-
def clean?
|
58
|
-
@config[ 'clean' ] || false
|
59
|
-
end
|
60
|
-
|
61
|
-
def pom_file
|
62
|
-
raise 'overwrite this method'
|
63
|
-
end
|
64
|
-
|
65
|
-
def exec( *args )
|
66
|
-
maven.options[ '-f' ] ||= pom_file
|
67
|
-
args.unshift :clean if clean?
|
68
|
-
maven.exec( *args )
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
data/lib/jbundler/show.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'jbundler/configurator'
|
2
|
-
require 'jbundler/classpath_file'
|
3
|
-
require 'jbundler/vendor'
|
4
|
-
require 'jbundler/gemfile_lock'
|
5
|
-
require 'maven/tools/jarfile'
|
6
|
-
require 'maven/ruby/maven'
|
7
|
-
require 'fileutils'
|
8
|
-
module JBundler
|
9
|
-
class Show
|
10
|
-
|
11
|
-
def initialize( config )
|
12
|
-
@config = config
|
13
|
-
@classpath_file = JBundler::ClasspathFile.new( @config.classpath_file )
|
14
|
-
end
|
15
|
-
|
16
|
-
def show_classpath
|
17
|
-
return if ! @config.verbose
|
18
|
-
vendor = JBundler::Vendor.new(@config.vendor_dir)
|
19
|
-
if vendor.vendored?
|
20
|
-
vendor.require_jars
|
21
|
-
warn "complete classpath:"
|
22
|
-
$CLASSPATH.each do |path|
|
23
|
-
warn "\t#{path}"
|
24
|
-
end
|
25
|
-
else
|
26
|
-
@classpath_file.load_classpath
|
27
|
-
warn ''
|
28
|
-
warn 'jbundler provided classpath:'
|
29
|
-
warn '----------------'
|
30
|
-
JBUNDLER_JRUBY_CLASSPATH.each do |path|
|
31
|
-
warn "#{path}"
|
32
|
-
end
|
33
|
-
warn ''
|
34
|
-
warn 'jbundler runtime classpath:'
|
35
|
-
warn '---------------------------'
|
36
|
-
JBUNDLER_CLASSPATH.each do |path|
|
37
|
-
warn "#{path}"
|
38
|
-
end
|
39
|
-
warn ''
|
40
|
-
warn 'jbundler test classpath:'
|
41
|
-
warn '------------------------'
|
42
|
-
if JBUNDLER_TEST_CLASSPATH.empty?
|
43
|
-
warn "\t--- empty ---"
|
44
|
-
else
|
45
|
-
JBUNDLER_TEST_CLASSPATH.each do |path|
|
46
|
-
warn "#{path}"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
warn ''
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
data/lib/jbundler/tree.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'jbundler/configurator'
|
2
|
-
require 'maven/ruby/maven'
|
3
|
-
require 'fileutils'
|
4
|
-
module JBundler
|
5
|
-
class Tree
|
6
|
-
|
7
|
-
def initialize( config )
|
8
|
-
@config = Configurator.new( config )
|
9
|
-
end
|
10
|
-
|
11
|
-
def show_it( debug = false )
|
12
|
-
m = Maven::Ruby::Maven.new
|
13
|
-
m.options[ '-f' ] = File.join( File.dirname( __FILE__ ),
|
14
|
-
'dependency_pom.rb' )
|
15
|
-
m.options[ '-q' ] = nil unless debug
|
16
|
-
m.verbose = debug
|
17
|
-
|
18
|
-
@config.configure( m )
|
19
|
-
|
20
|
-
puts '...'
|
21
|
-
|
22
|
-
tree = File.join( File.expand_path( @config.work_dir ),
|
23
|
-
'tree.txt' )
|
24
|
-
m.property( 'jbundler.outputFile', tree )
|
25
|
-
|
26
|
-
m.exec( 'dependency:tree' )
|
27
|
-
|
28
|
-
puts File.read( tree )
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/lib/jbundler/vendor.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'jar_installer'
|
2
|
-
module JBundler
|
3
|
-
class Vendor
|
4
|
-
|
5
|
-
def initialize( dir )
|
6
|
-
@dir = File.expand_path( dir )
|
7
|
-
end
|
8
|
-
|
9
|
-
def vendored?
|
10
|
-
File.exists?( @dir ) && Dir[ File.join( @dir, '*' ) ].size > 0
|
11
|
-
end
|
12
|
-
|
13
|
-
def require_jars
|
14
|
-
jars = File.join( @dir, 'jbundler.rb' )
|
15
|
-
if File.exists?( jars )
|
16
|
-
$LOAD_PATH << @dir unless $LOAD_PATH.include? @dir
|
17
|
-
require jars
|
18
|
-
else
|
19
|
-
Dir[ File.join( @dir, '**', '*' ) ].each do |f|
|
20
|
-
require f
|
21
|
-
end
|
22
|
-
Jars.freeze_loading
|
23
|
-
true
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def clear
|
28
|
-
FileUtils.mkdir_p( @dir )
|
29
|
-
Dir[ File.join( @dir, '*' ) ].each do |f|
|
30
|
-
FileUtils.rm_rf( f )
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def vendor_dependencies( deps )
|
35
|
-
require_file = File.join( @dir, 'jbundler.rb' )
|
36
|
-
Jars::JarInstaller.install_deps( deps, @dir, require_file, true ) do |f|
|
37
|
-
f.puts
|
38
|
-
f.puts 'Jars.freeze_loading'
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def setup( classpath_file )
|
43
|
-
classpath_file.require_classpath
|
44
|
-
FileUtils.mkdir_p( @dir )
|
45
|
-
JBUNDLER_CLASSPATH.each do |f|
|
46
|
-
FileUtils.cp( f, File.join( @dir,
|
47
|
-
File.basename( f ) ) )
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
data/lib/jbundler.jar
DELETED
Binary file
|
data/spec/aether_spec.rb
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
load File.expand_path(File.join('spec', 'setup.rb'))
|
2
|
-
require 'maven/tools/jarfile'
|
3
|
-
require 'maven/tools/model'
|
4
|
-
require 'jbundler/aether'
|
5
|
-
require 'fileutils'
|
6
|
-
|
7
|
-
describe JBundler::AetherRuby do
|
8
|
-
|
9
|
-
let(:workdir) { 'pkg' }
|
10
|
-
let(:jfile) { File.join(workdir, 'tmp-jarfile') }
|
11
|
-
let(:jfile_lock) { jfile + ".lock"}
|
12
|
-
let(:jarfile) { Maven::Tools::Jarfile.new(jfile) }
|
13
|
-
subject { JBundler::AetherRuby.new }
|
14
|
-
|
15
|
-
before do
|
16
|
-
FileUtils.mkdir_p( workdir )
|
17
|
-
Dir[File.join(workdir, "tmp*")].each { |f| FileUtils.rm_f f }
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'repositories' do
|
21
|
-
File.open(jfile, 'w') do |f|
|
22
|
-
f.write <<-EOF
|
23
|
-
repository :first, "http://example.com/repo"
|
24
|
-
source 'second', "http://example.org/repo"
|
25
|
-
EOF
|
26
|
-
end
|
27
|
-
jarfile.populate_unlocked subject
|
28
|
-
subject.repositories.size.must_equal 3
|
29
|
-
subject.artifacts.size.must_equal 0
|
30
|
-
subject.repositories[0].id.must_equal "central"
|
31
|
-
subject.repositories[1].id.must_equal "first"
|
32
|
-
subject.repositories[2].id.must_equal "second"
|
33
|
-
subject.repositories[0].get_policy( false ).is_enabled.must_equal true
|
34
|
-
subject.repositories[0].get_policy( true ).is_enabled.must_equal true
|
35
|
-
subject.repositories[1].get_policy( true ).is_enabled.must_equal false
|
36
|
-
subject.repositories[2].get_policy( true ).is_enabled.must_equal false
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'snapshot repositories' do
|
40
|
-
File.open(jfile, 'w') do |f|
|
41
|
-
f.write <<-EOF
|
42
|
-
snapshot_repository :snap, "http://example.com/repo"
|
43
|
-
EOF
|
44
|
-
end
|
45
|
-
jarfile.populate_unlocked subject
|
46
|
-
subject.repositories.size.must_equal 2
|
47
|
-
subject.artifacts.size.must_equal 0
|
48
|
-
subject.repositories[0].id.must_equal "central"
|
49
|
-
subject.repositories[1].id.must_equal "snap"
|
50
|
-
subject.repositories[1].get_policy( true ).is_enabled.must_equal true
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'artifacts without locked' do
|
54
|
-
File.open(jfile, 'w') do |f|
|
55
|
-
f.write <<-EOF
|
56
|
-
jar 'a:b', '123'
|
57
|
-
pom 'x:y', '987'
|
58
|
-
EOF
|
59
|
-
end
|
60
|
-
jarfile.populate_unlocked subject
|
61
|
-
subject.repositories.size.must_equal 1 # central
|
62
|
-
subject.artifacts.size.must_equal 2
|
63
|
-
subject.artifacts[0].to_s.must_equal "a:b:jar:123"
|
64
|
-
subject.artifacts[1].to_s.must_equal "x:y:pom:987"
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'artifacts with locked' do
|
68
|
-
File.open(jfile, 'w') do |f|
|
69
|
-
f.write <<-EOF
|
70
|
-
jar 'a:b', '123'
|
71
|
-
pom 'x:y', '987'
|
72
|
-
EOF
|
73
|
-
end
|
74
|
-
File.open(jfile_lock, 'w') do |f|
|
75
|
-
f.write <<-EOF
|
76
|
-
a:b:jar:432
|
77
|
-
EOF
|
78
|
-
end
|
79
|
-
|
80
|
-
jarfile.populate_unlocked subject
|
81
|
-
subject.repositories.size.must_equal 1 # central
|
82
|
-
subject.artifacts.size.must_equal 1
|
83
|
-
subject.artifacts[0].to_s.must_equal "x:y:pom:987"
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'locked artifacts' do
|
87
|
-
File.open(jfile_lock, 'w') do |f|
|
88
|
-
f.write <<-EOF
|
89
|
-
a:b:jar:432
|
90
|
-
EOF
|
91
|
-
end
|
92
|
-
|
93
|
-
jarfile.populate_locked subject
|
94
|
-
subject.repositories.size.must_equal 1 # central
|
95
|
-
subject.artifacts.size.must_equal 1
|
96
|
-
subject.artifacts[0].to_s.must_equal "a:b:jar:432"
|
97
|
-
end
|
98
|
-
end
|