maven-tools 0.32.5 → 0.33.2

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.
@@ -0,0 +1,52 @@
1
+ require 'maven/tools/coordinate'
2
+
3
+ module Maven
4
+ module Tools
5
+ class GemspecDependencies
6
+
7
+ def initialize( gemspec )
8
+ if gemspec.is_a? Gem::Specification
9
+ @spec = gemspec
10
+ else
11
+ @spec = Gem::Specification.load( gemspec )
12
+ end
13
+ _setup
14
+ end
15
+
16
+ def java_runtime
17
+ _deps( :java_runtime )
18
+ end
19
+
20
+ def runtime
21
+ _deps( :runtime )
22
+ end
23
+
24
+ def development
25
+ _deps( :development )
26
+ end
27
+
28
+ private
29
+
30
+ include Coordinate
31
+
32
+ def _deps( type )
33
+ @deps ||= {}
34
+ @deps[ type ] ||= []
35
+ end
36
+
37
+ def _setup
38
+ @spec.dependencies.each do |dep|
39
+ versions = dep.requirement.requirements.collect do |req|
40
+ # use this construct to get the same result in 1.8.x and 1.9.x
41
+ req.collect{ |i| i.to_s }.join
42
+ end
43
+ _deps( dep.type ) << "rubygems:#{dep.name}:#{to_version( *versions )}"
44
+ end
45
+ @spec.requirements.each do |req|
46
+ coord = to_split_coordinate( req )
47
+ _deps( :java_runtime ) << coord if coord
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -19,6 +19,8 @@
19
19
  # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
20
  #
21
21
  require File.join(File.dirname(__FILE__), 'coordinate.rb')
22
+ require File.join(File.dirname(__FILE__), 'artifact.rb')
23
+ require 'fileutils'
22
24
  module Maven
23
25
  module Tools
24
26
 
@@ -52,6 +54,14 @@ module Maven
52
54
  File.read(@lockfile).each_line do |line|
53
55
  line.strip!
