maven-tools 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b750e1a95af6fe1d7e31cba7df155f145988d12c
4
- data.tar.gz: 29771d92dab94acde14863208a8fd0fed1a41283
3
+ metadata.gz: cb25e10235359acd7536276bae2fb121b54a7236
4
+ data.tar.gz: 4c37c3d8d1292711cb69d91271a31f7904fb5f56
5
5
  SHA512:
6
- metadata.gz: 95e225b04bbd2626774f2cb0c7a198ed342b45b350d91d08b2247888154d32e60bc39de48bd479e211f5e667b65b4335004d8bd65c0b063de94a599d5d5dd89e
7
- data.tar.gz: 231b1d90bc92d85169d89560f79baaf76afbc427db67b5bbdf39d35f5bfd6d7890493df9e5785f882952eda561083286c4b390c37f513207db04eda9bf09867b
6
+ metadata.gz: e27447be1c62cce5080e2987d7b2d8468cbb8adf19c85fc07bc0c02703dfda8121c78737d911db5f7d85abfc465b1582c1606fb25c8585d6f6ffcfaf27b0f02f
7
+ data.tar.gz: ccd6c4f02a520e416a71458b3e9efef2cee45fa88181eb7248fc0f577c721afd747ca9a7c06488c12d607ad0664751126b850fdbdaff440c73b8ad9ceffcb1bb
@@ -136,7 +136,7 @@ module Maven
136
136
  self[ :artifact_id ] ||= options[ :artifact_id ]
137
137
  self[ :version ] ||= options[ :version ]
138
138
  self[ :classifier ] ||= options[ :classifier ] if options[ :classifier ]
139
- self[ :exclusions ] ||= options[ :exclusions ] if options[ :exclusions ]
139
+ self[ :exclusions ] ||= prepare( options[ :exclusions ] ) if options[ :exclusions ]
140
140
  options.delete( :group_id )
141
141
  options.delete( :artifact_id )
142
142
  options.delete( :version )
@@ -147,6 +147,41 @@ module Maven
147
147
  end
148
148
  end
149
149
 
150
+ def prepare( excl )
151
+ excl.collect do |e|
152
+ case e
153
+ when String
154
+ e
155
+ when Array
156
+ e.join ':'
157
+ else
158
+ raise 'only String and Array allowed'
159
+ end
160
+ end
161
+ end
162
+ private :prepare
163
+
164
+ ATTRS = :type=, :group_id=, :artifact_id=, :version=, :classifier=, :exclusions=, :scope=
165
+ def method_missing( m, arg = nil )
166
+ if ATTRS.member? m
167
+ # setter
168
+ self[ m.to_s[ 0..-2].to_sym ] = arg
169
+ elsif ATTRS.member?( "#{m}=".to_sym )
170
+ if arg.nil?
171
+ # getter
172
+ self[ m ]
173
+ else
174
+ # setter
175
+ self[ m ] = arg
176
+ end
177
+ else
178
+ super
179
+ end
180
+ end
181
+ def respond_to?( m )
182
+ ATTRS.member? m
183
+ end
184
+
150
185
  def gav
151
186
  [ self[:group_id], self[:artifact_id], self[:version], self[:classifier] ].select { |o| o }.join( ':' )
152
187
  end
@@ -286,12 +286,13 @@ module Maven
286
286
  private :setup_gem_support
287
287
 
288
288
  def setup_jruby( jruby, jruby_scope = :provided )
289
+ warn "deprecated: use jruby DSL directly"
289
290
  jruby ||= VERSIONS[ :jruby_version ]
290
291
 
291
- if jruby.match( /-SNAPSHOT/ ) != nil
292
- snapshot_repository( 'http://ci.jruby.org/snapshots/maven',
293
- :id => 'jruby-snapshots' )
294
- end
292
+ # if jruby.match( /-SNAPSHOT/ ) != nil
293
+ # snapshot_repository( 'http://ci.jruby.org/snapshots/maven',
294
+ # :id => 'jruby-snapshots' )
295
+ # end
295
296
  scope( jruby_scope ) do
296
297
  if ( jruby < '1.6' )
297
298
  raise 'jruby before 1.6 are not supported'
@@ -319,29 +320,25 @@ module Maven
319
320
  end
320
321
 
321
322
  if options[ :skip_locked ] or not file.exists_lock?
322
- file.populate_unlocked do |dsl|
323
- jarfile_dsl( dsl )
324
- dsl.artifacts.each do |a|
325
- _dependency a
326
- end
327
- end
323
+ dsl = file.setup_unlocked( @current )
324
+ # TODO this setup should be partly part of Jarfile
325
+ jarfile_dsl( dsl )
328
326
  else
329
327
  file.locked.each do |dep|
330
328
  artifact( dep )
331
329
  end
332
330
  file.populate_unlocked do |dsl|
