Module: Maven::Tools::DSL

Included in:
POM
Defined in:
lib/maven/tools/dsl.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
# File 'lib/maven/tools/dsl.rb', line 948

def method_missing( method, *args, &block )
  if @context
    m = "#{method}=".to_sym
    if @current.respond_to? m
      #p @context
      #p m
      #p args
      begin

        if defined?(JRUBY_VERSION) and
            not RUBY_VERSION =~ /1.8/ and
            args.size > 1

          @current.send( m, args, &block )

        else
          @current.send( m, *args, &block )
        end
      rescue TypeError
        # assume single argument
        @current.send( m, args[0].to_s, &block )              
      rescue ArgumentError
        begin
          @current.send( m, args )
        rescue ArgumentError => e
          if @current.respond_to? method
            @current.send( method, *args )
          end
        end
      end
      @current
    else
      if ( args.size > 0 &&
           args[0].is_a?( String ) &&
           args[0] =~ /^[${}0-9a-zA-Z._-]+(:[${}0-9a-zA-Z._-]+)+$/ ) ||
          ( args.size == 1 && args[0].is_a?( Hash ) )
        mm = method.to_s
        case mm[ (mm.size - 1)..-1 ]
        when '?'
          dependency?( method.to_s[0..-2].to_sym, *args )
        when '!'
          dependency!( method.to_s[0..-2].to_sym, *args )
        else
          dependency( method, *args )
        end
        # elsif @current.respond_to? method
        #   @current.send( method, *args )
        #   @current
      else
        p @context
        p m
        p args
      end
    end
  else
    super
  end
end

Instance Method Details

#activation(&block) ⇒ Object



443
444
445
446
447
# File 'lib/maven/tools/dsl.rb', line 443

def activation( &block )
  activation = Activation.new
  nested_block( :activation, activation, block ) if block
  @current.activation = activation
end

#add_execute_task(options, &block) ⇒ Object

hook for polyglot maven to register those tasks



696
697
698
699
700
701
702
703
704
# File 'lib/maven/tools/dsl.rb', line 696

def add_execute_task( options, &block )
  plugin!( 'io.tesla.polyglot:tesla-polyglot-maven-plugin',
           VERSIONS[ :tesla_version ] ) do
    execute_goal( :execute, options )
    
    jar!( 'io.tesla.polyglot:tesla-polyglot-ruby',
          VERSIONS[ :tesla_version ] )
  end
end

#archives(*archives) ⇒ Object



391
392
393
394
# File 'lib/maven/tools/dsl.rb', line 391

def archives( *archives )
  @current.archive = archives.shift
  @current.other_archives = archives
end

#args_and_options(*args) ⇒ Object



529
530
531
532
533
534
535
# File 'lib/maven/tools/dsl.rb', line 529

def args_and_options( *args )
  if args.last.is_a? Hash
    [ args[0..-2], args.last ]
  else
    [ args, {} ]
  end
end

#artifact(a) ⇒ Object



55
56
57
58
59
60
# File 'lib/maven/tools/dsl.rb', line 55

def artifact( a )
  if a.is_a?( String )
    a = Maven::Tools::Artifact.from_coordinate( a )
  end
  self.send a[:type].to_sym, a
end

#basedir(basedir = nil) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/maven/tools/dsl.rb', line 46

def basedir( basedir = nil )
  @basedir ||= basedir if basedir
  if @source
    @basedir ||= File.directory?( @source ) ? @source : 
      File.dirname( File.expand_path( @source ) )
  end
  @basedir ||= File.expand_path( '.' )
end

#build(&block) ⇒ Object



295
296
297
298
299
# File 'lib/maven/tools/dsl.rb', line 295

def build( &block )
  build = @current.build ||= Build.new
  nested_block( :build, build, block ) if block
  build
end

#contributor(*args, &block) ⇒ Object



413
414
415
416
417
418
419
420
421
422
423
# File 'lib/maven/tools/dsl.rb', line 413

