Module: Maven::Tools::DSL
- Included in:
- POM
- Defined in:
- lib/maven/tools/dsl.rb
Instance Method Summary collapse
- #activation(&block) ⇒ Object
-
#add_execute_task(options, &block) ⇒ Object
hook for polyglot maven to register those tasks.
- #archives(*archives) ⇒ Object
- #args_and_options(*args) ⇒ Object
- #artifact(a) ⇒ Object
- #basedir(basedir = nil) ⇒ Object
- #build(&block) ⇒ Object
- #contributor(*args, &block) ⇒ Object
- #dependency(type, *args) ⇒ Object
- #dependency!(type, *args) ⇒ Object
- #dependency?(type, *args) ⇒ Boolean
- #dependency_container ⇒ Object
- #dependency_set(bang, container, dep) ⇒ Object
- #developer(*args, &block) ⇒ Object
- #distribution(val = nil, &block) ⇒ Object (also: #distribution_management)
- #do_dependency(bang, type, *args) ⇒ Object
- #do_gem(bang, *args) ⇒ Object
- #do_jruby_plugin(method, *gav, &block) ⇒ Object
- #eval_pom(src, reference_file = '.') ⇒ Object
- #excludes(*items) ⇒ Object
- #execute(id = nil, phase = nil, options = {}, &block) ⇒ Object
- #execute_goal(goal, options = {}, &block) ⇒ Object
- #execute_goals(*goals, &block) ⇒ Object
- #extension(*gav) ⇒ Object
- #file(options) ⇒ Object
- #fill(receiver, method, args) ⇒ Object
- #fill_options(receiver, options) ⇒ Object
- #find_dependency(container, dep) ⇒ Object
- #gem(*args) ⇒ Object
-
#gem!(*args) ⇒ Object
TODO useful ?.
- #gem?(name) ⇒ Boolean
- #gemfile(name = 'Gemfile', options = {}) ⇒ Object
- #gemspec(name = nil, options = @gemfile_options || {}) ⇒ Object
- #git(*args) ⇒ Object
- #group(*args) ⇒ Object
- #id(*args) ⇒ Object
- #includes(*items) ⇒ Object
- #inherit(*args, &block) ⇒ Object (also: #parent)
- #issue_management(url, system = nil) ⇒ Object
- #jar!(*args) ⇒ Object
- #jarfile(file = 'Jarfile', options = {}) ⇒ Object
- #jruby_plugin(*gav, &block) ⇒ Object
- #jruby_plugin!(*gav, &block) ⇒ Object
- #license(*args, &block) ⇒ Object
- #local(path, options = {}) ⇒ Object
- #mailing_list(*args, &block) ⇒ Object
- #maven(val = nil, &block) ⇒ Object
- #method_missing(method, *args, &block) ⇒ Object
- #model ⇒ Object
- #organization(*args, &block) ⇒ Object
- #other_archives(*archives) ⇒ Object
- #overrides(&block) ⇒ Object (also: #plugin_management, #dependency_management)
- #path(*args) ⇒ Object
- #phase(name) ⇒ Object
- #platforms(*args) ⇒ Object
- #plugin(*gav, &block) ⇒ Object
- #plugin!(*gav, &block) ⇒ Object
- #plugin_repository(url, options = {}, &block) ⇒ Object
- #prerequisites(*args, &block) ⇒ Object
- #profile(id, &block) ⇒ Object
- #project(*args, &block) ⇒ Object
- #properties(props = {}) ⇒ Object
- #property(options) ⇒ Object
- #releases(config) ⇒ Object
- #report_set(*reports, &block) ⇒ Object
- #reporting(&block) ⇒ Object
- #repository(url, options = {}, &block) ⇒ Object
- #repository_policy(config) ⇒ Object
- #resource(&block) ⇒ Object
- #retrieve_dependency(type, *args) ⇒ Object
- #roles(*roles) ⇒ Object
- #ruby(*args) ⇒ Object
- #scope(name) ⇒ Object
- #set_config(receiver, options) ⇒ Object
- #setup_jruby_plugins_version ⇒ Object
- #site(url = nil, options = {}) ⇒ Object
- #snapshot_repository(url, options = {}, &block) ⇒ Object
- #snapshots(config) ⇒ Object
- #source(*args) ⇒ Object
- #source_control(url = nil, options = {}) ⇒ Object (also: #scm)
- #spec(spec, name = nil, options = {}) ⇒ Object
- #tesla(&block) ⇒ Object
- #test_resource(&block) ⇒ Object
- #xml(xml) ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
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 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 |
# File 'lib/maven/tools/dsl.rb', line 975 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
458 459 460 461 462 |
# File 'lib/maven/tools/dsl.rb', line 458 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
713 714 715 716 717 718 719 720 721 |
# File 'lib/maven/tools/dsl.rb', line 713 def add_execute_task( , &block ) plugin!( 'io.tesla.polyglot:tesla-polyglot-maven-plugin', VERSIONS[ :tesla_version ] ) do execute_goal( :execute, ) jar!( 'io.tesla.polyglot:tesla-polyglot-ruby', VERSIONS[ :tesla_version ] ) end end |
#archives(*archives) ⇒ Object
406 407 408 409 |
# File 'lib/maven/tools/dsl.rb', line 406 def archives( *archives ) @current.archive = archives.shift @current.other_archives = archives end |
#args_and_options(*args) ⇒ Object
546 547 548 549 550 551 552 |
# File 'lib/maven/tools/dsl.rb', line 546 def ( *args ) if args.last.is_a? Hash [ args[0..-2], args.last ] else [ args, {} ] end end |
#artifact(a) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/maven/tools/dsl.rb', line 65 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
56 57 58 59 60 61 62 63 |
# File 'lib/maven/tools/dsl.rb', line 56 def basedir( basedir = nil ) @basedir ||= basedir if basedir if @source @basedir ||= File.directory?( @source ) ? @source : File.dirname( File.( @source ) ) end @basedir ||= File.( '.' ) end |
#build(&block) ⇒ Object
310 311 312 313 314 |
# File 'lib/maven/tools/dsl.rb', line 310 def build( &block ) build = @current.build ||= Build.new nested_block( :build, build, block ) if block build end |
#contributor(*args, &block) ⇒ Object
428 429 430 431 432 433 434 435 436 437 438 |
# File 'lib/maven/tools/dsl.rb', line 428 def contributor( *args, &block ) con = Contributor.new args, = ( *args ) con.name = args[ 0 ] con.url = args[ 1 ] con.email = args[ 2 ] ( con, ) nested_block( :contributor, con, block ) if block @current.contributors << con con end |
#dependency(type, *args) ⇒ Object
762 763 764 |
# File 'lib/maven/tools/dsl.rb', line 762 def dependency( type, *args ) do_dependency( false, type, *args ) end |
#dependency!(type, *args) ⇒ Object
766 767 768 |
# File 'lib/maven/tools/dsl.rb', line 766 def dependency!( type, *args ) do_dependency( true, type, *args ) end |
#dependency?(type, *args) ⇒ Boolean
770 771 772 773 |
# File 'lib/maven/tools/dsl.rb', line 770 def dependency?( type, *args ) find_dependency( dependency_container, retrieve_dependency( type, *args ) ) != nil end |
#dependency_container ⇒ Object
816 817 818 819 820 821 822 823 |
# File 'lib/maven/tools/dsl.rb', line 816 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
781 782 783 784 785 786 787 788 789 790 791 792 |
# File 'lib/maven/tools/dsl.rb', line 781 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
415 416 417 418 419 420 421 422 423 424 425 426 |
# File 'lib/maven/tools/dsl.rb', line 415 def developer( *args, &block ) dev = Developer.new args, = ( *args ) dev.id = args[ 0 ] dev.name = args[ 1 ] dev.url = args[ 2 ] dev.email = args[ 3 ] ( dev, ) nested_block( :developer, dev, block ) if block @current.developers << dev dev end |
#distribution(val = nil, &block) ⇒ Object Also known as: distribution_management
464 465 466 467 468 469 470 471 472 |
# File 'lib/maven/tools/dsl.rb', line 464 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
825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 |
# File 'lib/maven/tools/dsl.rb', line 825 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 ) = args.last end if || @scope ||= {} if @scope if [ :scope ] || [ 'scope' ] raise "scope block and scope option given" end [ :scope ] = @scope end exclusions = .delete( :exclusions ) || .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 .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
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 |
# File 'lib/maven/tools/dsl.rb', line 930 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) = args.last # on ruby-maven side we ignore the require option .delete( :require ) .delete( 'require' ) if .key?( :git ) @has_git = true elsif .key?( :path ) @has_path = true else platform = .delete( :platform ) || .delete( 'platform' ) group = .delete( :group ) || .delete( 'group' ) || @group || nil if group case group.to_sym when :test [ :scope ] = :test when :development [ :scope ] = :provided end end if platform.nil? || is_jruby_platform( platform ) [ :version ] = '[0,)' if args.size == 2 && [ :version ].nil? && [ '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
604 605 606 607 608 609 610 611 |
# File 'lib/maven/tools/dsl.rb', line 604 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
48 49 50 51 52 53 54 |
# File 'lib/maven/tools/dsl.rb', line 48 def eval_pom( src, reference_file = '.' ) @source = reference_file eval( src ) ensure @source = nil @basedir = nil end |
#excludes(*items) ⇒ Object
479 480 481 |
# File 'lib/maven/tools/dsl.rb', line 479 def excludes( *items ) @current.excludes = items.flatten end |
#execute(id = nil, phase = nil, options = {}, &block) ⇒ Object
687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 |
# File 'lib/maven/tools/dsl.rb', line 687 def execute( id = nil, phase = nil, = {}, &block ) if block raise 'can not be inside a plugin' if @current == :plugin if phase.is_a? Hash = phase else [ :phase ] = phase end if id.is_a? Hash = id else [ :id ] = id end [ :taskId ] = [ :id ] || [ 'id' ] if @source [ :nativePom ] = File.( @source ).sub( /#{basedir}./, '' ) end add_execute_task( , &block ) else # just act like execute_goals execute_goals( id ) end end |
#execute_goal(goal, options = {}, &block) ⇒ Object
735 736 737 738 739 740 741 |
# File 'lib/maven/tools/dsl.rb', line 735 def execute_goal( goal, = {}, &block ) if goal.is_a? Hash execute_goals( goal, &block ) else execute_goals( goal, , &block ) end end |
#execute_goals(*goals, &block) ⇒ Object
743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 |
# File 'lib/maven/tools/dsl.rb', line 743 def execute_goals( *goals, &block ) if goals.last.is_a? Hash = goals.last goals = goals[ 0..-2 ] else = {} end exec = Execution.new # keep the original default of id id = .delete( :id ) || .delete( 'id' ) exec.id = id if id exec.phase = retrieve_phase( ) exec.goals = goals.collect { |g| g.to_s } set_config( exec, ) @current.executions << exec nested_block(:execution, exec, block) if block exec end |
#extension(*gav) ⇒ Object
590 591 592 593 594 595 596 |
# File 'lib/maven/tools/dsl.rb', line 590 def extension( *gav ) @current.build ||= Build.new gav = gav.join( ':' ) ext = fill_gav( Extension, gav) @current.build.extensions << ext ext end |
#file(options) ⇒ Object
451 452 453 454 455 456 |
# File 'lib/maven/tools/dsl.rb', line 451 def file( ) file = ActivationFile.new file.missing = [ :missing ] || [ 'missing' ] file.exists = [ :exists ] || [ 'exists' ] @current.file = file end |
#fill(receiver, method, args) ⇒ Object
560 561 562 563 564 565 566 567 568 569 570 571 |
# File 'lib/maven/tools/dsl.rb', line 560 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
554 555 556 557 558 |
# File 'lib/maven/tools/dsl.rb', line 554 def ( receiver, ) .each do |k,v| receiver.send( "#{k}=".to_sym, v ) end end |
#find_dependency(container, dep) ⇒ Object
775 776 777 778 779 |
# File 'lib/maven/tools/dsl.rb', line 775 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
921 922 923 |
# File 'lib/maven/tools/dsl.rb', line 921 def gem( *args ) do_gem( false, *args ) end |
#gem!(*args) ⇒ Object
TODO useful ?
926 927 928 |
# File 'lib/maven/tools/dsl.rb', line 926 def gem!( *args ) do_gem( true, *args ) end |
#gem?(name) ⇒ Boolean
911 912 913 914 915 |
# File 'lib/maven/tools/dsl.rb', line 911 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
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/maven/tools/dsl.rb', line 106 def gemfile( name = 'Gemfile', = {} ) if name.is_a? Hash = name name = 'Gemfile' end name = File.join( basedir, name ) unless File.exists?( name ) basedir = File.dirname( name ) unless basedir @gemfile_options = FileUtils.cd( basedir ) do eval( File.read( File.( name ) ) ) end if @gemfile_options @gemfile_options = nil setup_gem_support( ) 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
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 |
# File 'lib/maven/tools/dsl.rb', line 232 def gemspec( name = nil, = @gemfile_options || {} ) if name.is_a? Hash = 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.( 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, ) end |
#git(*args) ⇒ Object
84 85 86 |
# File 'lib/maven/tools/dsl.rb', line 84 def git( *args ) warn 'git block not implemented' end |
#group(*args) ⇒ Object
99 100 101 102 103 104 |
# File 'lib/maven/tools/dsl.rb', line 99 def group( *args ) @group = args[ 0 ] yield ensure @group = nil end |
#id(*args) ⇒ Object
350 351 352 353 354 355 356 357 358 359 360 361 362 |
# File 'lib/maven/tools/dsl.rb', line 350 def id( *args ) args, = ( *args ) if @context == :project # reset version + groupId @current.version = nil @current.group_id = nil fill_gav( @current, *args ) ( @current, ) reduce_id else @current.id = args[ 0 ] end end |
#includes(*items) ⇒ Object
475 476 477 |
# File 'lib/maven/tools/dsl.rb', line 475 def includes( *items ) @current.includes = items.flatten end |
#inherit(*args, &block) ⇒ Object Also known as: parent
573 574 575 576 577 578 579 580 |
# File 'lib/maven/tools/dsl.rb', line 573 def inherit( *args, &block ) args, = ( *args ) parent = ( @current.parent = fill_gav( Parent, *args ) ) ( parent, ) nested_block( :parent, parent, block ) if block reduce_id parent end |
#issue_management(url, system = nil) ⇒ Object
379 380 381 382 383 384 385 |
# File 'lib/maven/tools/dsl.rb', line 379 def issue_management( url, system = nil ) issues = IssueManagement.new issues.url = url issues.system = system @current.issue_management = issues issues end |
#jar!(*args) ⇒ Object
917 918 919 |
# File 'lib/maven/tools/dsl.rb', line 917 def jar!( *args ) dependency!( :jar, *args ) end |
#jarfile(file = 'Jarfile', options = {}) ⇒ Object
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/maven/tools/dsl.rb', line 201 def jarfile( file = 'Jarfile', = {} ) if file.is_a? Hash = file file = 'Jarfile' end unless file.is_a?( Maven::Tools::Jarfile ) file = Maven::Tools::Jarfile.new( File.( file ) ) end if [ :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
613 614 615 |
# File 'lib/maven/tools/dsl.rb', line 613 def jruby_plugin( *gav, &block ) do_jruby_plugin( :plugin, *gav, &block ) end |
#jruby_plugin!(*gav, &block) ⇒ Object
617 618 619 |
# File 'lib/maven/tools/dsl.rb', line 617 def jruby_plugin!( *gav, &block ) do_jruby_plugin( :plugin!, *gav, &block ) end |
#license(*args, &block) ⇒ Object
330 331 332 333 334 335 336 337 338 339 |
# File 'lib/maven/tools/dsl.rb', line 330 def license( *args, &block ) args, = ( *args ) license = License.new license.name = args[ 0 ] license.url = args[ 1 ] ( license, ) nested_block( :license, license, block ) if block @current.licenses << license license end |
#local(path, options = {}) ⇒ Object
969 970 971 972 973 |
# File 'lib/maven/tools/dsl.rb', line 969 def local( path, = {} ) path = File.( path ) dependency( :jar, Maven::Tools::Artifact.new_local( path, :jar, ) ) end |
#mailing_list(*args, &block) ⇒ Object
387 388 389 390 391 392 393 394 395 |
# File 'lib/maven/tools/dsl.rb', line 387 def mailing_list( *args, &block ) list = MailingList.new args, = ( *args ) list.name = args[ 0 ] ( list, ) nested_block( :mailing_list, list, block ) if block @current.mailing_lists << list list end |
#maven(val = nil, &block) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/maven/tools/dsl.rb', line 36 def maven( val = nil, &block ) if @context == nil tesla( &block ) else @current.maven = val end end |
#model ⇒ Object
44 45 46 |
# File 'lib/maven/tools/dsl.rb', line 44 def model @model end |
#organization(*args, &block) ⇒ Object
316 317 318 319 320 321 322 323 324 325 326 327 328 |
# File 'lib/maven/tools/dsl.rb', line 316 def organization( *args, &block ) if @context == :project args, = ( *args ) org = ( @current.organization ||= Organization.new ) org.name = args[ 0 ] org.url = args[ 1 ] ( org, ) nested_block( :organization, org, block ) if block org else @current.organization = args[ 0 ] end end |
#other_archives(*archives) ⇒ Object
411 412 413 |
# File 'lib/maven/tools/dsl.rb', line 411 def other_archives( *archives ) @current.other_archives = archives end |
#overrides(&block) ⇒ Object Also known as: plugin_management, dependency_management
681 682 683 |
# File 'lib/maven/tools/dsl.rb', line 681 def overrides(&block) nested_block(:overrides, @current, block) if block end |
#path(*args) ⇒ Object
80 81 82 |
# File 'lib/maven/tools/dsl.rb', line 80 def path( *args ) warn 'path block not implemented' end |
#phase(name) ⇒ Object
875 876 877 878 879 |
# File 'lib/maven/tools/dsl.rb', line 875 def phase( name ) @phase = name yield @phase = nil end |
#platforms(*args) ⇒ Object
93 94 95 96 97 |
# File 'lib/maven/tools/dsl.rb', line 93 def platforms( *args ) if is_jruby_platform( *args ) yield end end |
#plugin(*gav, &block) ⇒ Object
665 666 667 668 669 670 671 |
# File 'lib/maven/tools/dsl.rb', line 665 def plugin( *gav, &block ) gav, = plugin_gav( *gav ) plugin = fill_gav( @context == :reporting ? ReportPlugin : Plugin, gav) do_plugin( true, plugin, , &block ) end |
#plugin!(*gav, &block) ⇒ Object
621 622 623 624 625 626 627 628 629 630 631 632 633 634 |
# File 'lib/maven/tools/dsl.rb', line 621 def plugin!( *gav, &block ) gav, = plugin_gav( *gav ) pl = plugins.detect do |p| "#{p.group_id}:#{p.artifact_id}:#{p.version}" == gav end if pl do_plugin( false, pl, , &block ) else plugin = fill_gav( @context == :reporting ? ReportPlugin : Plugin, gav) do_plugin( true, plugin, , &block ) end end |
#plugin_repository(url, options = {}, &block) ⇒ Object
509 510 511 |
# File 'lib/maven/tools/dsl.rb', line 509 def plugin_repository( url, = {}, &block ) do_repository( :plugin, url, , block ) end |
#prerequisites(*args, &block) ⇒ Object
397 398 399 400 401 402 403 404 |
# File 'lib/maven/tools/dsl.rb', line 397 def prerequisites( *args, &block ) pre = Prerequisites.new args, = ( *args ) ( pre, ) nested_block( :prerequisites, pre, block ) if block @current.prerequisites = pre pre end |
#profile(id, &block) ⇒ Object
881 882 883 884 885 886 |
# File 'lib/maven/tools/dsl.rb', line 881 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
341 342 343 344 345 346 347 348 |
# File 'lib/maven/tools/dsl.rb', line 341 def project( *args, &block ) raise 'mixed up hierachy' unless @current == model args, = ( *args ) @current.name = args[ 0 ] @current.url = args[ 1 ] ( @current, ) nested_block(:project, @current, block) if block end |
#properties(props = {}) ⇒ Object
583 584 585 586 587 588 |
# File 'lib/maven/tools/dsl.rb', line 583 def properties(props = {}) props.each do |k,v| @current.properties[k.to_s] = v.to_s end @current.properties end |
#property(options) ⇒ Object
444 445 446 447 448 449 |
# File 'lib/maven/tools/dsl.rb', line 444 def property( ) prop = ActivationProperty.new prop.name = [ :name ] || [ 'name' ] prop.value = [ :value ] || [ 'value' ] @current.property = prop end |
#releases(config) ⇒ Object
521 522 523 |
# File 'lib/maven/tools/dsl.rb', line 521 def releases( config ) @current.releases = repository_policy( config ) end |
#report_set(*reports, &block) ⇒ Object
888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 |
# File 'lib/maven/tools/dsl.rb', line 888 def report_set( *reports, &block ) set = ReportSet.new case reports.last when Hash = reports.last reports = reports[ 0..-2 ] id = .delete( :id ) || .delete( 'id' ) set.id = id if id inherited = .delete( :inherited ) || .delete( 'inherited' ) set.inherited = inherited if inherited end set_config( set, ) set.reports = reports#.to_java @current.report_sets << set end |
#reporting(&block) ⇒ Object
905 906 907 908 909 |
# File 'lib/maven/tools/dsl.rb', line 905 def reporting( &block ) reporting = Reporting.new @current.reporting = reporting nested_block( :reporting, reporting, block ) if block end |
#repository(url, options = {}, &block) ⇒ Object
505 506 507 |
# File 'lib/maven/tools/dsl.rb', line 505 def repository( url, = {}, &block ) do_repository( :repository=, url, , block ) end |
#repository_policy(config) ⇒ Object
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 |
# File 'lib/maven/tools/dsl.rb', line 529 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
495 496 497 498 499 500 501 502 503 |
# File 'lib/maven/tools/dsl.rb', line 495 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
794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 |
# File 'lib/maven/tools/dsl.rb', line 794 def retrieve_dependency( type, *args ) if args.empty? a = type type = a[ :type ] = a elsif args[ 0 ].is_a?( ::Maven::Tools::Artifact ) a = args[ 0 ] type = a[ :type ] = a else a = ::Maven::Tools::Artifact.from( type, *args ) end ||= {} d = fill_gav( Dependency, a ? a.gav : args.join( ':' ) ) d.type = type.to_s # TODO maybe copy everything from options ? d.scope = [ :scope ] if [ :scope ] d.system_path = [ :system_path ] if [ :system_path ] d end |
#roles(*roles) ⇒ Object
440 441 442 |
# File 'lib/maven/tools/dsl.rb', line 440 def roles( *roles ) @current.roles = roles end |
#ruby(*args) ⇒ Object
76 77 78 |
# File 'lib/maven/tools/dsl.rb', line 76 def ruby( *args ) # ignore end |
#scope(name) ⇒ Object
869 870 871 872 873 |
# File 'lib/maven/tools/dsl.rb', line 869 def scope( name ) @scope = name yield @scope = nil end |
#set_config(receiver, options) ⇒ Object
1038 1039 1040 |
# File 'lib/maven/tools/dsl.rb', line 1038 def set_config( receiver, ) receiver.configuration = end |
#setup_jruby_plugins_version ⇒ Object
598 599 600 601 602 |
# File 'lib/maven/tools/dsl.rb', line 598 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
364 365 366 367 368 369 |
# File 'lib/maven/tools/dsl.rb', line 364 def site( url = nil, = {} ) site = Site.new .merge!( :url => url ) ( site, ) @current.site = site end |
#snapshot_repository(url, options = {}, &block) ⇒ Object
513 514 515 516 517 518 519 |
# File 'lib/maven/tools/dsl.rb', line 513 def snapshot_repository( url, = {}, &block ) unless @current.respond_to? :snapshot_repository= [ :releases ] = false unless .key?( :releases ) || .key?( 'releases' ) [ :snapshots ] = true unless .key?( :snapshots ) || .key?( 'snapshots' ) end do_repository( :snapshot_repository=, url, , block ) end |
#snapshots(config) ⇒ Object
525 526 527 |
# File 'lib/maven/tools/dsl.rb', line 525 def snapshots( config ) @current.snapshots = repository_policy( config ) end |
#source(*args) ⇒ Object
72 73 74 |
# File 'lib/maven/tools/dsl.rb', line 72 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
371 372 373 374 375 376 |
# File 'lib/maven/tools/dsl.rb', line 371 def source_control( url = nil, = {} ) scm = Scm.new .merge!( :url => url ) ( scm, ) @current.scm = scm end |
#spec(spec, name = nil, options = {}) ⇒ Object
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 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
# File 'lib/maven/tools/dsl.rb', line 259 def spec( spec, name = nil, = {} ) 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 url spec.homepage unless [ :only_metadata ] packaging 'gem' extension 'de.saumya.mojo:gem-extension:${jruby.plugins.version}' end end setup_gem_support( , spec ) return if [ :only_metadata ] config = { :gemspec => name.sub( /^#{basedir}\/?/, '' ) } if [ :include_jars ] || [ '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 25 26 27 28 29 30 31 32 33 34 |
# 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 if @needs_torquebox if ! @model.repositories.detect { |r| r.id == 'rubygems-prereleases' } && @model.dependencies.detect { |d| d.group_id == 'rubygems' && d.version.match( /[a-zA-Z]/ ) } @current = @model snapshot_repository( 'http://rubygems-proxy.torquebox.org/prereleases', :id => 'rubygems-prereleases' ) @current = nil end @needs_torquebox = nil end result = @model @context = nil @model = nil result end |
#test_resource(&block) ⇒ Object
483 484 485 486 487 488 489 490 491 492 493 |
# File 'lib/maven/tools/dsl.rb', line 483 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
1034 1035 1036 |
# File 'lib/maven/tools/dsl.rb', line 1034 def xml( xml ) raise 'Xpp3DomBuilder.build( java.io.StringReader.new( xml ) )' end |