331
+ dsl = file.setup_locked( @current )
332
+ # TODO this setup should be partly part of Jarfile
333
333
  jarfile_dsl( dsl )
334
- dsl.artifacts.each do |a|
335
- if a[ :system_path ]
336
- dependeny a
337
- end
334
+ dsl.parent.dependencies.each do |d|
335
+ @current.dependencies << d if d.system_path
338
336
  end
339
337
  end
340
338
  end
341
339
  end
342
340
 
343
341
  def jarfile_dsl( dsl )
344
- setup_jruby( dsl.jruby )
345
342
  dsl.repositories.each do |r|
346
343
  repository r.merge( {:id => r[:name] } )
347
344
  end
@@ -0,0 +1,88 @@
1
+ #
2
+ # Copyright (C) 2014 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 'maven/tools/artifact'
22
+ require 'maven/tools/dsl/exclusions_dsl'
23
+ module Maven
24
+ module Tools
25
+ module DSL
26
+ class DependencyDSL < Artifact
27
+ extend Options
28
+ include Models
29
+
30
+ class << self
31
+ def create( parent, type, scope, *args, &block )
32
+ a = DependencyDSL.from( type, *args, &block )
33
+ a.scope = scope if scope
34
+
35
+ options = process_exclusions( a.model, a.dup )
36
+ a.instance_eval &block if block
37
+ fill_options( a.model, options, :type )
38
+ parent.dependencies << a.model
39
+ a
40
+ end
41
+
42
+ private
43
+
44
+ def process_exclusions( dep, options )
45
+ exclusions = options.delete( :exclusions )
46
+ if exclusions && exclusions.size > 0# && dep.exclusions.size == 0
47
+ ExclusionsDSL.create( dep, *exclusions )
48
+ end
49
+ options
50
+ end
51
+ end
52
+
53
+ def initialize( *args )
54
+ super
55
+ @model = Dependency.new
56
+ end
57
+
58
+ def help
59
+ type = self[:type]
60
+ warn self.class.help( type, :group_id, :artifact_id, :version, :classifier, :exclusions, :scope => '{:compile|:test|:provided|:runtime}', :exclusions => nil, :exclusion => nil) + <<EOS
61
+ argument: #{type} 'group_id:artifact_id:version'
62
+ argument: #{type} 'group_id:artifact_id:classifier:version'
63
+ arguments: #{type} 'group_id:artifact_id','version'
64
+ arguments: #{type} 'group_id:artifact_id','classifier,'version'
65
+ arguments: #{type} 'group_id','artifact_id','version'
66
+ arguments: #{type} 'group_id','artifact_id','classifier,'version'
67
+ EOS
68
+ end
69
+
70
+ def exclusions( *args, &block )
71
+ # TODO remove this part
72
+ if args.empty?
73
+ super
74
+ else
75
+ self[ :exclusions ] = ExclusionsDSL.create( @model, *args, &block ).to_coordinate_array
76
+ end
77
+ end
78
+
79
+ def exclusion( *args, &block )
80
+ e = ExclusionDSL.create( @model, *args, &block )
81
+ # TODO remove this part
82
+ self[ :exclusions ] ||= []
83
+ self[ :exclusions ] << e.to_coordinate
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,95 @@
1
+ #
2
+ # Copyright (C) 2014 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 'maven/tools/dsl/options'
22
+ require 'maven/tools/dsl/models'
23
+ module Maven
24
+ module Tools
25
+ module DSL
26
+ class ExclusionsDSL < Array
27
+ extend Options
28
+ def self.create( dep, *args, &block )
29
+ a = ExclusionsDSL.new( dep )
30
+ args.each do |arg|
31
+ a << ExclusionDSL.create( dep, *arg )
32
+ end
33
+ a.instance_eval( &block ) if block
34
+ a
35
+ end
36
+
37
+ def initialize( dep )
38
+ @dep = dep
39
+ end
40
+
41
+ def help
42
+ warn self.class.help( 'exclusions', :exclusion => nil ) + <<EOS
43
+ arguments: exclusions 'group_id:artifact_id1', 'group_id:artifact_id2'
44
+ arguments: exclusions ['group_id','artifact_id1'], ['group_id','artifact_id2']
45
+ EOS
46
+ end
47
+
48
+ def exclusion( *args, &block )
49
+ self << ExclusionDSL.create( @dep, *args, &block )
50
+ end
51
+
52
+ def to_coordinate_array
53
+ self.collect do |a|
54
+ a.to_coordinate
55
+ end
56
+ end
57
+ end
58
+
59
+ class ExclusionDSL
60
+ extend Options
61
+ include Models
62
+
63
+ def self.create( dep, *args, &block )
64
+ args, options = args_and_options( *args )
65
+ e = ExclusionDSL.new
66
+ case args.size
67
+ when 1
68
+ e.group_id, e.artifact_id = args[0].split( /:/ )
69
+ when 2
70
+ e.group_id, e.artifact_id = *args
71
+ end
72
+ e.instance_eval( &block ) if block
73
+ fill_options( e, options || {} )
74
+ dep.exclusions << e.model
75
+ e
76
+ end
77
+
78
+ def initialize
79
+ @model = Exclusion.new
80
+ end
81
+
82
+ def help
83
+ warn self.class.help( 'exclusion', :group_id, :artifact_id ) + <<EOS
84
+ argument: exclusion 'group_id:artifact_id'
85
+ arguments: exclusion 'group_id','artifact_id'
86
+ EOS
87
+ end
88
+
89
+ def to_coordinate
90
+ "#{@model.group_id}:#{@model.artifact_id}"
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,114 @@
1
+ #
2
+ # Copyright (C) 2014 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 'maven/tools/dsl/jruby_dsl'
22
+ require 'maven/tools/dsl/dependency_dsl'
23
+ module Maven
24
+ module Tools
25
+ module DSL
26
+ class Jarfile
27
+ extend Options
28
+
29
+ class Data
30
+ def dependencies
31
+ @dependencies ||= []
32
+ end
33
+ end
34
+
35
+ def artifacts
36
+ # TODO remove this part
37
+ @artifacts ||= []
38
+ end
39
+
40
+ def repositories
41
+ @repositories ||= []
42
+ end
43
+
44
+ def snapshot_repositories
45
+ @snapshot_repositories ||= []
46
+ end
47
+
48
+ def initialize( file = 'Jarfile', parent = Data.new )
49
+ @parent = parent
50
+ eval( File.read( file ) )
51
+ end
52
+ attr_reader :parent
53
+
54
+ def help
55
+ warn "\n# Jarfile DSL #\n"
56
+ warn self.class.help_block( :local => "path-to-local-jar", :jar => nil, :pom => nil, :repository => nil, :snapshot_repository => nil, :jruby => nil, :scope => nil)[0..-2]
57
+ end
58
+
59
+ def local( path )
60
+ a = Artifact.new_local( ::File.expand_path( path ), :jar )
61
+ dep = Dependency.new
62
+ self.class.fill_options( dep, a )
63
+ @parent.dependencies << dep
64
+ # TODO remove this part
65
+ artifacts << a
66
+ end
67
+
68
+ def jar( *args, &block )
69
+ a = DependencyDSL.create( @parent, :jar, @scope, *args, &block )
70
+ # TODO remove this part
71
+ artifacts << a
72
+ a
73
+ end
74
+
75
+ def pom( *args, &block )
76
+ a = DependencyDSL.create( @parent, :pom, @scope, *args, &block )
77
+ # TODO remove this part
78
+ artifacts << a
79
+ a
80
+ end
81
+
82
+ def snapshot_repository( name, url = nil )
83
+ if url.nil?
84
+ url = name
85
+ end
86
+ snapshot_repositories << { :name => name.to_s, :url => url }
87
+ end
88
+
89
+ def repository( name, url = nil )
90
+ if url.nil?
91
+ url = name
92
+ end
93
+ repositories << { :name => name.to_s, :url => url }
94
+ end
95
+ alias :source :repository
96
+
97
+ def scope( scope )
98
+ @scope = scope
99
+ yield if block_given?
100
+ ensure
101
+ @scope = nil
102
+ end
103
+
104
+ def jruby( *args, &block )
105
+ if args.empty? && !block
106
+ @jruby ? @jruby.legacy_version : nil
107
+ else
108
+ @jruby = JRubyDSL.create( @parent, :provided, *args, &block )
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,111 @@
1
+ #
2
+ # Copyright (C) 2014 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 'maven/tools/dsl/options'
22
+ require 'maven/tools/dsl/models'
23
+ module Maven
24
+ module Tools
25
+ module DSL
26
+ class RepositoryDSL
27
+ extend Options
28
+ include Models
29
+
30
+ def self.create( parent, *args, &block )
31
+
32
+ end
33
+ end
34
+ class JRubyDSL
35
+ extend Options
36
+
37
+ def self.create( parent, scope, *args, &block )
38
+ args, options = args_and_options( *args )
39
+ j = JRubyDSL.new( parent, scope, &block )
40
+ j.version args[0]
41
+ j.no_asm args[1]
42
+ fill_options( j, options || {} )
43
+ j.apply
44
+ j
45
+ end
46
+
47
+ def initialize( parent, scope, &block )
48
+ @parent = parent
49
+ @data = {}
50
+ self.scope scope
51
+ self.instance_eval( &block ) if block
52
+ end
53
+
54
+ def dependency( type, artifact_id )
55
+ dep = Dependency.new
56
+ dep.type = type
57
+ dep.group_id = 'org.jruby'
58
+ dep.artifact_id = artifact_id
59
+ dep.version = version
60
+ dep.scope = scope
61
+ @parent.dependencies << dep
62
+ end
63
+ private :dependency
64
+
65
+ def apply
66
+ if version.nil?
67
+ # nothing to do
68
+ elsif( version < '1.6' )
69
+ raise 'jruby before 1.6 are not supported'
70
+ elsif ( version < '1.7' )
71
+ warn 'jruby version below 1.7 uses jruby-complete'
72
+ dependency :jar, 'jruby-complete'
73
+ elsif ( version.sub( /1\.7\./, '').to_i < 5 )
74
+ dependency :jar, 'jruby-core'
75
+ elsif no_asm
76
+ dependency :pom, 'jruby-noasm'
77
+ else
78
+ dependency :pom, 'jruby-noasm'
79
+ end
80
+ end
81
+
82
+ def legacy_version
83
+ v = version
84
+ v+= '-no_asm' if no_asm
85
+ v
86
+ end
87
+
88
+ def help
89
+ warn self.class.help( 'jruby', :scope, :version, :no_asm => true, :jar => nil ) + <<EOS
90
+ argument: jruby 'version'
91
+ arguments: jruby 'version', true
92
+ EOS
93
+ end
94
+
95
+ def jar( *args, &block )
96
+ DependencyDSL.create( @parent, :jar, scope, *args, &block )
97
+ end
98
+
99
+ [ :scope, :version, :no_asm ].each do |meth|
100
+ define_method( meth ) do |arg = nil|
101
+ @data[ meth ] = arg if arg
102
+ @data[ meth ]
103
+ end
104
+ define_method( "#{meth}=" ) do |arg|
105
+ @data[ meth ] = arg
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,48 @@
1
+ #
2
+ # Copyright (C) 2014 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
+ module Maven
22
+ module Tools
23
+ module DSL
24
+ module Models
25
+ def model
26
+ @model
27
+ end
28
+
29
+ def respond_to?( m )
30
+ @model.respond_to?( m ) || @model.respond_to?( m.to_s[ 0..-2 ].to_sym )
31
+ end
32
+
33
+ def method_missing( m, *args )
34
+ if @model.respond_to? m
35
+ meth = @model.method m
36
+ if meth.arity == 0 && args.size == 1
37
+ @model.send( "#{m}=".to_sym, *args )
38
+ else
39
+ @model.send( m, *args )
40
+ end
41
+ else
42
+ super
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,87 @@
1
+ #
2
+ # Copyright (C) 2014 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
+ module Maven
22
+ module Tools
23
+ module DSL
24
+ module Options
25
+
26
+ def args_and_options( *args )
27
+ if args.last.is_a? Hash
28
+ [ args[0..-2], args.last ]
29
+ else
30
+ [ args, {} ]
31
+ end
32
+ end
33
+
34
+ def fill_options( receiver, options, *allow_defaults )
35
+ options.each do |k,v|
36
+ if ! allow_defaults.member?( k ) && receiver.send( "#{k}".to_sym )
37
+ raise "#{receiver} has attribute #{k} already set"
38
+ end
39
+ receiver.send( "#{k}=".to_sym, v )
40
+ end
41
+ end
42
+
43
+ def help( name, *args )
44
+ args, options = args_and_options( *args )
45
+ args.each do |a|
46
+ options[ a ] = a.to_s if a && !options.key?( a )
47
+ end
48
+ opts = options.select{ |k,v| v }
49
+ t = "\n# " + name.to_s.upcase + " #\n\n"
50
+ unless opts.empty?
51
+ t += "hash options: #{name} #{opts.inspect.gsub( /\"[{]/, '(' ).gsub( /[}]\"/, ')' )}\n"
52
+ end
53
+ t += "nested: #{name} do\n"
54
+ t = append_nested_block( options, t )
55
+ t += " end\n"
56
+ t
57
+ end
58
+
59
+ def help_block( *args )
60
+ args, options = help_args_and_options( *args )
61
+ append_nested_block( options )
62
+ end
63
+
64
+ private
65
+
66
+ def help_args_and_options( *args )
67
+ args, options = args_and_options( *args )
68
+ args.each do |a|
69
+ options[ a ] = a.to_s if a && !options.key?( a )
70
+ end
71
+ [ args, options ]
72
+ end
73
+
74
+ def append_nested_block( options, t = "")
75
+ options.each do |k,v|
76
+ if v
77
+ t += " #{k} #{v.inspect.gsub( /\"[{]/, '(' ).gsub( /[}]\"/, ')' )}\n"
78
+ else
79
+ t += " #{k} # nested element\n"
80
+ end
81
+ end
82
+ t
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
@@ -21,6 +21,8 @@
21
21
  require ::File.join(::File.dirname(__FILE__), 'coordinate.rb')