def contributor( *args, &block )
  con = Contributor.new
  args, options = args_and_options( *args )
  con.name = args[ 0 ]
  con.url = args[ 1 ]
  con.email = args[ 2 ]
  fill_options( con, options )
  nested_block( :contributor, con, block ) if block
  @current.contributors << con
  con
end

#dependency(type, *args) ⇒ Object



745
746
747
# File 'lib/maven/tools/dsl.rb', line 745

def dependency( type, *args )
  do_dependency( false, type, *args )
end

#dependency!(type, *args) ⇒ Object



749
750
751
# File 'lib/maven/tools/dsl.rb', line 749

def dependency!( type, *args )
  do_dependency( true, type, *args )
end

#dependency?(type, *args) ⇒ Boolean

Returns:

  • (Boolean)


753
754
755
756
# File 'lib/maven/tools/dsl.rb', line 753

def dependency?( type, *args )
  find_dependency( dependency_container,
                   retrieve_dependency( type, *args ) ) != nil
end

#dependency_containerObject



795
796
797
798
799
800
801
802
# File 'lib/maven/tools/dsl.rb', line 795

def dependency_container
  if @context == :overrides
    @current.dependency_management ||= DependencyManagement.new
    @current.dependency_management.dependencies
  else
    @current.dependencies
  end
end

#dependency_set(bang, container, dep) ⇒ Object



764
765
766
767
768
769
770
771
772
773
774
775
# File 'lib/maven/tools/dsl.rb', line 764

def dependency_set( bang, container, dep )
  if bang
    dd = do_dependency?( container, dep )
    if index = container.index( dd )
      container[ index ] = dep
    else
      container << dep
    end
  else
    container << dep
  end
end

#developer(*args, &block) ⇒ Object



400
401
402
403
404
405
406
407
408
409
410
411
# File 'lib/maven/tools/dsl.rb', line 400

def developer( *args, &block )
  dev = Developer.new
  args, options = args_and_options( *args )
  dev.id = args[ 0 ]
  dev.name = args[ 1 ]
  dev.url = args[ 2 ]
  dev.email = args[ 3 ]
  fill_options( dev, options )
  nested_block( :developer, dev, block ) if block
  @current.developers << dev
  dev
end

#distribution(val = nil, &block) ⇒ Object Also known as: distribution_management



449
450
451
452
453
454
455
456
457
# File 'lib/maven/tools/dsl.rb', line 449

def distribution( val = nil, &block )
  if @context == :license
    @current.distribution = val
  else
    dist = DistributionManagement.new
    nested_block( :distribution, dist, block ) if block
    @current.distribution_management = dist
  end
end

#do_dependency(bang, type, *args) ⇒ Object



804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
# File 'lib/maven/tools/dsl.rb', line 804

def do_dependency( bang, type, *args )
  d = retrieve_dependency( type, *args )
  container = dependency_container

  if bang
    dd = find_dependency( container, d )
    if index = container.index( dd )
      container[ index ] = d
    else
      container << d
    end
  else
    container << d
  end

  if args.last.is_a?( Hash )
    options = args.last
  end
  if options || @scope
    options ||= {}
    if @scope
      if options[ :scope ] || options[ 'scope' ]
        raise "scope block and scope option given"
      end
      options[ :scope ] = @scope
    end
    exclusions = options.delete( :exclusions ) ||
      options.delete( "exclusions" )
    case exclusions
    when Array
      exclusions.each do |v|
        d.exclusions << fill_gav( Exclusion, v )
      end
    when String
      d.exclusions << fill_gav( Exclusion, exclusions )
    end
    options.each do |k,v|
      d.send( "#{k}=".to_sym, v ) unless d.send( k.to_sym )
    end
  end
  d
end

#do_gem(bang, *args) ⇒ Object



908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
# File 'lib/maven/tools/dsl.rb', line 908

