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
- #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
- #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
- #resource(&block) ⇒ Object
- #respository_policy(method, config) ⇒ 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)
- #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
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( , &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
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 ) 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.( @source ) ) end @basedir ||= File.( '.' ) 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, = ( *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
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
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_container ⇒ Object
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, = ( *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
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 ) = 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
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) = args.last 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 |
#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, = {}, &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
690 691 692 693 694 695 696 |
# File 'lib/maven/tools/dsl.rb', line 690 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
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 = 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
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( ) file = ActivationFile.new file.missing = [ :missing ] || [ 'missing' ] file.exists = [ :exists ] || [ '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 ( receiver, ) .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
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', = {} ) 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
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, = @gemfile_options || {} ) unless model.properties.member?( 'project.build.sourceEncoding' ) properties( 'project.build.sourceEncoding' => 'utf-8' ) end @gemfile_options = nil 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 FileUtils.cd( basedir ) do spec = eval( File.read( File.( 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( , spec ) 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 |
#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, = ( *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
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, = ( *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
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', = {} ) 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
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, = ( *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
914 915 916 917 918 |
# File 'lib/maven/tools/dsl.rb', line 914 def local( path, = {} ) path = File.( path ) dependency( :jar, Maven::Tools::Artifact.new_local( path, :jar, ) ) 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, = ( *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
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 |
#model ⇒ Object
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, = ( *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
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, = plugin_gav( *gav ) plugin = fill_gav( @context == :reporting ? ReportPlugin : Plugin, gav) do_plugin( true, plugin, , &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, = 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
476 477 478 |
# File 'lib/maven/tools/dsl.rb', line 476 def plugin_repository( url, = {}, &block ) do_repository( :plugin, url, , 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, = ( *args ) ( pre, ) 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, = ( *args ) @current.name = args[ 0 ] @current.url = args[ 1 ] ( @current, ) 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( ) prop = ActivationProperty.new prop.name = [ :name ] || [ 'name' ] prop.value = [ :value ] || [ '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 = 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
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, = {}, &block ) do_repository( :repository=, url, , 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 ] = 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 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, ) receiver.configuration = end |
#setup_jruby_plugins_version ⇒ Object
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, = {} ) site = Site.new .merge!( :url => url ) ( site, ) @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, = {}, &block ) do_repository( :snapshot_repository=, url, , 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, = {} ) scm = Scm.new .merge!( :url => url ) ( scm, ) @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 |