22
22
  require ::File.join(::File.dirname(__FILE__), 'artifact.rb')
23
23
  require 'fileutils'
24
+ require 'delegate'
25
+ require 'maven/tools/dsl/jarfile'
24
26
  module Maven
25
27
  module Tools
26
28
 
@@ -79,6 +81,7 @@ module Maven
79
81
  end
80
82
 
81
83
  def eval_file( file )
84
+ warn "#{self.class} is deprecated"
82
85
  if ::File.exists?( file )
83
86
  eval( ::File.read( file ), nil, file )
84
87
  self
@@ -152,10 +155,28 @@ module Maven
152
155
 
153
156
  end
154
157
 
158
+ class LockedParent < SimpleDelegator
159
+ def initialize(obj)
160
+ super
161
+ end
162
+
163
+ def dependencies
164
+ @d ||= []
165
+ end
166
+ end
167
+
168
+ def setup_unlocked( parent )
169
+ Maven::Tools::DSL::Jarfile.new( @file, parent )
170
+ end
171
+
172
+ def setup_locked( parent )
173
+ Maven::Tools::DSL::Jarfile.new( @file, LockedParent.new( parent ) )
174
+ end
175
+
155
176
  def populate_unlocked( container = nil, &block )
156
177
  if ::File.exists?(@file)