def do_gem( bang, *args )
  # in some setup that gem could overload the Kernel gem
  return if @current.nil?
  unless args[ 0 ].match( /:/ )
    args[ 0 ] = "rubygems:#{args[ 0 ] }"
  end
  if args.last.is_a?(Hash)
    options = args.last
    if options.key?( :git )
      @has_git = true
    elsif options.key?( :path )
      @has_path = true
    else
      platform = options.delete( :platform ) || options.delete( 'platform' )
      group = options.delete( :group ) || options.delete( 'group' ) || @group || nil
       if group
         case group.to_sym
         when :test
           options[ :scope ] = :test 
         when :development
           options[ :scope ] = :provided
         end
       end
      if platform.nil? || is_jruby_platform( platform )
        options[ :version ] = '[0,)' if args.size == 2 && options[ :version ].nil? && options[ 'version' ].nil?
        do_dependency( bang, :gem, *args )
      end
    end
  else
    args << { :version => '[0,)' } if args.size == 1
    do_dependency( bang, :gem, *args )
  end
end

#do_jruby_plugin(method, *gav, &block) ⇒ Object



587
588
589
590
591
592
593
594
# File 'lib/maven/tools/dsl.rb', line 587

def do_jruby_plugin( method, *gav, &block )
  gav[ 0 ] = "de.saumya.mojo:#{gav[ 0 ]}-maven-plugin"
  if gav.size == 1 || gav[ 1 ].is_a?( Hash )
    setup_jruby_plugins_version
    gav.insert( 1, '${jruby.plugins.version}' )
  end
  send( method, *gav, &block )
end

#eval_pom(src, reference_file = '.') ⇒ Object



38
39
40
41
42
43
44
# File 'lib/maven/tools/dsl.rb', line 38

def eval_pom( src, reference_file = '.' )
  @source = reference_file
  eval( src )
ensure
  @source = nil
  @basedir = nil
end

#excludes(*items) ⇒ Object



464
465
466
# File 'lib/maven/tools/dsl.rb', line 464

def excludes( *items )
  @current.excludes = items.flatten
end

#execute(id = nil, phase = nil, options = {}, &block) ⇒ Object



670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
# File 'lib/maven/tools/dsl.rb', line 670

