lock_jar 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -102,6 +102,8 @@ or directly load all Jars into the classpath
102
102
  require 'lock_jars'
103
103
 
104
104
  jars = LockJar.load
105
+
106
+ Do not forget, if you change your Jarfile, you have to re-generate the Jarfile.lock.
105
107
 
106
108
 
107
109
  === Buildr Integration
@@ -119,7 +121,8 @@ and a task per project to generate the lockfile for a single project
119
121
 
120
122
  buildr <app>:<project>:lock_jar:lock
121
123
 
122
- The resolved dependencies are automatically added to the classpath for compiling and testing.
124
+ The resolved dependencies are automatically added to the classpath for compiling and testing. Do not forget, if you change the lock_jar
125
+ definitions, you have to rerun the lock_jar:lock task.
123
126
 
124
127
 
125
128
  ==== Example
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -79,18 +79,53 @@ module LockJar
79
79
  dependencies
80
80
  end
81
81
 
82
- def load( jarfile_lock = "Jarfile.lock", scopes = ['compile', 'runtime'] )
82
+ def load( jarfile_lock = "Jarfile.lock", scopes = ['compile', 'runtime'], &blk )
83
+ dependencies = []
84
+
85
+ if jarfile_lock
86
+ if File.exists?(jarfile_lock)
87
+ dependencies += read_jarfile( jarfile_lock, scopes )
88
+ else
89
+ warn( "LockJar jarfile_lock not found: #{jarfile_lock}" )
90
+ end
91
+ end
92
+
93
+ if blk
94
+ dsl = LockJar::Dsl.evaluate(&blk)
95
+ dependencies += read_dsl( dsl, scopes )
96
+ end
97
+
98
+ dependencies.uniq!
99
+
100
+ @resolver.load_jars_to_classpath( dependencies )
101
+ end
102
+
103
+ private
104
+ def read_jarfile( jarfile_lock, scopes )
83
105
  lock_data = YAML.load_file( jarfile_lock )
84
106
 
85
107
  dependencies = []
86
-
108
+
87
109
  scopes.each do |scope|
88
110
  if lock_data['scopes'][scope]
89
111
  dependencies += lock_data['scopes'][scope]['resolved_dependencies']
90
112
  end
91
113
  end
92
114
 
93
- @resolver.load_jars_to_classpath( dependencies )
115
+ dependencies
116
+ end
117
+
118
+ def read_dsl( dsl, scopes )
119
+
120
+ dependencies = []
121
+
122
+ dsl.notations.each do |scope,notations|
123
+ if notations && notations.size > 0
124
+ dependencies += notations
125
+ end
126
+ end
127
+
128
+ @resolver.resolve( dependencies )
94
129
  end
95
130
  end
96
131
  end
data/lib/lock_jar.rb CHANGED
@@ -31,15 +31,15 @@ module LockJar
31
31
  # List jars for an array of scope in a lockfile
32
32
  #
33
33
  # Accepts path to the lockfile, array of scopes, and hash of options to configure LockJar
34
- def self.list( lockfile = 'Jarfile.lock', scopes = ['compile', 'runtime'], opts = {} )
34
+ def self.list( lockfile = 'Jarfile.lock', scopes = ['compile', 'runtime'], opts = {}, &blk )
35
35
  Runtime.new( opts ).list( lockfile, scopes )
36
36
  end
37
37
 
38
38
  # Load jars for an array of scopes in a lockfile
39
39
  #
40
40
  # Accepts a path to the lockfile, array scopes, and hash of optiosn to configure LockJar
41
- def self.load( lockfile = 'Jarfile.lock', scopes = ['compile', 'runtime'], opts = {} )
42
- Runtime.new( opts ).load( lockfile, scopes )
41
+ def self.load( lockfile = 'Jarfile.lock', scopes = ['compile', 'runtime'], opts = {}, &blk )
42
+ Runtime.new( opts ).load( lockfile, scopes, &blk )
43
43
  end
44
-
44
+
45
45
  end
data/lock_jar.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "lock_jar"
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
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"]
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: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Guymon