157
- dsl = DSL.new
158
- dsl.eval_file( @file )
178
+ dsl = Maven::Tools::DSL::Jarfile.new( @file )
179
+ #dsl.eval_file( @file )
159
180
 
160
181
  if block
161
182
  block.call( dsl )
@@ -20,6 +20,6 @@
20
20
  #
21
21
  module Maven
22
22
  module Tools
23
- VERSION = '1.0.4'.freeze
23
+ VERSION = '1.0.5'.freeze
24
24
  end
25
25
  end
@@ -1,3 +1,5 @@
1
1
  jar 'junit:junit', '4.11'
2
2
 
3
3
  local './myfirst.jar'
4
+
5
+ jruby :version => '1.7.13'
@@ -16,13 +16,6 @@
16
16
  <version>0.0.0</version>
17
17
  <name>example from jarfile</name>
18
18
  <dependencies>
19
- <dependency>
20
- <groupId>org.jruby</groupId>
21
- <artifactId>jruby</artifactId>
22
- <version>1.7.13</version>
23
- <type>pom</type>
24
- <scope>provided</scope>
25
- </dependency>
26
19
  <dependency>
27
20
  <groupId>junit</groupId>
28
21
  <artifactId>junit</artifactId>
@@ -35,5 +28,12 @@
35
28
  <scope>system</scope>