def execute( id = nil, phase = nil, options = {}, &block )
  if block
    raise 'can not be inside a plugin' if @current == :plugin
    if phase.is_a? Hash
      options = phase
    else
      options[ :phase ] = phase
    end
    if id.is_a? Hash
      options = id
    else
      options[ :id ] = id
    end
    options[ :taskId ] = options[ :id ] || options[ 'id' ]
    if @source
      options[ :nativePom ] = File.expand_path( @source ).sub( /#{basedir}./, '' )
    end
	  
    add_execute_task( options, &block )
  else
    # just act like execute_goals
    execute_goals( id )
  end
end

#execute_goal(goal, options = {}, &block) ⇒ Object



718
719
720
721
722
723
724
# File 'lib/maven/tools/dsl.rb', line 718

def execute_goal( goal, options = {}, &block )
  if goal.is_a? Hash
    execute_goals( goal, &block )
  else
    execute_goals( goal, options, &block )
  end
end

#execute_goals(*goals, &block) ⇒ Object



726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
# File 'lib/maven/tools/dsl.rb', line 726

def execute_goals( *goals, &block )
  if goals.last.is_a? Hash
    options = goals.last
    goals = goals[ 0..-2 ]
  else
    options = {}
  end
  exec = Execution.new
  # keep the original default of id
  id = options.delete( :id ) || options.delete( 'id' )
  exec.id = id if id
  exec.phase = retrieve_phase( options )
  exec.goals = goals.collect { |g| g.to_s }
  set_config( exec, options )
  @current.executions << exec
  nested_block(:execution, exec, block) if block
  exec
end

#extension(*gav) ⇒ Object



573
574
575
576
577
578
579
# File 'lib/maven/tools/dsl.rb', line 573

def extension( *gav )
  @current.build ||= Build.new
  gav = gav.join( ':' )
  ext = fill_gav( Extension, gav)
  @current.build.extensions << ext
  ext
end

#file(options) ⇒ Object



436
437
438
439
440
441
# File 'lib/maven/tools/dsl.rb', line 436

def file( options )
  file = ActivationFile.new
  file.missing = options[ :missing ] || options[ 'missing' ]
  file.exists = options[ :exists ] || options[ 'exists' ]
  @current.file = file
end

#fill(receiver, method, args) ⇒ Object



543
544
545
546
547
548
549
550
551
552
553
554
# File 'lib/maven/tools/dsl.rb', line 543

def fill( receiver, method, args )
  receiver.send( "#{method}=".to_sym, args )
rescue
  begin
    old = @current
    @current = receiver
    # assume v is an array
    send( method, *args )
  ensure
    @current = old
  end
end

#fill_options(receiver, options) ⇒ Object



537
538
539
540
541
# File 'lib/maven/tools/dsl.rb', line 537

def fill_options( receiver, options )
  options.each do |k,v|
    receiver.send( "#{k}=".to_sym, v )
  end
end

#find_dependency(container, dep) ⇒ Object



758
759
760
761
762
# File 'lib/maven/tools/dsl.rb', line 758

def find_dependency( container, dep )
  container.detect do |d|
    dep.group_id == d.group_id && dep.artifact_id == d.artifact_id && dep.classifier == d.classifier
  end
end

#gem(*args) ⇒ Object



899
900
901
# File 'lib/maven/tools/dsl.rb', line 899

def gem( *args )
  do_gem( false, *args )
end

#gem!(*args) ⇒ Object

TODO useful ?



904
905
906
# File 'lib/maven/tools/dsl.rb', line 904

def gem!( *args )
  do_gem( true, *args )
end

#gem?(name) ⇒ Boolean

Returns:

  • (Boolean)


889
890
891
892
893
# File 'lib/maven/tools/dsl.rb', line 889

def gem?( name )
  @current.dependencies.detect do |d|
    d.group_id == 'rubygems' && d.artifact_id == name && d.type == :gem
  end
end

#gemfile(name = 'Gemfile', options = {}) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/maven/tools/dsl.rb', line 96

def gemfile( name = 'Gemfile', options = {} )
  if name.is_a? Hash
    options = name
    name = 'Gemfile'
  end
  name = File.join( basedir, name ) unless File.exists?( name )
  basedir = File.dirname( name ) unless basedir

  @gemfile_options = options
  FileUtils.cd( basedir ) do
    eval( File.read( File.expand_path( name ) ) )
  end

  if @gemfile_options
    @gemfile_options = nil
    setup_gem_support( options )
  end

  if @has_path or @has_git
    gem 'bundler', :scope => :provided unless gem? 'bundler'
    jruby_plugin :gem do
      execute_goal :exec, :filename => 'bundle', :args => 'install'
    end
  end
ensure
  @has_path = nil
  @has_git = nil
end

#gemspec(name = nil, options = @gemfile_options || {}) ⇒ Object



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/maven/tools/dsl.rb', line 221

def gemspec( name = nil, options = @gemfile_options || {} )
  if name.is_a? Hash
    options = name
    name = nil
  end
  if name
    name = File.join( basedir, name )
  else name
    gemspecs = Dir[ File.join( basedir, "*.gemspec" ) ]
    raise "more then one gemspec file found" if gemspecs.size > 1
    raise "no gemspec file found" if gemspecs.size == 0
    name = gemspecs.first
  end
  spec = nil
  spec_file = File.read( File.expand_path( name ) )
  begin
    FileUtils.cd( basedir ) do
      # TODO jruby java user.dir
      spec = eval( spec_file )
    end
  rescue
    spec = Gem::Specification.from_yaml( spec_file )
  end
  
  self.spec( spec, name, options )
end

#git(*args) ⇒ Object



74
75
76
# File 'lib/maven/tools/dsl.rb', line 74

def git( *args )
  warn 'git block not implemented'
end

#group(*args) ⇒ Object



89
90
91
92
93
94
# File 'lib/maven/tools/dsl.rb', line 89

def group( *args )
  @group = args[ 0 ]
  yield
ensure
  @group = nil
end

#id(*args) ⇒ Object



335
336
337
338
339
340
341
342
343
344
345
346
347
# File 'lib/maven/tools/dsl.rb', line 335

def id( *args )
  args, options = args_and_options( *args )
  if @context == :project
    # reset version + groupId
    @current.version = nil
    @current.group_id = nil
    fill_gav( @current, *args )
    fill_options( @current, options )
    reduce_id
  else
    @current.id = args[ 0 ]
  end
end

#includes(*items) ⇒ Object



460
461
462
# File 'lib/maven/tools/dsl.rb', line 460

def includes( *items )
  @current.includes = items.flatten
end

#inherit(*args, &block) ⇒ Object Also known as: parent



556
557
558
559
560
561
562
563
# File 'lib/maven/tools/dsl.rb', line 556

def inherit( *args, &block )
  args, options = args_and_options( *args )
  parent = ( @current.parent = fill_gav( Parent, *args ) )
  fill_options( parent, options )
  nested_block( :parent, parent, block ) if block
  reduce_id
  parent
end

#issue_management(url, system = nil) ⇒ Object



364
365
366
367
368
369
370
# File 'lib/maven/tools/dsl.rb', line 364

def issue_management( url, system = nil )
  issues = IssueManagement.new
  issues.url = url
  issues.system = system
  @current.issue_management = issues
  issues
end

#jar!(*args) ⇒ Object



895
896
897
# File 'lib/maven/tools/dsl.rb', line 895

def jar!( *args )
  dependency!( :jar, *args )
end

#jarfile(file = 'Jarfile', options = {}) ⇒ Object



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/maven/tools/dsl.rb', line 190

def jarfile( file = 'Jarfile', options = {} )
  if file.is_a? Hash 
    options = file
    file = 'Jarfile'
  end
  unless file.is_a?( Maven::Tools::Jarfile )
    file = Maven::Tools::Jarfile.new( File.expand_path( file ) )
  end

  if options[ :skip_locked ] or not file.exists_lock?
    file.populate_unlocked do |dsl|
      setup_jruby( dsl.jruby )
      dsl.artifacts.each do |a|
        dependency a
      end
    end
  else
    file.locked.each do |dep|
      artifact( dep )
    end
    file.populate_unlocked do |dsl|
      setup_jruby( dsl.jruby )
      dsl.artifacts.each do |a|
        if a[ :system_path ]
          dependeny a
        end
      end
    end
  end
end

#jruby_plugin(*gav, &block) ⇒ Object



596
597
598
# File 'lib/maven/tools/dsl.rb', line 596

def jruby_plugin( *gav, &block )
  do_jruby_plugin( :plugin, *gav, &block )
end

#jruby_plugin!(*gav, &block) ⇒ Object



600
601
602
# File 'lib/maven/tools/dsl.rb', line 600

def jruby_plugin!( *gav, &block )
  do_jruby_plugin( :plugin!, *gav, &block )
end

#license(*args, &block) ⇒ Object



315
316
317
318
319
320
321
322
323
324
# File 'lib/maven/tools/dsl.rb', line 315

def license( *args, &block )
  args, options = args_and_options( *args )
  license = License.new
  license.name = args[ 0 ]
  license.url = args[ 1 ]
  fill_options( license, options )
  nested_block( :license, license, block ) if block
  @current.licenses << license
  license
end

#local(path, options = {}) ⇒ Object



942
943
944
945
946
# File 'lib/maven/tools/dsl.rb', line 942

def local( path, options = {} )
  path = File.expand_path( path )
  dependency( :jar,
              Maven::Tools::Artifact.new_local( path, :jar, options ) )
end

#mailing_list(*args, &block) ⇒ Object



372
373
374
375
376
377
378
379
380
# File 'lib/maven/tools/dsl.rb', line 372

def mailing_list( *args, &block )
  list = MailingList.new
  args, options = args_and_options( *args )
  list.name = args[ 0 ]
  fill_options( list, options )
  nested_block( :mailing_list, list, block ) if block
  @current.mailing_lists <<  list
  list
end

#maven(val = nil, &block) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/maven/tools/dsl.rb', line 26

def maven( val = nil, &block )
  if @context == nil
    tesla( &block )
  else
    @current.maven = val
  end
end

#modelObject



34
35
36
# File 'lib/maven/tools/dsl.rb', line 34

def model
  @model
end

#organization(*args, &block) ⇒ Object



301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/maven/tools/dsl.rb', line 301

def organization( *args, &block )
  if @context == :project
    args, options = args_and_options( *args )
    org = ( @current.organization ||= Organization.new )
    org.name = args[ 0 ]
    org.url = args[ 1 ]
    fill_options( org, options )
    nested_block( :organization, org, block ) if block
    org
  else
    @current.organization = args[ 0 ]
  end
end

#other_archives(*archives) ⇒ Object



396
397
398
# File 'lib/maven/tools/dsl.rb', line 396

def other_archives( *archives )
  @current.other_archives = archives
end

#overrides(&block) ⇒ Object Also known as: plugin_management, dependency_management



664
665
666
# File 'lib/maven/tools/dsl.rb', line 664

def overrides(&block)
  nested_block(:overrides, @current, block) if block
end

#path(*args) ⇒ Object



70
71
72
# File 'lib/maven/tools/dsl.rb', line 70

def path( *args )
  warn 'path block not implemented'
end

#phase(name) ⇒ Object



853
854
855
856
857
# File 'lib/maven/tools/dsl.rb', line 853

def phase( name )
  @phase = name
  yield
  @phase = nil
end

#platforms(*args) ⇒ Object



83
84
85
86
87
# File 'lib/maven/tools/dsl.rb', line 83

def platforms( *args )
  if is_jruby_platform( *args )
    yield
  end
end

#plugin(*gav, &block) ⇒ Object



648
649
650
651
652
653
654
# File 'lib/maven/tools/dsl.rb', line 648

def plugin( *gav, &block )
  gav, options = plugin_gav( *gav )
  plugin = fill_gav( @context == :reporting ? ReportPlugin : Plugin,
                     gav)

  do_plugin( true, plugin, options, &block )
end

#plugin!(*gav, &block) ⇒ Object



604
605
606
607
608
609
610
611
612
613
614
615
616
617
# File 'lib/maven/tools/dsl.rb', line 604

def plugin!( *gav, &block )
  gav, options = plugin_gav( *gav )
  pl = plugins.detect do |p|
    "#{p.group_id}:#{p.artifact_id}:#{p.version}" == gav
  end
  if pl
    do_plugin( false, pl, options, &block )
  else
    plugin = fill_gav( @context == :reporting ? ReportPlugin : Plugin,
                       gav)

    do_plugin( true, plugin, options, &block )
  end
end

#plugin_repository(url, options = {}, &block) ⇒ Object



494
495
496
# File 'lib/maven/tools/dsl.rb', line 494

def plugin_repository( url, options = {}, &block )
  do_repository( :plugin, url, options, block )
end

#prerequisites(*args, &block) ⇒ Object



382
383
384
385
386
387
388
389
# File 'lib/maven/tools/dsl.rb', line 382

def prerequisites( *args, &block )
  pre = Prerequisites.new
  args, options = args_and_options( *args )
  fill_options( pre, options )
  nested_block( :prerequisites, pre, block ) if block
  @current.prerequisites = pre
  pre
end

#profile(id, &block) ⇒ Object



859
860
861
862
863
864
# File 'lib/maven/tools/dsl.rb', line 859

def profile( id, &block )
  profile = Profile.new
  profile.id = id if id
  @current.profiles << profile
  nested_block( :profile, profile, block ) if block
end

#project(*args, &block) ⇒ Object



326
327
328
329
330
331
332
333
# File 'lib/maven/tools/dsl.rb', line 326

def project( *args, &block )
  raise 'mixed up hierachy' unless @current == model
  args, options = args_and_options( *args )
  @current.name = args[ 0 ]
  @current.url = args[ 1 ]
  fill_options( @current, options )
  nested_block(:project, @current, block) if block
end

#properties(props = {}) ⇒ Object



566
567
568
569
570
571
# File 'lib/maven/tools/dsl.rb', line 566

def properties(props = {})
  props.each do |k,v|
    @current.properties[k.to_s] = v.to_s
  end
  @current.properties
end

#property(options) ⇒ Object



429
430
431
432
433
434
# File 'lib/maven/tools/dsl.rb', line 429

def property( options )
  prop = ActivationProperty.new
  prop.name = options[ :name ] || options[ 'name' ]
  prop.value = options[ :value ] || options[ 'value' ]
  @current.property = prop
end

#releases(config) ⇒ Object



504
505
506
# File 'lib/maven/tools/dsl.rb', line 504

def releases( config )
  @current.releases = respository_policy( config )
end

#report_set(*reports, &block) ⇒ Object



866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
# File 'lib/maven/tools/dsl.rb', line 866

def report_set( *reports, &block )
  set = ReportSet.new
  case reports.last
  when Hash
    options = reports.last
    reports = reports[ 0..-2 ]
    id = options.delete( :id ) || options.delete( 'id' )
    set.id = id if id
    inherited = options.delete( :inherited ) ||
      options.delete( 'inherited' )
    set.inherited = inherited if inherited
  end
  set_config( set, options )
  set.reports = reports#.to_java
  @current.report_sets << set
end

#reporting(&block) ⇒ Object



883
884
885
886
887
# File 'lib/maven/tools/dsl.rb', line 883

def reporting( &block )
  reporting = Reporting.new
  @current.reporting = reporting
  nested_block( :reporting, reporting, block ) if block
end

#repository(url, options = {}, &block) ⇒ Object



490
491
492
# File 'lib/maven/tools/dsl.rb', line 490

def repository( url, options = {}, &block )
  do_repository( :repository=, url, options, block )
end

#repository_policy(config) ⇒ Object



512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
# File 'lib/maven/tools/dsl.rb', line 512

def repository_policy( config )
  rp = RepositoryPolicy.new
  case config
  when Hash
    rp.enabled = config[ :enabled ]
    rp.update_policy = config[ :update ]
    rp.checksum_policy = config[ :checksum ]
  when TrueClass
    rp.enabled = true
  when FalseClass
    rp.enabled = false
  else
    rp.enabled = 'true' == config
  end
  rp
end

#resource(&block) ⇒ Object



480
481
482
483
484
485
486
487
488
# File 'lib/maven/tools/dsl.rb', line 480

def resource( &block )
  resource = Resource.new
  nested_block( :resource, resource, block ) if block
  if @context == :project
    ( @current.build ||= Build.new ).resources << resource
  else
    @current.resources << resource
  end
end

#retrieve_dependency(type, *args) ⇒ Object



777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
# File 'lib/maven/tools/dsl.rb', line 777

def retrieve_dependency( type, *args )
  if args.empty?
    a = type
    type = a[ :type ]
    options = a
  elsif args[ 0 ].is_a?( ::Maven::Tools::Artifact )
    a = args[ 0 ]
    type = a[ :type ]
    options = a
  else
    a = ::Maven::Tools::Artifact.from( type, *args )
  end
  d = fill_gav( Dependency, 
                a ? a.gav : args.join( ':' ) )
  d.type = type.to_s
  d
end

#roles(*roles) ⇒ Object



425
426
427
# File 'lib/maven/tools/dsl.rb', line 425

def roles( *roles )
  @current.roles = roles
end

#ruby(*args) ⇒ Object



66
67
68
# File 'lib/maven/tools/dsl.rb', line 66

def ruby( *args )
  # ignore
end

#scope(name) ⇒ Object



847
848
849
850
851
# File 'lib/maven/tools/dsl.rb', line 847

def scope( name )
  @scope = name
  yield
  @scope = nil
end

#set_config(receiver, options) ⇒ Object



1011
1012
1013
# File 'lib/maven/tools/dsl.rb', line 1011

def set_config(  receiver, options )
  receiver.configuration = options
end

#setup_jruby_plugins_versionObject



581
582
583
584
585
# File 'lib/maven/tools/dsl.rb', line 581

def setup_jruby_plugins_version
  unless @current.properties.key?( 'jruby.plugins.version' )
    properties( 'jruby.plugins.version' => VERSIONS[ :jruby_plugins ] )
  end
end

#site(url = nil, options = {}) ⇒ Object



349
350
351
352
353
354
# File 'lib/maven/tools/dsl.rb', line 349

def site( url = nil, options = {} )
  site = Site.new
  options.merge!( :url => url )
  fill_options( site, options )
  @current.site = site
end

#snapshot_repository(url, options = {}, &block) ⇒ Object



498
499
500
501
502
# File 'lib/maven/tools/dsl.rb', line 498

def snapshot_repository( url, options = {}, &block )
  options[ :releases ] = false unless options.key?( :releases ) || options.key?( 'releases' )
  options[ :snapshots ] = true unless options.key?( :snapshots ) || options.key?( 'snapshots' )
  do_repository( :snapshot_repository=, url, options, block )
end

#snapshots(config) ⇒ Object



508
509
510
# File 'lib/maven/tools/dsl.rb', line 508

def snapshots( config )
  @current.snapshots = respository_policy( config )
end

#source(*args) ⇒ Object



62
63
64
# File 'lib/maven/tools/dsl.rb', line 62

def source(*args)
  warn "ignore source #{args}" if !(args[0].to_s =~ /^https?:\/\/rubygems.org/) && args[0] != :rubygems
end

#source_control(url = nil, options = {}) ⇒ Object Also known as: scm



356
357
358
359
360
361
# File 'lib/maven/tools/dsl.rb', line 356

def source_control( url = nil, options = {} )
  scm = Scm.new
  options.merge!( :url => url )
  fill_options( scm, options )
  @current.scm = scm
end

#spec(spec, name = nil, options = {}) ⇒ Object



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/maven/tools/dsl.rb', line 248

def spec( spec, name = nil, options = {} )
  name ||= "#{spec.name}-#{spec.version}.gemspec"
  unless model.properties.member?( 'project.build.sourceEncoding' )
    properties( 'project.build.sourceEncoding' => 'utf-8' ) 
  end

  @gemfile_options = nil

  if @context == :project
    build.directory = '${basedir}/pkg'
    version = spec.version.to_s
    version += '-SNAPSHOT' if spec.version.prerelease?
    id "rubygems:#{spec.name}:#{version}"
    name( spec.summary || spec.name )
    description spec.description
    packaging 'gem'
    url spec.homepage
    extension 'de.saumya.mojo:gem-extension:${jruby.plugins.version}'
  end

  setup_gem_support( options, spec )
  
  config = { :gemspec => name.sub( /^#{basedir}\/?/, '' ) }
  if options[ :include_jars ] || options[ 'include_jars' ] 
    config[ :includeDependencies ] = true
  end
  plugin( 'de.saumya.mojo:gem-maven-plugin:${jruby.plugins.version}',
          config )

  deps = Maven::Tools::GemspecDependencies.new( spec )
  deps.runtime.each do |d|
    gem d
  end
  unless deps.development.empty?
    scope :test do
      deps.development.each do |d|
        gem d
      end          
    end
  end
  unless deps.java_runtime.empty?
    deps.java_runtime.each do |d|
      dependency Maven::Tools::Artifact.new( *d )
    end
  end
end

#tesla(&block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/maven/tools/dsl.rb', line 11

def tesla( &block )
  @model = Model.new
  @model.model_version = '4.0.0'
  @model.name = File.basename( basedir )
  @model.group_id = 'dummy'
  @model.artifact_id = model.name
  @model.version = '0.0.0'
  @context = :project
  nested_block( :project, @model, block ) if block
  result = @model
  @context = nil
  @model = nil
  result
end

#test_resource(&block) ⇒ Object



468
469
470
471
472
473
474
475
476
477
478
# File 'lib/maven/tools/dsl.rb', line 468

def test_resource( &block )
  # strange behaviour when calling specs from Rakefile
  return if @current.nil?
  resource = Resource.new
  nested_block( :resource, resource, block ) if block
  if @context == :project
    ( @current.build ||= Build.new ).test_resources << resource
  else
    @current.test_resources << resource
  end
end

#xml(xml) ⇒ Object



1007
1008
1009
# File 'lib/maven/tools/dsl.rb', line 1007

def xml( xml )
  raise  'Xpp3DomBuilder.build( java.io.StringReader.new( xml ) )'
end