lock_jar 0.1.0 → 0.2.0
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.
- data/Gemfile +1 -1
- data/README.rdoc +39 -18
- data/VERSION +1 -1
- data/lib/lock_jar/buildr.rb +9 -6
- data/lib/lock_jar/bundler.rb +2 -0
- data/lib/lock_jar/dsl.rb +36 -20
- data/lib/lock_jar/resolver.rb +29 -3
- data/lib/lock_jar/runtime.rb +42 -6
- data/lib/lock_jar.rb +8 -0
- data/lock_jar.gemspec +6 -6
- data/spec/lock_jar/bundler_spec.rb +19 -11
- data/spec/lock_jar/dsl_spec.rb +1 -1
- data/spec/lock_jar/maven_spec.rb +1 -1
- data/spec/lock_jar/resolver_spec.rb +11 -4
- data/spec/lock_jar/runtime_spec.rb +2 -2
- data/spec/lock_jar_spec.rb +55 -9
- data/spec/spec_helper.rb +6 -1
- metadata +14 -14
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
@@ -16,14 +16,15 @@ gem install lock_jar
|
|
16
16
|
=== Using a Jarfile
|
17
17
|
|
18
18
|
==== Jarfile
|
19
|
-
|
19
|
+
|
20
|
+
A Jarfile is a simple file using a Ruby DSL for defining a project's dependencies using the following
|
20
21
|
methods:
|
21
22
|
|
22
23
|
* local: Set the local Maven repository
|
23
|
-
* repository: Add url of additional Maven repository
|
24
|
-
* jar: Add Jar dependency in artifact notation
|
25
|
-
* pom: Add local path to a Maven pom
|
26
|
-
* scope:
|
24
|
+
* repository: Add url of additional remote Maven repository.
|
25
|
+
* jar: Add Jar dependency in artifact notation, default scope is *compile*
|
26
|
+
* pom: Add local path to a Maven pom, default is to load dependencies for all scopes.
|
27
|
+
* scope: Set the scope for nested jar or pom.
|
27
28
|
|
28
29
|
Example Jarfile
|
29
30
|
|
@@ -43,7 +44,7 @@ Example Jarfile
|
|
43
44
|
|
44
45
|
==== Resolving dependencies
|
45
46
|
|
46
|
-
When the Jarfile is locked, the transitive dependencies for the Jars and
|
47
|
+
When the Jarfile is locked, the transitive dependencies for the Jars and POM are resolved and saved to the Jarfile.lock file.
|
47
48
|
|
48
49
|
Example of locking a Jarfile to a Jarfile.lock
|
49
50
|
|
@@ -101,34 +102,45 @@ or directly load all Jars into the classpath
|
|
101
102
|
|
102
103
|
Do not forget, if you change your Jarfile, you have to re-generate the Jarfile.lock.
|
103
104
|
|
104
|
-
|
105
|
+
==== Skipping the Jarfile
|
105
106
|
|
106
|
-
You can skip the Jarfile and directly load dependencies by passing a block to LockJar.load
|
107
|
+
You can skip the Jarfile and Jarfile.lock to directly load dependencies by passing a block to LockJar.load
|
107
108
|
|
108
109
|
LockJar.load do
|
109
110
|
jar 'org.eclipse.jetty:example-jetty-embedded:jar:8.1.2.v20120308'
|
110
111
|
end
|
111
112
|
|
113
|
+
Since you skipped the locking part, mostly likely you will need to resolve the dependences in the block, just pass the
|
114
|
+
:resolve => true option to enable dependency resolution.
|
115
|
+
|
116
|
+
LockJar.load( :resolve => true ) do
|
117
|
+
jar 'org.eclipse.jetty:example-jetty-embedded:jar:8.1.2.v20120308'
|
118
|
+
end
|
119
|
+
|
112
120
|
=== Bundler Integration
|
113
121
|
|
114
122
|
LockJar integrates with {Bundler}[https://github.com/carlhuda/bundler/] by {modifying}[https://github.com/mguymon/lock_jar/blob/master/lib/lock_jar/bundler.rb] the Bundler
|
115
|
-
DSL to include LockJar's DSL, generating a Jarfile.lock when Bundler locks, and populating the classpath
|
116
|
-
when Bundler requires.
|
123
|
+
DSL to include LockJar's DSL, generating a Jarfile.lock when Bundler locks, and populating the classpath when Bundler requires.
|
117
124
|
|
118
125
|
==== Example
|
119
126
|
|
120
127
|
The following Gemfile with LockJar
|
121
128
|
|
122
|
-
|
129
|
+
# This is what modifies Bundler to trigger LockJar
|
130
|
+
require 'lock_jar/bundler'
|
123
131
|
|
124
132
|
gem "naether"
|
133
|
+
|
134
|
+
group :development do
|
135
|
+
gem "rspec", "~> 2.9.0"
|
136
|
+
end
|
125
137
|
|
126
138
|
# lockjar dsl that is used to generate Jarfile.lock
|
127
139
|
lock_jar do
|
128
140
|
scope :test do
|
129
|
-
|
130
|
-
|
131
|
-
|
141
|
+
jar 'junit:junit:jar:4.10'
|
142
|
+
end
|
143
|
+
|
132
144
|
pom 'spec/pom.xml', :scope => :compile
|
133
145
|
end
|
134
146
|
|
@@ -136,12 +148,20 @@ Will produce a Gemfile.lock and Jarfile.lock for
|
|
136
148
|
|
137
149
|
bundle install
|
138
150
|
|
139
|
-
When
|
151
|
+
When Bundler.setup or Bundler.require is called, the jars from the Jarfile.lock are loaded into the classpath.
|
152
|
+
|
153
|
+
require 'rubygems'
|
154
|
+
require 'bundler'
|
155
|
+
|
156
|
+
# This is what modifies Bundler to trigger LockJar
|
157
|
+
require 'lock_jar/bundler'
|
158
|
+
|
159
|
+
Bundler.require
|
140
160
|
|
141
161
|
=== Buildr Integration
|
142
162
|
|
143
163
|
LockJar integrates with {Buildr}[http://buildr.apache.org/] using an {Addon}[https://github.com/mguymon/lock_jar/blob/master/lib/lock_jar/buildr.rb].
|
144
|
-
This allows the Jarfile to be defined directly into a buildfile. A global
|
164
|
+
This allows the Jarfile to be defined directly into a buildfile. A global LockJar definition can be set and
|
145
165
|
is inherited to all projects. Each project may have its own LockJar definition. A lock file is generated per project based
|
146
166
|
on the project name.
|
147
167
|
|
@@ -153,8 +173,9 @@ and a task per project to generate the lockfile for a single project
|
|
153
173
|
|
154
174
|
buildr <app>:<project>:lock_jar:lock
|
155
175
|
|
156
|
-
The
|
157
|
-
|
176
|
+
The compile scoped dependencies are automatically added to the classpath for compiling. The test scoped dependencies are
|
177
|
+
automatically added to the classpath for tests. Do not forget, if you change the lock_jar
|
178
|
+
definitions, you have to rerun the *lock_jar:lock* task.
|
158
179
|
|
159
180
|
|
160
181
|
==== Example
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/lock_jar/buildr.rb
CHANGED
@@ -18,16 +18,18 @@ require 'lock_jar/dsl'
|
|
18
18
|
|
19
19
|
module Buildr
|
20
20
|
|
21
|
-
attr_reader :global_lockjar_dsl
|
22
|
-
|
23
21
|
class << self
|
24
22
|
def project_to_lockfile( project )
|
25
23
|
"#{project.name.gsub(/:/,'-')}.lock"
|
26
24
|
end
|
25
|
+
|
26
|
+
def global_lockjar_dsl
|
27
|
+
@@global_lockjar_dsl
|
28
|
+
end
|
27
29
|
end
|
28
30
|
|
29
31
|
def lock_jar( &blk )
|
30
|
-
|
32
|
+
@@global_lockjar_dsl = ::LockJar::Dsl.evaluate(&blk)
|
31
33
|
end
|
32
34
|
|
33
35
|
namespace "lock_jar" do
|
@@ -47,8 +49,9 @@ module Buildr
|
|
47
49
|
|
48
50
|
def lock_jar( &blk )
|
49
51
|
@lockjar_dsl = ::LockJar::Dsl.evaluate(&blk)
|
50
|
-
|
51
|
-
|
52
|
+
|
53
|
+
unless Buildr.global_lockjar_dsl.nil?
|
54
|
+
@lockjar_dsl.merge( Buildr.global_lockjar_dsl )
|
52
55
|
end
|
53
56
|
end
|
54
57
|
|
@@ -57,7 +60,7 @@ module Buildr
|
|
57
60
|
end
|
58
61
|
|
59
62
|
def lockjar_dsl
|
60
|
-
@lockjar_dsl || global_lockjar_dsl
|
63
|
+
@lockjar_dsl || Buildr.global_lockjar_dsl
|
61
64
|
end
|
62
65
|
|
63
66
|
after_define do |project|
|
data/lib/lock_jar/bundler.rb
CHANGED
data/lib/lock_jar/dsl.rb
CHANGED
@@ -20,6 +20,7 @@ module LockJar
|
|
20
20
|
attr_reader :repositories
|
21
21
|
attr_reader :local_repository
|
22
22
|
attr_reader :scopes
|
23
|
+
attr_reader :maps
|
23
24
|
|
24
25
|
class << self
|
25
26
|
|
@@ -61,10 +62,7 @@ module LockJar
|
|
61
62
|
@present_scope = 'compile'
|
62
63
|
|
63
64
|
@local_repository = nil
|
64
|
-
|
65
|
-
|
66
|
-
def local( path )
|
67
|
-
@local_repository = path
|
65
|
+
@maps = {}
|
68
66
|
end
|
69
67
|
|
70
68
|
def jar(notation, *args)
|
@@ -75,6 +73,34 @@ module LockJar
|
|
75
73
|
|
76
74
|
artifact( notation, opts )
|
77
75
|
end
|
76
|
+
|
77
|
+
def local( path )
|
78
|
+
@local_repository = path
|
79
|
+
end
|
80
|
+
|
81
|
+
def merge( dsl )
|
82
|
+
@repositories = (@repositories + dsl.repositories).uniq
|
83
|
+
|
84
|
+
dsl.notations.each do |scope, notations|
|
85
|
+
@notations[scope] = (@notations[scope] + notations).uniq
|
86
|
+
end
|
87
|
+
|
88
|
+
dsl.maps.each do |notation,paths|
|
89
|
+
existing_map = @maps[notation]
|
90
|
+
if existing_map
|
91
|
+
@maps[notation] = (existing_map + paths).uniq
|
92
|
+
else
|
93
|
+
@maps[notation] = paths
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
self
|
98
|
+
end
|
99
|
+
|
100
|
+
# Map a dependency to another dependency or local directory.
|
101
|
+
def map( notation, *args )
|
102
|
+
@maps[notation] = args
|
103
|
+
end
|
78
104
|
|
79
105
|
# Pom default to all scopes, unless nested in a scope
|
80
106
|
def pom(path, *args)
|
@@ -91,11 +117,15 @@ module LockJar
|
|
91
117
|
|
92
118
|
artifact( path, opts )
|
93
119
|
end
|
120
|
+
|
121
|
+
def read_file(file)
|
122
|
+
File.open(file, "rb") { |f| f.read }
|
123
|
+
end
|
94
124
|
|
95
125
|
def repository( url, opts = {} )
|
96
126
|
@repositories << url
|
97
127
|
end
|
98
|
-
|
128
|
+
|
99
129
|
def scope(*scopes, &blk)
|
100
130
|
@scope_changed = true
|
101
131
|
scopes.each do |scope|
|
@@ -104,22 +134,8 @@ module LockJar
|
|
104
134
|
end
|
105
135
|
@scope_changed = false
|
106
136
|
@present_scope = 'compile'
|
107
|
-
end
|
137
|
+
end
|
108
138
|
|
109
|
-
def read_file(file)
|
110
|
-
File.open(file, "rb") { |f| f.read }
|
111
|
-
end
|
112
|
-
|
113
|
-
def merge( dsl )
|
114
|
-
@repositories = (@repositories + dsl.repositories).uniq
|
115
|
-
|
116
|
-
dsl.notations.each do |scope, notations|
|
117
|
-
@notations[scope] = (@notations[scope] + notations).uniq
|
118
|
-
end
|
119
|
-
|
120
|
-
self
|
121
|
-
end
|
122
|
-
|
123
139
|
private
|
124
140
|
def artifact(artifact, opts)
|
125
141
|
|
data/lib/lock_jar/resolver.rb
CHANGED
@@ -63,11 +63,37 @@ module LockJar
|
|
63
63
|
@naether.dependenciesNotation
|
64
64
|
end
|
65
65
|
|
66
|
-
def
|
67
|
-
|
66
|
+
def to_local_paths( notations )
|
67
|
+
paths = []
|
68
|
+
notations.each do |notation|
|
69
|
+
if File.directory?(notation)
|
70
|
+
paths << notation
|
71
|
+
else
|
72
|
+
paths = paths + @naether.to_local_paths( [notation] )
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
paths
|
77
|
+
end
|
78
|
+
|
79
|
+
def load_to_classpath( notations )
|
80
|
+
dirs = []
|
81
|
+
jars = []
|
82
|
+
|
83
|
+
notations.each do |notation|
|
84
|
+
if File.directory?(notation)
|
85
|
+
dirs << notation
|
86
|
+
else
|
87
|
+
jars << notation
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
Naether::Java.load_paths( dirs )
|
92
|
+
|
93
|
+
jars = @naether.to_local_paths( jars )
|
68
94
|
Naether::Java.load_jars( jars )
|
69
95
|
|
70
|
-
jars
|
96
|
+
dirs + jars
|
71
97
|
end
|
72
98
|
end
|
73
99
|
end
|
data/lib/lock_jar/runtime.rb
CHANGED
@@ -27,6 +27,7 @@ module LockJar
|
|
27
27
|
attr_reader :current_resolver
|
28
28
|
|
29
29
|
def resolver( opts = {} )
|
30
|
+
# XXX: opts for a method will cause resolver to reload
|
30
31
|
if @current_resolver.nil? || opts != @current_resolver.opts
|
31
32
|
@current_resolver = LockJar::Resolver.new( opts )
|
32
33
|
end
|
@@ -35,6 +36,7 @@ module LockJar
|
|
35
36
|
end
|
36
37
|
|
37
38
|
def lock( jarfile, opts = {} )
|
39
|
+
|
38
40
|
lock_jar_file = nil
|
39
41
|
|
40
42
|
if jarfile.is_a? LockJar::Dsl
|
@@ -61,7 +63,11 @@ module LockJar
|
|
61
63
|
if lock_jar_file.repositories.size > 0
|
62
64
|
lock_data['repositories'] = lock_jar_file.repositories
|
63
65
|
end
|
64
|
-
|
66
|
+
|
67
|
+
if lock_jar_file.maps.size > 0
|
68
|
+
lock_data['maps'] = lock_jar_file.maps
|
69
|
+
end
|
70
|
+
|
65
71
|
lock_data['scopes'] = {}
|
66
72
|
|
67
73
|
lock_jar_file.notations.each do |scope, notations|
|
@@ -73,6 +79,7 @@ module LockJar
|
|
73
79
|
|
74
80
|
if dependencies.size > 0
|
75
81
|
resolved_notations = resolver(opts).resolve( dependencies )
|
82
|
+
|
76
83
|
lock_data['scopes'][scope] = {
|
77
84
|
'dependencies' => notations,
|
78
85
|
'resolved_dependencies' => resolved_notations }
|
@@ -86,17 +93,45 @@ module LockJar
|
|
86
93
|
|
87
94
|
def list( jarfile_lock, scopes = ['compile', 'runtime'], opts = {}, &blk )
|
88
95
|
dependencies = []
|
89
|
-
|
96
|
+
maps = []
|
97
|
+
|
90
98
|
if jarfile_lock
|
91
|
-
|
99
|
+
lockfile = read_lockfile( jarfile_lock)
|
100
|
+
dependencies += lockfile_dependencies( lockfile, scopes )
|
101
|
+
maps = lockfile['maps']
|
92
102
|
end
|
93
103
|
|
94
104
|
unless blk.nil?
|
95
105
|
dsl = LockJar::Dsl.evaluate(&blk)
|
96
106
|
dependencies += dsl_dependencies( dsl, scopes )
|
107
|
+
maps = dsl.maps
|
97
108
|
end
|
98
109
|
|
99
|
-
|
110
|
+
if maps && maps.size > 0
|
111
|
+
mapped_dependencies = []
|
112
|
+
|
113
|
+
maps.each do |notation, replacements|
|
114
|
+
dependencies.each do |dep|
|
115
|
+
if dep =~ /#{notation}/
|
116
|
+
replacements.each do |replacement|
|
117
|
+
mapped_dependencies << replacement
|
118
|
+
end
|
119
|
+
else
|
120
|
+
mapped_dependencies << dep
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
dependencies = mapped_dependencies
|
126
|
+
end
|
127
|
+
|
128
|
+
if opts[:local_paths]
|
129
|
+
opts.delete( :local_paths ) # remove list opts so resolver is not reset
|
130
|
+
resolver(opts).to_local_paths( dependencies.uniq )
|
131
|
+
|
132
|
+
else
|
133
|
+
dependencies.uniq
|
134
|
+
end
|
100
135
|
end
|
101
136
|
|
102
137
|
def load( jarfile_lock, scopes = ['compile', 'runtime'], opts = {}, &blk )
|
@@ -122,14 +157,15 @@ module LockJar
|
|
122
157
|
dependencies = resolver(opts).resolve( dependencies )
|
123
158
|
end
|
124
159
|
|
125
|
-
resolver(opts).
|
160
|
+
resolver(opts).load_to_classpath( dependencies )
|
126
161
|
end
|
127
162
|
|
128
|
-
private
|
129
163
|
def read_lockfile( jarfile_lock )
|
130
164
|
YAML.load_file( jarfile_lock )
|
131
165
|
end
|
132
166
|
|
167
|
+
private
|
168
|
+
|
133
169
|
def lockfile_dependencies( lockfile, scopes)
|
134
170
|
dependencies = []
|
135
171
|
|
data/lib/lock_jar.rb
CHANGED
@@ -21,6 +21,10 @@ require 'lock_jar/runtime'
|
|
21
21
|
|
22
22
|
module LockJar
|
23
23
|
|
24
|
+
def self.config( opts )
|
25
|
+
Runtime.instance.resolver( opts )
|
26
|
+
end
|
27
|
+
|
24
28
|
# Lock a Jarfile and generate a Jarfile.lock
|
25
29
|
#
|
26
30
|
# Accepts path to the jarfile and hash of options to configure LockJar
|
@@ -80,5 +84,9 @@ module LockJar
|
|
80
84
|
|
81
85
|
Runtime.instance.load( lockfile, scopes, opts, &blk )
|
82
86
|
end
|
87
|
+
|
88
|
+
def self.read( lockfile )
|
89
|
+
Runtime.instance.read_lockfile( lockfile )
|
90
|
+
end
|
83
91
|
|
84
92
|
end
|
data/lock_jar.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "lock_jar"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Michael Guymon"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-05-09"
|
13
13
|
s.description = "Manage Jar files for Ruby. In the spirit of Bundler, a Jarfile\n is used to generate a Jarfile.lock that contains all the resolved jar dependencies for scopes runtime, compile, and test.\n The Jarfile.lock can be used to populate the classpath"
|
14
14
|
s.email = "michael.guymon@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -45,25 +45,25 @@ Gem::Specification.new do |s|
|
|
45
45
|
s.homepage = "http://github.com/mguymon/lock_jar"
|
46
46
|
s.licenses = ["Apache"]
|
47
47
|
s.require_paths = ["lib"]
|
48
|
-
s.rubygems_version = "1.8.
|
48
|
+
s.rubygems_version = "1.8.24"
|
49
49
|
s.summary = "Manage Jar files for Ruby"
|
50
50
|
|
51
51
|
if s.respond_to? :specification_version then
|
52
52
|
s.specification_version = 3
|
53
53
|
|
54
54
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
55
|
-
s.add_runtime_dependency(%q<naether>, ["~> 0.
|
55
|
+
s.add_runtime_dependency(%q<naether>, ["~> 0.7.0"])
|
56
56
|
s.add_development_dependency(%q<rspec>, ["~> 2.9.0"])
|
57
57
|
s.add_development_dependency(%q<bundler>, ["> 1.0.0"])
|
58
58
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
59
59
|
else
|
60
|
-
s.add_dependency(%q<naether>, ["~> 0.
|
60
|
+
s.add_dependency(%q<naether>, ["~> 0.7.0"])
|
61
61
|
s.add_dependency(%q<rspec>, ["~> 2.9.0"])
|
62
62
|
s.add_dependency(%q<bundler>, ["> 1.0.0"])
|
63
63
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
64
64
|
end
|
65
65
|
else
|
66
|
-
s.add_dependency(%q<naether>, ["~> 0.
|
66
|
+
s.add_dependency(%q<naether>, ["~> 0.7.0"])
|
67
67
|
s.add_dependency(%q<rspec>, ["~> 2.9.0"])
|
68
68
|
s.add_dependency(%q<bundler>, ["> 1.0.0"])
|
69
69
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
@@ -1,16 +1,22 @@
|
|
1
|
-
require 'spec_helper'
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'../spec_helper'))
|
2
|
+
|
2
3
|
require 'rubygems'
|
3
4
|
require 'bundler'
|
4
5
|
require 'lib/lock_jar/bundler'
|
5
6
|
require 'helper/bundler_helper'
|
7
|
+
require 'fileutils'
|
6
8
|
|
7
9
|
describe Bundler do
|
8
10
|
include BundlerHelper
|
9
11
|
|
12
|
+
before(:all) do
|
13
|
+
FileUtils.rm_rf( bundled_app ) if File.exists? bundled_app
|
14
|
+
FileUtils.mkdir_p tmp('bundler')
|
15
|
+
end
|
16
|
+
|
10
17
|
before(:each) do
|
11
18
|
gemfile <<-G
|
12
19
|
require 'lock_jar/bundler'
|
13
|
-
source "file://#{tmp('bundler')}"
|
14
20
|
gem "naether"
|
15
21
|
|
16
22
|
lock_jar do
|
@@ -33,14 +39,13 @@ describe Bundler do
|
|
33
39
|
end
|
34
40
|
|
35
41
|
it "provides a list of the jar and pom dependencies" do
|
36
|
-
Bundler.load.lock_jar.notations.should eql( {"compile"=>["
|
42
|
+
Bundler.load.lock_jar.notations.should eql( {"compile"=>[File.expand_path(File.join(File.dirname(__FILE__), "../../spec/pom.xml"))], "runtime"=>[], "test"=>["junit:junit:jar:4.10"]} )
|
37
43
|
end
|
38
44
|
|
39
45
|
it "should create Jarfile.lock with bundle install" do
|
40
46
|
File.delete( bundled_app("Jarfile.lock") ) if File.exists? bundled_app("Jarfile.lock")
|
41
47
|
install_gemfile <<-G
|
42
48
|
require 'lock_jar/bundler'
|
43
|
-
source "file://#{tmp('bundler')}"
|
44
49
|
gem "naether"
|
45
50
|
|
46
51
|
lock_jar do
|
@@ -52,10 +57,9 @@ describe Bundler do
|
|
52
57
|
end
|
53
58
|
|
54
59
|
G
|
60
|
+
File.exists?( bundled_app("Jarfile.lock") ).should be_true
|
55
61
|
|
56
|
-
File.
|
57
|
-
|
58
|
-
IO.read( File.join(root,'spec', 'BundlerJarfile.lock') ).should eql( IO.read( bundled_app("Jarfile.lock") ) )
|
62
|
+
LockJar.read( File.join(root,'spec', 'BundlerJarfile.lock') ).should eql( LockJar.read( bundled_app("Jarfile.lock") ) )
|
59
63
|
end
|
60
64
|
|
61
65
|
it "should create Jarfile.lock with bundle update" do
|
@@ -63,7 +67,7 @@ describe Bundler do
|
|
63
67
|
bundle "update"
|
64
68
|
File.exists?( bundled_app("Jarfile.lock") ).should be_true
|
65
69
|
|
66
|
-
|
70
|
+
LockJar.read( File.join(root,'spec', 'BundlerJarfile.lock') ).should eql( LockJar.read( bundled_app("Jarfile.lock") ) )
|
67
71
|
end
|
68
72
|
|
69
73
|
it "should load Jarfile.lock with Bundle.setup" do
|
@@ -71,12 +75,16 @@ describe Bundler do
|
|
71
75
|
require 'rubygems'
|
72
76
|
require 'bundler'
|
73
77
|
require 'lock_jar/bundler'
|
78
|
+
require 'naether/java'
|
79
|
+
|
80
|
+
LockJar.config( :local_repo => '#{tmp('test-repo')}' )
|
81
|
+
|
74
82
|
Bundler.setup
|
75
83
|
|
76
|
-
puts com.slackworks.modelcitizen.ModelFactory.
|
84
|
+
puts Naether::Java.create('com.slackworks.modelcitizen.ModelFactory').getClass().toString()
|
77
85
|
RUBY
|
78
|
-
err.should eq("")
|
79
|
-
out.should match("
|
86
|
+
# err.should eq("") # 1.9.3 has a IConv error that outputs to std err
|
87
|
+
out.should match("class com.slackworks.modelcitizen.ModelFactory")
|
80
88
|
end
|
81
89
|
|
82
90
|
end
|
data/spec/lock_jar/dsl_spec.rb
CHANGED
data/spec/lock_jar/maven_spec.rb
CHANGED
@@ -1,19 +1,26 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec/spec_helper'
|
2
2
|
require 'lib/lock_jar/resolver'
|
3
3
|
require 'fileutils'
|
4
4
|
require 'naether'
|
5
5
|
|
6
6
|
describe LockJar::Resolver do
|
7
7
|
context "Instance" do
|
8
|
-
|
8
|
+
before(:each) do
|
9
9
|
FileUtils.mkdir_p( 'tmp/test-repo' )
|
10
|
-
resolver = LockJar::Resolver.new( :local_repo => 'tmp/test-repo' )
|
11
|
-
|
10
|
+
@resolver = LockJar::Resolver.new( :local_repo => 'tmp/test-repo' )
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should bootstrap naether" do
|
12
14
|
deps = Naether::Bootstrap.check_local_repo_for_deps( 'tmp/test-repo' )
|
13
15
|
deps[:missing].should eql([])
|
14
16
|
deps[:exists].each do |dep|
|
15
17
|
dep.values[0].should match /.+#{File::SEPARATOR}tmp#{File::SEPARATOR}test-repo#{File::SEPARATOR}.+/
|
16
18
|
end
|
17
19
|
end
|
20
|
+
|
21
|
+
it "should return local paths for notations" do
|
22
|
+
@resolver.to_local_paths( ["junit:junit:jar:4.10"] ).should
|
23
|
+
eql( [File.expand_path("tmp/test-repo/junit/junit/4.10/junit-4.10.jar")] )
|
24
|
+
end
|
18
25
|
end
|
19
26
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec/spec_helper'
|
2
2
|
require 'lib/lock_jar/runtime'
|
3
3
|
|
4
4
|
describe LockJar::Runtime do
|
5
5
|
context "Singleton" do
|
6
6
|
it "should set local repo" do
|
7
7
|
LockJar::Runtime.instance.load( nil ) do
|
8
|
-
jar '
|
8
|
+
jar 'junit:junit:4.10'
|
9
9
|
end
|
10
10
|
|
11
11
|
LockJar::Runtime.instance.current_resolver.naether.local_repo_path.should eql File.expand_path('~/.m2/repository')
|
data/spec/lock_jar_spec.rb
CHANGED
@@ -1,20 +1,64 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'spec_helper'))
|
1
2
|
require 'rubygems'
|
2
3
|
require 'lib/lock_jar'
|
3
4
|
require 'naether'
|
4
5
|
|
5
6
|
describe LockJar do
|
6
7
|
context "Module" do
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
context "lock" do
|
9
|
+
it "should create a lock file" do
|
10
|
+
File.delete( 'tmp/Jarfile.lock' ) if File.exists?( 'tmp/Jarfile.lock' )
|
11
|
+
Dir.mkdir( 'tmp' ) unless File.exists?( 'tmp' )
|
12
|
+
|
13
|
+
LockJar.lock( "spec/Jarfile", :local_repo => 'tmp/test-repo', :lockfile => 'tmp/Jarfile.lock' )
|
14
|
+
File.exists?( 'tmp/Jarfile.lock' ).should be_true
|
15
|
+
end
|
10
16
|
|
11
|
-
|
12
|
-
|
17
|
+
it "should not replace dependencies with maps" do
|
18
|
+
dsl = LockJar::Dsl.evaluate do
|
19
|
+
map 'junit:junit:4.10', 'tmp'
|
20
|
+
jar 'junit:junit:4.10'
|
21
|
+
end
|
22
|
+
|
23
|
+
LockJar.lock( dsl, :local_repo => 'tmp/test-repo', :lockfile => 'tmp/Jarfile.lock' )
|
24
|
+
lockfile = LockJar.read('tmp/Jarfile.lock')
|
25
|
+
lockfile.should eql( {
|
26
|
+
"maps"=>{"junit:junit:4.10"=>["tmp"]},
|
27
|
+
"scopes"=>{
|
28
|
+
"compile"=>{
|
29
|
+
"dependencies"=>["junit:junit:4.10"], "resolved_dependencies"=>["junit:junit:jar:4.10", "org.hamcrest:hamcrest-core:jar:1.1"]}}} )
|
30
|
+
end
|
13
31
|
end
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
32
|
+
|
33
|
+
context "list" do
|
34
|
+
it "should list jars" do
|
35
|
+
LockJar.lock( "spec/Jarfile", :local_repo => 'tmp/test-repo', :lockfile => 'tmp/Jarfile.lock' )
|
36
|
+
|
37
|
+
jars = LockJar.list( 'tmp/Jarfile.lock', ['compile', 'runtime', 'bad scope'], :local_repo => 'tmp/test-repo' )
|
38
|
+
jars.should eql( ["org.apache.mina:mina-core:jar:2.0.4", "org.slf4j:slf4j-api:jar:1.6.1", "com.slackworks:modelcitizen:jar:0.2.2", "commons-lang:commons-lang:jar:2.6", "commons-beanutils:commons-beanutils:jar:1.8.3", "commons-logging:commons-logging:jar:1.1.1", "ch.qos.logback:logback-classic:jar:0.9.24", "ch.qos.logback:logback-core:jar:0.9.24", "com.metapossum:metapossum-scanner:jar:1.0", "commons-io:commons-io:jar:1.4", "junit:junit:jar:4.7", "org.apache.tomcat:servlet-api:jar:6.0.35"] )
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should replace dependencies with maps" do
|
42
|
+
dsl = LockJar::Dsl.evaluate do
|
43
|
+
map 'junit:junit', 'tmp'
|
44
|
+
jar 'junit:junit:4.10'
|
45
|
+
end
|
46
|
+
|
47
|
+
LockJar.lock( dsl, :local_repo => 'tmp/test-repo', :lockfile => 'tmp/ListJarfile.lock' )
|
48
|
+
paths = LockJar.list( 'tmp/ListJarfile.lock', :local_repo => 'tmp/test-repo' )
|
49
|
+
paths.should eql( [ "tmp", "org.hamcrest:hamcrest-core:jar:1.1"] )
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should replace dependencies with maps and get local paths" do
|
53
|
+
dsl = LockJar::Dsl.evaluate do
|
54
|
+
map 'junit:junit', 'tmp'
|
55
|
+
jar 'junit:junit:4.10'
|
56
|
+
end
|
57
|
+
|
58
|
+
LockJar.lock( dsl, :local_repo => 'tmp/test-repo', :lockfile => 'tmp/ListJarfile.lock' )
|
59
|
+
paths = LockJar.list( 'tmp/ListJarfile.lock', :local_repo => 'tmp/test-repo' )
|
60
|
+
paths.should eql( [ "tmp", "org.hamcrest:hamcrest-core:jar:1.1"] )
|
61
|
+
end
|
18
62
|
end
|
19
63
|
|
20
64
|
context "load" do
|
@@ -25,6 +69,8 @@ describe LockJar do
|
|
25
69
|
lambda { Rjb::import('org.apache.mina.core.IoUtil') }.should raise_error
|
26
70
|
end
|
27
71
|
|
72
|
+
LockJar.lock( "spec/Jarfile", :local_repo => 'tmp/test-repo', :lockfile => 'tmp/Jarfile.lock' )
|
73
|
+
|
28
74
|
jars = LockJar.load( 'tmp/Jarfile.lock', ['compile', 'runtime'], :local_repo => 'tmp/test-repo' )
|
29
75
|
|
30
76
|
jars.should eql( [File.expand_path("tmp/test-repo/org/apache/mina/mina-core/2.0.4/mina-core-2.0.4.jar"), File.expand_path("tmp/test-repo/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar"), File.expand_path("tmp/test-repo/com/slackworks/modelcitizen/0.2.2/modelcitizen-0.2.2.jar"), File.expand_path("tmp/test-repo/commons-lang/commons-lang/2.6/commons-lang-2.6.jar"), File.expand_path("tmp/test-repo/commons-beanutils/commons-beanutils/1.8.3/commons-beanutils-1.8.3.jar"), File.expand_path("tmp/test-repo/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar"), File.expand_path("tmp/test-repo/ch/qos/logback/logback-classic/0.9.24/logback-classic-0.9.24.jar"), File.expand_path("tmp/test-repo/ch/qos/logback/logback-core/0.9.24/logback-core-0.9.24.jar"), File.expand_path("tmp/test-repo/com/metapossum/metapossum-scanner/1.0/metapossum-scanner-1.0.jar"), File.expand_path("tmp/test-repo/commons-io/commons-io/1.4/commons-io-1.4.jar"), File.expand_path("tmp/test-repo/junit/junit/4.7/junit-4.7.jar"), File.expand_path("tmp/test-repo/org/apache/tomcat/servlet-api/6.0.35/servlet-api-6.0.35.jar")] )
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,10 @@
|
|
1
|
+
$:.unshift File.expand_path('.')
|
1
2
|
$:.unshift File.expand_path('..', __FILE__)
|
2
|
-
$:.unshift File.expand_path('
|
3
|
+
$:.unshift File.expand_path('../lib', __FILE__)
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'rspec'
|
7
|
+
require 'lib/lock_jar'
|
3
8
|
|
4
9
|
RSpec.configure do |config|
|
5
10
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lock_jar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Guymon
|
@@ -15,27 +15,25 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-05-09 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
prerelease: false
|
22
|
-
type: :runtime
|
23
21
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
22
|
none: false
|
25
23
|
requirements:
|
26
24
|
- - ~>
|
27
25
|
- !ruby/object:Gem::Version
|
28
|
-
hash:
|
26
|
+
hash: 3
|
29
27
|
segments:
|
30
28
|
- 0
|
31
|
-
-
|
29
|
+
- 7
|
32
30
|
- 0
|
33
|
-
version: 0.
|
31
|
+
version: 0.7.0
|
34
32
|
version_requirements: *id001
|
35
33
|
name: naether
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
34
|
prerelease: false
|
38
|
-
type: :
|
35
|
+
type: :runtime
|
36
|
+
- !ruby/object:Gem::Dependency
|
39
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
40
38
|
none: false
|
41
39
|
requirements:
|
@@ -49,9 +47,9 @@ dependencies:
|
|
49
47
|
version: 2.9.0
|
50
48
|
version_requirements: *id002
|
51
49
|
name: rspec
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
50
|
prerelease: false
|
54
51
|
type: :development
|
52
|
+
- !ruby/object:Gem::Dependency
|
55
53
|
requirement: &id003 !ruby/object:Gem::Requirement
|
56
54
|
none: false
|
57
55
|
requirements:
|
@@ -65,9 +63,9 @@ dependencies:
|
|
65
63
|
version: 1.0.0
|
66
64
|
version_requirements: *id003
|
67
65
|
name: bundler
|
68
|
-
- !ruby/object:Gem::Dependency
|
69
66
|
prerelease: false
|
70
67
|
type: :development
|
68
|
+
- !ruby/object:Gem::Dependency
|
71
69
|
requirement: &id004 !ruby/object:Gem::Requirement
|
72
70
|
none: false
|
73
71
|
requirements:
|
@@ -81,6 +79,8 @@ dependencies:
|
|
81
79
|
version: 1.6.4
|
82
80
|
version_requirements: *id004
|
83
81
|
name: jeweler
|
82
|
+
prerelease: false
|
83
|
+
type: :development
|
84
84
|
description: |-
|
85
85
|
Manage Jar files for Ruby. In the spirit of Bundler, a Jarfile
|
86
86
|
is used to generate a Jarfile.lock that contains all the resolved jar dependencies for scopes runtime, compile, and test.
|
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
147
|
requirements: []
|
148
148
|
|
149
149
|
rubyforge_project:
|
150
|
-
rubygems_version: 1.8.
|
150
|
+
rubygems_version: 1.8.24
|
151
151
|
signing_key:
|
152
152
|
specification_version: 3
|
153
153
|
summary: Manage Jar files for Ruby
|