36
29
  <systemPath>myfirst.jar</systemPath>
37
30
  </dependency>
31
+ <dependency>
32
+ <groupId>org.jruby</groupId>
33
+ <artifactId>jruby-noasm</artifactId>
34
+ <version>1.7.13</version>
35
+ <type>pom</type>
36
+ <scope>provided</scope>
37
+ </dependency>
38
38
  </dependencies>
39
39
  </project>
@@ -0,0 +1,13 @@
1
+ help
2
+
3
+ jar 'asd:asd' do
4
+ help
5
+ exclusions 'asd:asd' do help; end
6
+ exclusion do help; end
7
+ end
8
+
9
+ pom 'asd:asd' do
10
+ help
11
+ end
12
+
13
+ jruby do help; end
@@ -0,0 +1,5 @@
1
+ project 'example from jarfile' do
2
+
3
+ jarfile
4
+
5
+ end
@@ -0,0 +1,37 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+
4
+ Copyright (c) 2012 to original author or authors
5
+ All rights reserved. This program and the accompanying materials
6
+ are made available under the terms of the Eclipse Public License v1.0
7
+ which accompanies this distribution, and is available at
8
+ http://www.eclipse.org/legal/epl-v10.html
9
+
10
+ -->
11
+ <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
12
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
13
+ <modelVersion>4.0.0</modelVersion>
14
+ <groupId>no_group_id_given</groupId>
15
+ <artifactId>pom_from_jarfile_help_only</artifactId>
16
+ <version>0.0.0</version>
17
+ <name>example from jarfile</name>
18
+ <dependencies>
19
+ <dependency>
20
+ <groupId>asd</groupId>
21
+ <artifactId>asd</artifactId>
22
+ <exclusions>
23
+ <exclusion>
24
+ <groupId>asd</groupId>
25
+ <artifactId>asd</artifactId>
26
+ </exclusion>
27
+ <exclusion>
28
+ </exclusion>
29
+ </exclusions>
30
+ </dependency>
31
+ <dependency>
32
+ <groupId>asd</groupId>
33
+ <artifactId>asd</artifactId>
34
+ <type>pom</type>
35
+ </dependency>
36
+ </dependencies>
37
+ </project>
@@ -0,0 +1,19 @@
1
+ jar 'asd:asd:123' do
2
+ scope 'test'
3
+ classifier 'source'
4
+ exclusions 'group:a1', ['group','a2'] do
5
+ exclusion 'group', 'a3'
6
+ exclusion :artifact_id => 'a4', :group_id => 'group'
7
+ exclusion 'group:a5'
8
+ exclusion 'group' do
9
+ artifact_id 'a6'
10
+ end
11
+ exclusion do
12
+ group_id 'group'
13
+ artifact_id 'a7'
14
+ end
15
+ end
16
+ end
17
+ jar 'dsa:dsa', '12', :exclusions => ['group:b1', ['group','b2']], :classifier => 'provided' do
18
+ exclusion 'group:b3'
19
+ end
@@ -0,0 +1,5 @@
1
+ project 'example from jarfile' do
2
+
3
+ jarfile
4
+
5
+ end
@@ -0,0 +1,76 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+
4
+ Copyright (c) 2012 to original author or authors
5
+ All rights reserved. This program and the accompanying materials
6
+ are made available under the terms of the Eclipse Public License v1.0
7
+ which accompanies this distribution, and is available at
8
+ http://www.eclipse.org/legal/epl-v10.html
9
+
10
+ -->
11
+ <project>
12
+ <modelVersion>4.0.0</modelVersion>
13
+ <groupId>no_group_id_given</groupId>
14
+ <artifactId>pom_from_jarfile_with_exclusions</artifactId>
15
+ <version>0.0.0</version>
16
+ <name>example from jarfile</name>
17
+ <dependencies>
18
+ <dependency>
19
+ <groupId>asd</groupId>
20
+ <artifactId>asd</artifactId>
21
+ <version>123</version>
22
+ <classifier>source</classifier>
23
+ <scope>test</scope>
24
+ <exclusions>
25
+ <exclusion>
26
+ <groupId>group</groupId>
27
+ <artifactId>a1</artifactId>
28
+ </exclusion>
29
+ <exclusion>
30
+ <groupId>group</groupId>
31
+ <artifactId>a2</artifactId>
32
+ </exclusion>
33
+ <exclusion>
34
+ <groupId>group</groupId>
35
+ <artifactId>a3</artifactId>
36
+ </exclusion>
37
+ <exclusion>
38
+ <groupId>group</groupId>
39
+ <artifactId>a4</artifactId>
40
+ </exclusion>
41
+ <exclusion>
42
+ <groupId>group</groupId>
43
+ <artifactId>a5</artifactId>
44
+ </exclusion>
45
+ <exclusion>
46
+ <groupId>group</groupId>
47
+ <artifactId>a6</artifactId>
48
+ </exclusion>
49
+ <exclusion>
50
+ <groupId>group</groupId>
51
+ <artifactId>a7</artifactId>
52
+ </exclusion>
53
+ </exclusions>
54
+ </dependency>
55
+ <dependency>
56
+ <groupId>dsa</groupId>
57
+ <artifactId>dsa</artifactId>
58
+ <version>12</version>
59
+ <classifier>provided</classifier>
60
+ <exclusions>
61
+ <exclusion>
62
+ <groupId>group</groupId>
63
+ <artifactId>b1</artifactId>
64
+ </exclusion>
65
+ <exclusion>
66
+ <groupId>group</groupId>
67
+ <artifactId>b2</artifactId>
68
+ </exclusion>
69
+ <exclusion>
70
+ <groupId>group</groupId>
71
+ <artifactId>b3</artifactId>
72
+ </exclusion>
73
+ </exclusions>
74
+ </dependency>
75
+ </dependencies>
76
+ </project>
@@ -0,0 +1,5 @@
1
+ jruby '1.7.16' do
2
+ no_asm true
3
+ scope :compile
4
+ jar 'joda-time:joda-time', '2.6'
5
+ end
@@ -0,0 +1,5 @@
1
+ project 'example from jarfile' do
2
+
3
+ jarfile
4
+
5
+ end
@@ -0,0 +1,32 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+
4
+ Copyright (c) 2012 to original author or authors
5
+ All rights reserved. This program and the accompanying materials
6
+ are made available under the terms of the Eclipse Public License v1.0
7
+ which accompanies this distribution, and is available at
8
+ http://www.eclipse.org/legal/epl-v10.html
9
+
10
+ -->
11
+ <project>
12
+ <modelVersion>4.0.0</modelVersion>
13
+ <groupId>no_group_id_given</groupId>
14
+ <artifactId>pom_from_jarfile_with_jruby</artifactId>
15
+ <version>0.0.0</version>
16
+ <name>example from jarfile</name>
17
+ <dependencies>
18
+ <dependency>
19
+ <groupId>joda-time</groupId>
20
+ <artifactId>joda-time</artifactId>
21
+ <version>2.6</version>
22
+ <scope>compile</scope>
23
+ </dependency>
24
+ <dependency>
25
+ <groupId>org.jruby</groupId>
26
+ <artifactId>jruby-noasm</artifactId>
27
+ <version>1.7.16</version>
28
+ <type>pom</type>
29
+ <scope>compile</scope>
30
+ </dependency>
31
+ </dependencies>
32
+ </project>
@@ -16,13 +16,6 @@
16
16
  <version>0.0.0</version>