54
56
  if line.size > 0 && !(line =~ /^\s*#/)
57
+ # fix the classifier and version position
58
+ if line.count( ':' ) == 4
59
+ parts = line.split( ':' )
60
+ p = parts.last
61
+ parts[ 4 ] = parts[ 3 ]
62
+ parts[ 3 ] = p
63
+ line = parts.join( ':' )
64
+ end
55
65
  _locked << line
56
66
  end
57
67
  end
@@ -68,27 +78,91 @@ module Maven
68
78
  locked.detect { |l| l.sub(/^([^:]+:[^:]+):.+/) { $1 } == coord } != nil
69
79
  end
70
80
 
71
- def populate_unlocked(container)
81
+ class DSL
82
+ include Coordinate
83
+
84
+ def self.eval_file( file )
85
+ jarfile = self.new
86
+ jarfile.eval_file( file )
87
+ end
88
+
89
+ def eval_file( file )
90
+ if File.exists?( file )
91
+ eval( File.read( file ) )
92
+ self
93
+ end
94
+ end
95
+
96
+ def artifacts
97
+ @artifacts ||= []
98
+ end
99
+
100
+ def repositories
101
+ @repositories ||= []
102
+ end
103
+
104
+ def snapshot_repositories
105
+ @snapshot_repositories ||= []
106
+ end
107
+
108
+ def local( path )
109
+ artifacts << Artifact.new_local( File.expand_path( path ), :jar )
110
+ end
111
+
112
+ def jar( *args )
113
+ args << '[0,)' if args.size == 1
114
+ artifacts << Artifact.from( :jar, *args )
115
+ end
116
+
117
+ def pom( *args )
118
+ args << '[0,)' if args.size == 1
119
+ artifacts << Artifact.from( :pom, *args )
120
+ end
121
+
122
+ def snapshot_repository( name, url = nil )
123
+ if url.nil?
124
+ url = name
125
+ end
126
+ snapshot_repositories << { :name => name.to_s, :url => url }
127
+ end
128
+
129
+ def repository( name, url = nil )
130
+ if url.nil?
131
+ url = name
132
+ end
133
+ repositories << { :name => name.to_s, :url => url }
134
+ end
135
+ alias :source :repository
136
+
137
+ def jruby( version = nil )
138
+ @jruby = version if version
139
+ end
140
+
141
+ end
142
+
143
+ def populate_unlocked( container = nil, &block )
72
144
  if File.exists?(@file)
73
- File.read(@file).each_line do |line|
74
- if coord = to_coordinate(line)
75
- unless locked?(coord)
76
- container.add_artifact(coord)
145
+ dsl = DSL.new
146
+ dsl.eval_file( @file )
147
+
148
+ if block
149
+ block.call( dsl )
150
+ end
151
+ if container
152
+ dsl.artifacts.each do |a|
153
+ if path = a[ :system_path ]
154
+ container.add_local_jar( path )
155
+ elsif not locked?( a.to_s )
156
+ container.add_artifact( a.to_s )
77
157
  end
78
- elsif line =~ /^\s*(repository|source)\s/
79
- # allow `source :name, "http://url"`
80
- # allow `source "name", "http://url"`
81
- # allow `source "http://url"`
82
- # also allow `repository` instead of `source`
83
- name, url = line.sub(/.*(repository|source)\s+/, '').split(/,/)
84
- url = name unless url
85
- # remove whitespace and trailing/leading ' or "
86
- name.strip!
87
- name.gsub!(/^:/, '')
88
- name.gsub!(/^['"]|['"]$/,'')
89
- url.strip!
90
- url.gsub!(/^['"]|['"]$/,'')
91
- container.add_repository(name, url)
158
+ end
159
+ dsl.repositories.each do |repo|
160
+ container.add_repository( repo[ :name ] || repo[ 'name' ],
161
+ repo[ :url ] || repo[ 'url' ] )
162
+ end
163
+ dsl.snapshot_repositories.each do |repo|
164
+ container.add_snapshot_repository( repo[ :name ] || repo[ 'name' ],
165
+ repo[ :url ] || repo[ 'url' ] )
92
166
  end
93
167
  end
94
168
  end
@@ -112,4 +186,4 @@ module Maven
112
186
  end
113
187
 
114
188
  end
115
- end
189
+ end
@@ -0,0 +1,359 @@
1
+ require 'virtus'
2
+
3
+ module GAV
4
+ def self.included( base )
5
+ base.attribute :group_id, String
6
+ base.attribute :artifact_id, String
7
+ base.attribute :version, String
8
+ end
9
+ end
10
+ module GA
11
+ def self.included( base )
12
+ base.attribute :group_id, String
13
+ base.attribute :artifact_id, String
14
+ end
15
+ end
16
+ module SU
17
+ def self.included( base )
18
+ base.attribute :system, String
19
+ base.attribute :url, String
20
+ end
21
+ end
22
+ module NU
23
+ def self.included( base )
24
+ base.attribute :name, String
25
+ base.attribute :url, String
26
+ end
27
+ end
28
+ module INU
29
+ def self.included( base )
30
+ base.attribute :id, String
31
+ base.attribute :name, String
32
+ base.attribute :url, String
33
+ end
34
+ end
35
+
36
+ class Parent
37
+ include Virtus
38
+
39
+ include GAV
40
+
41
+ attribute :relative_path, String
42
+ end
43
+ class Organization
44
+ include Virtus
45
+
46
+ include NU
47
+ end
48
+ class License
49
+ include Virtus
50
+
51
+ include NU
52
+ attribute :distribution, String
53
+ attribute :comments, String
54
+ end
55
+ class Developer
56
+ include Virtus
57
+
58
+ include INU
59
+ attribute :email, String
60
+ attribute :organization, String
61
+ attribute :organization_url, String
62
+ attribute :roles, String
63
+ attribute :timezone, String
64
+ attribute :properties, Hash
65
+ end
66
+ class Contributor
67
+ include Virtus
68
+
69
+ include NU
70
+ attribute :email, String
71
+ attribute :organization, String
72
+ attribute :organization_url, String
73
+ attribute :roles, String
74
+ attribute :timezone, String
75
+ attribute :properties, Hash
76
+ end
77
+ class MailingList
78
+ include Virtus
79
+
80
+ attribute :name, String
81
+ attribute :subscribe, String
82
+ attribute :unsubscribe, String
83
+ attribute :post, String
84
+ attribute :archive, String
85
+ attribute :other_archives, Array[ String ]
86
+ end
87
+ class Prerequisites
88
+ include Virtus
89
+
90
+ attribute :maven, String
91
+ end
92
+ class Scm
93
+ include Virtus
94
+
95
+ attribute :connection, String
96
+ attribute :developer_connection, String
97
+ attribute :tag, String
98
+ attribute :url, String
99
+ end
100
+ class IssueManagement
101
+ include Virtus
102
+
103
+ include SU
104
+ end
105
+ class Notifier
106
+ include Virtus
107
+
108
+ attribute :type, String
109
+ attribute :send_on_error, Boolean
110
+ attribute :send_on_failure, Boolean
111
+ attribute :send_on_success, Boolean
112
+ attribute :send_on_warning, Boolean
113
+ attribute :address, String
114
+ attribute :configuration, Hash
115
+ end
116
+ class CiManagement
117
+ include Virtus
118
+
119
+ include SU
120
+
121
+ attribute :notifiers, Array[ Notifier ]
122
+ end
123
+ class Site
124
+ include Virtus
125
+
126
+ include INU
127
+ end
128
+ class Relocation
129
+ include Virtus
130
+
131
+ include GAV
132
+ attribute :message, String
133
+ end
134
+ class RepositoryPolicy
135
+ include Virtus
136
+
137
+ attribute :enabled, Boolean
138
+ attribute :update_policy, String
139
+ attribute :checksum_policy, String
140
+ end
141
+ class Repository
142
+ include Virtus
143
+
144
+ attribute :unique_version, String
145
+ attribute :releases, RepositoryPolicy
146
+ attribute :snapshot, RepositoryPolicy
147
+
148
+ include INU
149
+
150
+ attribute :layout, String
151
+ end
152
+ class PluginRepository < Repository; end
153
+ class DistributionManagement
154
+ include Virtus
155
+
156
+ attribute :repository, Repository
157
+ attribute :snapshot_repository, Repository
158
+ attribute :site, Site
159
+ attribute :download_url, String
160
+ attribute :relocation, Relocation
161
+ end
162
+ class Exclusion
163
+ include Virtus
164
+
165
+ include GA
166
+ end
167
+ class Dependency
168
+ include Virtus
169
+
170
+ include GAV
171
+
172
+ attribute :type, String
173
+ attribute :classifier, String
174
+ attribute :scope, String
175
+ attribute :system_path, String
176
+ attribute :exclusions, Array[ Exclusion ]
177
+ attribute :optional, Boolean
178
+
179
+ # silent default
180
+ def type=( t )
181
+ if t.to_sym == :jar
182
+ @type = nil
183
+ else
184
+ @type = t
185
+ end
186
+ end
187
+ end
188
+ class DependencyManagement
189
+ include Virtus
190
+
191
+ attribute :dependencies, Array[ Dependency ]
192
+ end
193
+ class Extension
194
+ include Virtus
195
+
196
+ include GAV
197
+ end
198
+ class Resource
199
+ include Virtus
200
+
201
+ attribute :target_path, String
202
+ attribute :filtering, String
203
+ attribute :directory, String
204
+ attribute :includes, Array[ String ]
205
+ attribute :excludes, Array[ String ]
206
+ end
207
+ class Execution
208
+ include Virtus
209
+
210
+ attribute :id, String
211
+ attribute :phase, String
212
+ attribute :goals, Array[ String ]
213
+ attribute :inherited, Boolean
214
+ attribute :configuration, Hash
215
+ end
216
+ class Plugin
217
+ include Virtus
218
+
219
+ include GAV
220
+ attribute :extensions, Boolean
221
+ attribute :executions, Array[ Execution ]
222
+ attribute :dependencies, Array[ Dependency ]
223
+ attribute :goals, Array[ String ]
224
+ attribute :inherited, Boolean
225
+ attribute :configuration, Hash
226
+
227
+ # silent default
228
+ def group_id=( v )
229
+ if v.to_s == 'org.apache.maven.plugins'
230
+ @group_id = nil
231
+ else
232
+ @group_id = v
233
+ end
234
+ end
235
+ end
236
+ class PluginManagement
237
+ include Virtus
238
+
239
+ attribute :plugins, Array[ Plugin ]
240
+ end
241
+ class TestResource < Resource; end
242
+ class ReportSet
243
+ include Virtus
244
+
245
+ attribute :id, String
246
+ attribute :reports, Array[ String ]
247
+ attribute :inherited, Boolean
248
+ attribute :configuration, Hash
249
+ end
250
+ class ReportPlugin
251
+ include Virtus
252
+
253
+ include GAV
254
+
255
+ attribute :report_sets, Array[ ReportSet ]
256
+ end
257
+ class Reporting
258
+ include Virtus
259
+
260
+ attribute :exclude_defaults, Boolean
261
+ attribute :output_directory, String
262
+ attribute :plugins, Array[ ReportPlugin ]
263
+ end
264
+ class Build
265
+ include Virtus
266
+
267
+ attribute :source_directory, String
268
+ attribute :script_source_directory, String
269
+ attribute :test_source_directory, String
270
+ attribute :output_directory, String
271
+ attribute :test_output_directory, String
272
+ attribute :extensions, Array[ Extension ]
273
+ attribute :default_goal, String
274
+ attribute :resources, Array[ Resource ]
275
+ attribute :test_resources, Array[ TestResource ]
276
+ attribute :directory, String
277
+ attribute :final_name, String
278
+ attribute :filters, Array[ String ]
279
+ attribute :plugin_management, PluginManagement
280
+ attribute :plugins, Array[ Plugin ]
281
+ end
282
+ class Os
283
+ include Virtus
284
+
285
+ attribute :name, String
286
+ attribute :family, String
287
+ attribute :arch, String
288
+ attribute :version, String
289
+ end
290
+ class Property
291
+ include Virtus
292
+
293
+ attribute :name, String
294
+ attribute :value, String
295
+ end
296
+ class File
297
+ include Virtus
298
+
299
+ attribute :missing, String
300
+ attribute :exists, String
301
+ end
302
+ class Activation
303
+ include Virtus
304
+
305
+ attribute :active_by_default, Boolean
306
+ attribute :jdk, String
307
+ attribute :os, Os
308
+ attribute :property, Property
309
+ attribute :file, File
310
+ end
311
+ class Profile
312
+ include Virtus
313
+
314
+ attribute :id, String
315
+ attribute :activation, Activation
316
+ attribute :build, Build
317
+ attribute :modules, Array[ String ]
318
+ attribute :distribution_management, DistributionManagement
319
+ attribute :properties, Hash
320
+ attribute :dependency_management, DependencyManagement
321
+ attribute :dependencies, Array[ Dependency ]
322
+ attribute :repositories, Array[ Repository ]
323
+ attribute :plugin_repositories, Array[ PluginRepository ]
324
+ attribute :reporting, Reporting
325
+ end
326
+ class Model
327
+ include Virtus
328
+
329
+ attribute :model_version, String
330
+ attribute :parent, Parent
331
+
332
+ include GAV
333
+
334
+ attribute :packaging, String
335
+
336
+ include NU
337
+
338
+ attribute :description, String
339
+ attribute :inception_year, String
340
+ attribute :organization, Organization
341
+ attribute :licenses, Array[ License ]
342
+ attribute :developers, Array[ Developer ]
343
+ attribute :contributors, Array[ Contributor ]
344
+ attribute :mailing_lists, Array[ MailingList ]
345
+ attribute :prerequisites, Prerequisites
346
+ attribute :modules, Array[ String ]
347
+ attribute :scm, Scm
348
+ attribute :issue_management, IssueManagement
349
+ attribute :ci_management, CiManagement
350
+ attribute :distribution_management, DistributionManagement
351
+ attribute :properties, Hash
352
+ attribute :dependency_management, DependencyManagement
353
+ attribute :dependencies, Array[ Dependency ]
354
+ attribute :repositories, Array[ Repository ]
355
+ attribute :plugin_repositories, Array[ PluginRepository ]
356
+ attribute :build, Build
357
+ attribute :reporting, Reporting
358
+ attribute :profiles, Array[ Profile ]
359
+ end