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



920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
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
# File 'lib/maven/tools/dsl.rb', line 920

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



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

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



668
669
670
671
672
673
674
675
676
# File 'lib/maven/tools/dsl.rb', line 668

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



373
374
375
376
# File 'lib/maven/tools/dsl.rb', line 373

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

#args_and_options(*args) ⇒ Object



509
510
511
512
513
514
515
# File 'lib/maven/tools/dsl.rb', line 509

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



277
278
279
280
281
# File 'lib/maven/tools/dsl.rb', line 277

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

#contributor(*args, &block) ⇒ Object



395
396
397
398
399
400
401
402
403
404
405
# File 'lib/maven/tools/dsl.rb', line 395

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



717
718
719
# File 'lib/maven/tools/dsl.rb', line 717

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

#dependency!(type, *args) ⇒ Object



721
722
723
# File 'lib/maven/tools/dsl.rb', line 721

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

#dependency?(type, *args) ⇒ Boolean

Returns:

  • (Boolean)


725
726
727
728
# File 'lib/maven/tools/dsl.rb', line 725

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

#dependency_containerObject



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

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



736
737
738
739
740
741
742
743
744
745
746
747
# File 'lib/maven/tools/dsl.rb', line 736

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



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

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



431
432
433
434
435
436
437
438
439
# File 'lib/maven/tools/dsl.rb', line 431

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



776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
# File 'lib/maven/tools/dsl.rb', line 776

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



880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
# File 'lib/maven/tools/dsl.rb', line 880

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

#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



446
447
448
# File 'lib/maven/tools/dsl.rb', line 446

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

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



642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
# File 'lib/maven/tools/dsl.rb', line 642

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



690
691
692
693
694
695
696
# File 'lib/maven/tools/dsl.rb', line 690

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



698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
# File 'lib/maven/tools/dsl.rb', line 698

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



553
554
555
556
557
558
559
# File 'lib/maven/tools/dsl.rb', line 553

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

#file(options) ⇒ Object



418
419
420
421
422
423
# File 'lib/maven/tools/dsl.rb', line 418

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



523
524
525
526
527
528
529
530
531
532
533
534
# File 'lib/maven/tools/dsl.rb', line 523

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



517
518
519
520
521
# File 'lib/maven/tools/dsl.rb', line 517

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

#find_dependency(container, dep) ⇒ Object



730
731
732
733
734
# File 'lib/maven/tools/dsl.rb', line 730

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



871
872
873
# File 'lib/maven/tools/dsl.rb', line 871

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

#gem!(*args) ⇒ Object

TODO useful ?



876
877
878
# File 'lib/maven/tools/dsl.rb', line 876

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

#gem?(name) ⇒ Boolean

Returns:

  • (Boolean)


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

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



217
218
219
220
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
247
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
# File 'lib/maven/tools/dsl.rb', line 217

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

  @gemfile_options = nil
  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
  FileUtils.cd( basedir ) do
    spec = eval( File.read( File.expand_path( name ) ) )
  end

  if @context == :project
    build.directory = '${basedir}/pkg'
    id "rubygems:#{spec.name}:#{spec.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

#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



317
318
319
320
321
322
323
324
325
326
327
328
329
# File 'lib/maven/tools/dsl.rb', line 317

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



442
443
444
# File 'lib/maven/tools/dsl.rb', line 442

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

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



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

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



346
347
348
349
350
351
352
# File 'lib/maven/tools/dsl.rb', line 346

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

#jar!(*args) ⇒ Object



867
868
869
# File 'lib/maven/tools/dsl.rb', line 867

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

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



186
187
188
189
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
# File 'lib/maven/tools/dsl.rb', line 186

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



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

def jruby_plugin( *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
  plugin( *gav, &block )
end

#license(*args, &block) ⇒ Object



297
298
299
300
301
302
303
304
305
306
# File 'lib/maven/tools/dsl.rb', line 297

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



914
915
916
917
918
# File 'lib/maven/tools/dsl.rb', line 914

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



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

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



283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/maven/tools/dsl.rb', line 283

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



378
379
380
# File 'lib/maven/tools/dsl.rb', line 378

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

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



636
637
638
# File 'lib/maven/tools/dsl.rb', line 636

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



825
826
827
828
829
# File 'lib/maven/tools/dsl.rb', line 825

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



620
621
622
623
624
625
626
# File 'lib/maven/tools/dsl.rb', line 620

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



576
577
578
579
580
581
582
583
584
585
586
587
588
589
# File 'lib/maven/tools/dsl.rb', line 576

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



476
477
478
# File 'lib/maven/tools/dsl.rb', line 476

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

#prerequisites(*args, &block) ⇒ Object



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

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



831
832
833
834
835
836
# File 'lib/maven/tools/dsl.rb', line 831

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



308
309
310
311
312
313
314
315
# File 'lib/maven/tools/dsl.rb', line 308

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



546
547
548
549
550
551
# File 'lib/maven/tools/dsl.rb', line 546

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

#property(options) ⇒ Object



411
412
413
414
415
416
# File 'lib/maven/tools/dsl.rb', line 411

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



484
485
486
# File 'lib/maven/tools/dsl.rb', line 484

def releases( config )
  respository_policy( :releases=, config )
end

#report_set(*reports, &block) ⇒ Object



838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
# File 'lib/maven/tools/dsl.rb', line 838

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



855
856
857
858
859
# File 'lib/maven/tools/dsl.rb', line 855

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

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



472
473
474
# File 'lib/maven/tools/dsl.rb', line 472

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

#resource(&block) ⇒ Object



462
463
464
465
466
467
468
469
470
# File 'lib/maven/tools/dsl.rb', line 462

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

#respository_policy(method, config) ⇒ Object



492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
# File 'lib/maven/tools/dsl.rb', line 492

def respository_policy( method, config )
  rp = RepositoryPolicy.new
  case config
  when Hash
    rp.enabled = snapshot[ :enabled ]
    rp.update_policy = snapshot[ :update ]
    rp.checksum_policy = snapshot[ :checksum ]
  when TrueClass
    rp.enabled = true
  when FalseClass
    rp.enabled = false
  else
    rp.enabled = 'true' == config
  end
  @current.send( method, rp )
end

#retrieve_dependency(type, *args) ⇒ Object



749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
# File 'lib/maven/tools/dsl.rb', line 749

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



407
408
409
# File 'lib/maven/tools/dsl.rb', line 407

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



819
820
821
822
823
# File 'lib/maven/tools/dsl.rb', line 819

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

#set_config(receiver, options) ⇒ Object



983
984
985
# File 'lib/maven/tools/dsl.rb', line 983

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

#setup_jruby_plugins_versionObject



561
562
563
564
565
# File 'lib/maven/tools/dsl.rb', line 561

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



331
332
333
334
335
336
# File 'lib/maven/tools/dsl.rb', line 331

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



480
481
482
# File 'lib/maven/tools/dsl.rb', line 480

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

#snapshots(config) ⇒ Object



488
489
490
# File 'lib/maven/tools/dsl.rb', line 488

def snapshots( config )
  respository_policy( :snapshots=, 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



338
339
340
341
342
343
# File 'lib/maven/tools/dsl.rb', line 338

def source_control( url = nil, options = {} )
  scm = Scm.new
  options.merge!( :url => url )
  fill_options( scm, options )
  @current.scm = scm
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



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

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



979
980
981
# File 'lib/maven/tools/dsl.rb', line 979

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