17
17
  <name>pom_from_jarfile_with_repos</name>
18
18
  <dependencies>
19
- <dependency>
20
- <groupId>org.jruby</groupId>
21
- <artifactId>jruby</artifactId>
22
- <version>1.7.13</version>
23
- <type>pom</type>
24
- <scope>provided</scope>
25
- </dependency>
26
19
  <dependency>
27
20
  <groupId>junit</groupId>
28
21
  <artifactId>junit</artifactId>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maven-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Meier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-19 00:00:00.000000000 Z
11
+ date: 2014-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: virtus
@@ -76,6 +76,12 @@ files:
76
76
  - lib/maven/tools/jarfile.rb
77
77
  - lib/maven/tools/pom.rb
78
78
  - lib/maven/tools/coordinate.rb
79
+ - lib/maven/tools/dsl/models.rb
80
+ - lib/maven/tools/dsl/dependency_dsl.rb
81
+ - lib/maven/tools/dsl/jarfile.rb
82
+ - lib/maven/tools/dsl/jruby_dsl.rb
83
+ - lib/maven/tools/dsl/exclusions_dsl.rb
84
+ - lib/maven/tools/dsl/options.rb
79
85
  - spec/artifact_spec.rb
80
86
  - spec/jarfile_spec.rb
81
87
  - spec/coordinate_spec.rb
@@ -83,9 +89,11 @@ files:
83
89
  - spec/spec_helper.rb
84
90
  - spec/gemspec_dependencies_spec.rb
85
91
  - spec/gemfile_with_source/bouncy-castle-version.rb
92
+ - spec/pom_from_jarfile_with_jruby/pom.rb
86
93
  - spec/pom_maven_style/pom.rb
87
94
  - spec/gemspec_in_profile/bouncy-castle-version.rb
88
95
  - spec/gemfile_with_lock/bouncy-castle-version.rb
96
+ - spec/pom_from_jarfile_help_only/pom.rb
89
97
  - spec/pom_from_jarfile/pom.rb
90
98
  - spec/gemfile_include_jars/bouncy-castle-version.rb
91
99
  - spec/gemfile/bouncy-castle-version.rb
@@ -96,11 +104,13 @@ files:
96
104
  - spec/gemspec_include_jars/bouncy-castle-version.rb
97
105
  - spec/gemspec_with_extras/bouncy-castle-version.rb
98
106
  - spec/gemfile_with_extras/bouncy-castle-version.rb
107
+ - spec/pom_from_jarfile_with_exclusions/pom.rb
99
108
  - spec/pom_maven_alternative_style/pom.rb
100
109
  - MIT-LICENSE
101
110
  - README.md
102
111
  - spec/pom.xml
103
112
  - spec/gemfile_with_source/pom.xml
113
+ - spec/pom_from_jarfile_with_jruby/pom.xml
104
114
  - spec/gemspec_in_profile/pom.xml
105
115
  - spec/pom_from_jarfile_with_repos/pom.xml
106
116
  - spec/gemfile_with_lock/pom.xml
@@ -109,6 +119,7 @@ files:
109
119
  - spec/gemspec_with_custom_source_and_custom_jarname/pom.xml
110
120
  - spec/gemspec_prerelease_snapshot/pom.xml
111
121
  - spec/gemfile_with_path/pom.xml
122
+ - spec/pom_from_jarfile_help_only/pom.xml
112
123
  - spec/gemfile_with_source_and_custom_jarname/pom.xml
113
124
  - spec/pom_from_jarfile/pom.xml
114
125
  - spec/gemspec_no_rubygems_repo/pom.xml
@@ -134,7 +145,9 @@ files:
134
145
  - spec/gemspec_with_extras/pom.xml
135
146
  - spec/gemspec_with_source_and_no_jar/pom.xml
136
147
  - spec/gemfile_with_extras/pom.xml
148
+ - spec/pom_from_jarfile_with_exclusions/pom.xml
137
149
  - spec/gemfile_with_source/Mavenfile
150
+ - spec/pom_from_jarfile_with_jruby/Jarfile
138
151
  - spec/gemspec_in_profile/Mavenfile
139
152
  - spec/pom_from_jarfile_with_repos/Jarfile
140
153
  - spec/pom_from_jarfile_with_repos/Mavenfile
@@ -147,6 +160,7 @@ files:
147
160
  - spec/gemspec_prerelease_snapshot/Mavenfile
148
161
  - spec/gemfile_with_path/Mavenfile
149
162
  - spec/gemfile_with_path/Gemfile
163
+ - spec/pom_from_jarfile_help_only/Jarfile
150
164
  - spec/gemfile_with_source_and_custom_jarname/Mavenfile
151
165
  - spec/gemfile_with_source_and_custom_jarname/Gemfile
152
166
  - spec/pom_from_jarfile/Jarfile
@@ -184,6 +198,7 @@ files:
184
198
  - spec/gemspec_with_source_and_no_jar/Mavenfile
185
199
  - spec/gemfile_with_extras/Mavenfile
186
200
  - spec/gemfile_with_extras/Gemfile
201
+ - spec/pom_from_jarfile_with_exclusions/Jarfile
187
202
  - spec/gemfile_with_lock/Gemfile.lock
188
203
  - spec/gemfile_with_test_group/Gemfile.lock
189
204
  - spec/gemfile_with_groups_and_lockfile/Gemfile.lock
@@ -255,9 +270,11 @@ test_files:
255
270
  - spec/spec_helper.rb
256
271
  - spec/gemspec_dependencies_spec.rb
257
272
  - spec/gemfile_with_source/bouncy-castle-version.rb
273
+ - spec/pom_from_jarfile_with_jruby/pom.rb
258
274
  - spec/pom_maven_style/pom.rb
259
275
  - spec/gemspec_in_profile/bouncy-castle-version.rb
260
276
  - spec/gemfile_with_lock/bouncy-castle-version.rb
277
+ - spec/pom_from_jarfile_help_only/pom.rb
261
278
  - spec/pom_from_jarfile/pom.rb
262
279
  - spec/gemfile_include_jars/bouncy-castle-version.rb
263
280
  - spec/gemfile/bouncy-castle-version.rb
@@ -268,9 +285,11 @@ test_files:
268
285
  - spec/gemspec_include_jars/bouncy-castle-version.rb
269
286
  - spec/gemspec_with_extras/bouncy-castle-version.rb
270
287
  - spec/gemfile_with_extras/bouncy-castle-version.rb
288
+ - spec/pom_from_jarfile_with_exclusions/pom.rb
271
289
  - spec/pom_maven_alternative_style/pom.rb
272
290
  - spec/pom.xml
273
291
  - spec/gemfile_with_source/pom.xml
292
+ - spec/pom_from_jarfile_with_jruby/pom.xml
274
293
  - spec/gemspec_in_profile/pom.xml
275
294
  - spec/pom_from_jarfile_with_repos/pom.xml
276
295
  - spec/gemfile_with_lock/pom.xml
@@ -279,6 +298,7 @@ test_files:
279
298
  - spec/gemspec_with_custom_source_and_custom_jarname/pom.xml
280
299
  - spec/gemspec_prerelease_snapshot/pom.xml
281
300
  - spec/gemfile_with_path/pom.xml
301
+ - spec/pom_from_jarfile_help_only/pom.xml
282
302
  - spec/gemfile_with_source_and_custom_jarname/pom.xml
283
303
  - spec/pom_from_jarfile/pom.xml
284
304
  - spec/gemspec_no_rubygems_repo/pom.xml
@@ -304,7 +324,9 @@ test_files:
304
324
  - spec/gemspec_with_extras/pom.xml
305
325
  - spec/gemspec_with_source_and_no_jar/pom.xml
306
326
  - spec/gemfile_with_extras/pom.xml
327
+ - spec/pom_from_jarfile_with_exclusions/pom.xml
307
328
  - spec/gemfile_with_source/Mavenfile
329
+ - spec/pom_from_jarfile_with_jruby/Jarfile
308
330
  - spec/gemspec_in_profile/Mavenfile
309
331
  - spec/pom_from_jarfile_with_repos/Jarfile
310
332
  - spec/pom_from_jarfile_with_repos/Mavenfile
@@ -317,6 +339,7 @@ test_files:
317
339
  - spec/gemspec_prerelease_snapshot/Mavenfile
318
340
  - spec/gemfile_with_path/Mavenfile
319
341
  - spec/gemfile_with_path/Gemfile
342
+ - spec/pom_from_jarfile_help_only/Jarfile
320
343
  - spec/gemfile_with_source_and_custom_jarname/Mavenfile
321
344
  - spec/gemfile_with_source_and_custom_jarname/Gemfile
322
345
  - spec/pom_from_jarfile/Jarfile
@@ -354,6 +377,7 @@ test_files:
354
377
  - spec/gemspec_with_source_and_no_jar/Mavenfile
355
378
  - spec/gemfile_with_extras/Mavenfile
356
379
  - spec/gemfile_with_extras/Gemfile
380
+ - spec/pom_from_jarfile_with_exclusions/Jarfile
357
381
  - spec/gemfile_with_lock/Gemfile.lock
358
382
  - spec/gemfile_with_test_group/Gemfile.lock
359
383
  - spec/gemfile_with_groups_and_lockfile/Gemfile.lock