Module: Maven::Tools::DSL
- Included in:
- POM
- Defined in:
- lib/maven/tools/dsl.rb
Instance Method Summary collapse
- #_dependency(type, *args, &block) ⇒ Object
- #_dependency!(type, *args, &block) ⇒ Object
- #_dependency?(type, *args) ⇒ Boolean
- #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
- #ci_management(*args, &block) ⇒ Object (also: #ci)
- #configuration(v) ⇒ Object
- #contributor(*args, &block) ⇒ Object
- #dependency(*args, &block) ⇒ Object
- #dependency_container ⇒ Object
- #dependency_set(bang, container, dep) ⇒ Object
- #developer(*args, &block) ⇒ Object
- #directory(val) ⇒ Object
- #distribution(*args, &block) ⇒ Object
- #distribution_management(*args, &block) ⇒ Object
- #do_dependency(bang, type, *args, &block) ⇒ Object
- #do_gem(bang, *args) ⇒ Object
- #do_jruby_plugin(method, *gav, &block) ⇒ Object
- #enabled(value) ⇒ Object
- #eval_pom(src, reference_file) ⇒ Object
- #excludes(*items) ⇒ Object
- #exclusion(*gav) ⇒ Object
- #execute(id = nil, phase = nil, options = {}, &block) ⇒ Object
- #execute_goal(goal, options = {}, &block) ⇒ Object
- #execute_goals(*goals, &block) ⇒ Object
- #extension(*args) ⇒ Object
- #file(options) ⇒ Object
- #fill(receiver, method, args) ⇒ Object
- #fill_options(receiver, options) ⇒ Object
- #final_name(val) ⇒ 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 = {}) ⇒ Object
- #git(*args) ⇒ Object
- #group(*args) ⇒ Object
- #id(*args) ⇒ Object
- #includes(*items) ⇒ Object
- #inherit(*args, &block) ⇒ Object (also: #parent)
- #issue_management(*args, &block) ⇒ Object (also: #issues)
- #jar!(*args) ⇒ Object
- #jarfile(file = 'Jarfile', options = {}) ⇒ Object
- #jruby_plugin(*gav, &block) ⇒ Object
- #jruby_plugin!(*gav, &block) ⇒ Object
- #license(*args, &block) ⇒ Object
- #licenses ⇒ Object (also: #developers, #contributors, #mailing_lists, #notifiers, #dependencies, #repositories, #plugin_repositories, #extensions, #resources, #testResources, #plugins)
- #local(path, options = {}) ⇒ Object
- #mailing_list(*args, &block) ⇒ Object
- #maven(val = nil, &block) ⇒ Object
- #method_missing(method, *args, &block) ⇒ Object
- #model ⇒ Object
- #notifier(*args, &block) ⇒ Object
- #organization(*args, &block) ⇒ Object
- #other_archives(*archives) ⇒ Object
- #output_directory(val) ⇒ Object
- #overrides(&block) ⇒ Object (also: #plugin_management, #dependency_management)
- #path(*args) ⇒ Object
- #phase(name, &block) ⇒ Object
- #platforms(*args) ⇒ Object
- #plugin(*gav, &block) ⇒ Object
- #plugin!(*gav, &block) ⇒ Object
- #plugin_repository(*args, &block) ⇒ Object
- #prepare_config(receiver, options) ⇒ Object
- #prerequisites(*args, &block) ⇒ Object
- #profile(*args, &block) ⇒ Object
- #profile!(id, &block) ⇒ Object
- #project(*args, &block) ⇒ Object
- #properties(props = {}) ⇒ Object
- #property(options) ⇒ Object
- #releases(config = nil, &block) ⇒ Object
- #relocation(*args, &block) ⇒ Object
- #report_set(*reports, &block) ⇒ Object
- #reporting(&block) ⇒ Object
- #repository(*args, &block) ⇒ Object
- #repository_policy(rp, config, &block) ⇒ Object
- #resource(options = {}, &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(*args, &block) ⇒ Object
- #snapshot_repository(*args, &block) ⇒ Object
- #snapshots(config = nil, &block) ⇒ Object
- #source(*args) ⇒ Object
- #source_control(*args, &block) ⇒ Object (also: #scm)
- #spec(spec, name = nil, options = {}) ⇒ Object
- #system(*args) ⇒ Object
- #tesla(&block) ⇒ Object
- #test_resource(options = {}, &block) ⇒ Object
- #xml(xml) ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 |
# File 'lib/maven/tools/dsl.rb', line 1307 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 begin # 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 ) ) case method.to_s[ -1 ] when '?' _dependency?( method.to_s[0..-2].to_sym, *args, &block ) when '!' _dependency!( method.to_s[0..-2].to_sym, *args, &block ) else _dependency( method, *args, &block ) end # elsif @current.respond_to? method # @current.send( method, *args ) # @current # else rescue => e p @context p m p args raise e end end else super end end |
Instance Method Details
#_dependency(type, *args, &block) ⇒ Object
1049 1050 1051 |
# File 'lib/maven/tools/dsl.rb', line 1049 def _dependency( type, *args, &block ) do_dependency( false, type, *args, &block ) end |
#_dependency!(type, *args, &block) ⇒ Object
1053 1054 1055 |
# File 'lib/maven/tools/dsl.rb', line 1053 def _dependency!( type, *args, &block ) do_dependency( true, type, *args, &block ) end |
#_dependency?(type, *args) ⇒ Boolean
1057 1058 1059 1060 |
# File 'lib/maven/tools/dsl.rb', line 1057 def _dependency?( type, *args ) find_dependency( dependency_container, retrieve_dependency( type, *args ) ) != nil end |
#activation(&block) ⇒ Object
684 685 686 687 688 |
# File 'lib/maven/tools/dsl.rb', line 684 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
999 1000 1001 1002 1003 1004 1005 1006 1007 1008 |
# File 'lib/maven/tools/dsl.rb', line 999 def add_execute_task( , &block ) @model.properties[ 'tesla.version' ] = VERSIONS[ :tesla_version ] plugin!( 'io.tesla.polyglot:tesla-polyglot-maven-plugin', '${tesla.version}' ) do execute_goal( :execute, ) jar!( 'io.tesla.polyglot:tesla-polyglot-ruby', '${tesla.version}' ) end end |
#archives(*archives) ⇒ Object
632 633 634 635 |
# File 'lib/maven/tools/dsl.rb', line 632 def archives( *archives ) @current.archive = archives.shift @current.other_archives = archives end |
#args_and_options(*args) ⇒ Object
813 814 815 816 817 818 819 |
# File 'lib/maven/tools/dsl.rb', line 813 def ( *args ) if args.last.is_a? Hash [ args[0..-2], args.last ] else [ args, {} ] end end |
#artifact(a) ⇒ Object
66 67 68 69 70 71 |
# File 'lib/maven/tools/dsl.rb', line 66 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
57 58 59 60 61 62 63 64 |
# File 'lib/maven/tools/dsl.rb', line 57 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
478 479 480 481 482 |
# File 'lib/maven/tools/dsl.rb', line 478 def build( &block ) build = @current.build ||= Build.new nested_block( :build, build, block ) if block build end |
#ci_management(*args, &block) ⇒ Object Also known as: ci
566 567 568 569 570 571 572 573 |
# File 'lib/maven/tools/dsl.rb', line 566 def ci_management( *args, &block ) ci = CiManagement.new args, = ( *args ) ci.url = args[ 0 ] ( ci, ) nested_block( :ci_management, ci, block ) if block @current.ci_management = ci end |
#configuration(v) ⇒ Object
1386 1387 1388 1389 1390 1391 1392 |
# File 'lib/maven/tools/dsl.rb', line 1386 def configuration( v ) if @context == :notifier @current.configuration = v else set_config( @current, v ) end end |
#contributor(*args, &block) ⇒ Object
654 655 656 657 658 659 660 661 662 663 664 |
# File 'lib/maven/tools/dsl.rb', line 654 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(*args, &block) ⇒ Object
1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 |
# File 'lib/maven/tools/dsl.rb', line 1203 def dependency( *args, &block ) dep = Dependency.new args, = ( *args ) dep.group_id = args[ 0 ] dep.artifact_id = args[ 1 ] dep.version = args[ 2 ] dep.type = :jar ( dep, ) nested_block( :dependency, dep, block ) if block dependency_container << dep dep end |
#dependency_container ⇒ Object
1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 |
# File 'lib/maven/tools/dsl.rb', line 1105 def dependency_container if @context == :overrides @current.dependency_management ||= DependencyManagement.new @current.dependency_management.dependencies #elsif @context == :build # @current. else @current.dependencies end end |
#dependency_set(bang, container, dep) ⇒ Object
1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 |
# File 'lib/maven/tools/dsl.rb', line 1068 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
641 642 643 644 645 646 647 648 649 650 651 652 |
# File 'lib/maven/tools/dsl.rb', line 641 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 |
#directory(val) ⇒ Object
746 747 748 |
# File 'lib/maven/tools/dsl.rb', line 746 def directory( val ) build_method( __method__, val ) end |
#distribution(*args, &block) ⇒ Object
690 691 692 693 694 695 696 697 698 |
# File 'lib/maven/tools/dsl.rb', line 690 def distribution( *args, &block ) if @context == :license args, = ( *args ) @current.distribution = args[ 0 ] ( @current, ) else distribution_management( *args, &block ) end end |
#distribution_management(*args, &block) ⇒ Object
576 577 578 579 580 581 582 583 584 |
# File 'lib/maven/tools/dsl.rb', line 576 def distribution_management( *args, &block ) di = DistributionManagement.new args, = ( *args ) di.status = args[ 0 ] di.download_url = args[ 1 ] ( di, ) nested_block( :distribution_management, di, block ) if block @current.distribution_management = di end |
#do_dependency(bang, type, *args, &block) ⇒ Object
1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 |
# File 'lib/maven/tools/dsl.rb', line 1116 def do_dependency( bang, type, *args, &block ) 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 args, = ( *args ) 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| v, opts = ( v ) ex = fill_gav( Exclusion, *v ) ( ex, opts ) d.exclusions << ex 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 nested_block( :dependency, d, block ) if block d end |
#do_gem(bang, *args) ⇒ Object
1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 |
# File 'lib/maven/tools/dsl.rb', line 1258 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 elsif @group = {} args << end if # 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 if group group = [ group ].flatten.each { |g| g.to_sym } if group.member? :development [ :scope ] = :provided elsif group.member? :test [ :scope ] = :test 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
884 885 886 887 888 889 890 891 |
# File 'lib/maven/tools/dsl.rb', line 884 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 |
#enabled(value) ⇒ Object
809 810 811 |
# File 'lib/maven/tools/dsl.rb', line 809 def enabled( value ) @current.enabled = ( value.to_s == 'true' ) end |
#eval_pom(src, reference_file) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/maven/tools/dsl.rb', line 49 def eval_pom( src, reference_file ) @source = reference_file || '.' eval( src, nil, ::File.( @source ) ) ensure @source = nil @basedir = nil end |
#excludes(*items) ⇒ Object
704 705 706 |
# File 'lib/maven/tools/dsl.rb', line 704 def excludes( *items ) @current.excludes = items.flatten end |
#exclusion(*gav) ⇒ Object
870 871 872 873 874 875 |
# File 'lib/maven/tools/dsl.rb', line 870 def exclusion( *gav ) gav = gav.join( ':' ) ex = fill_gav( Exclusion, gav ) @current.exclusions << ex ex end |
#execute(id = nil, phase = nil, options = {}, &block) ⇒ Object
973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 |
# File 'lib/maven/tools/dsl.rb', line 973 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
1022 1023 1024 1025 1026 1027 1028 |
# File 'lib/maven/tools/dsl.rb', line 1022 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
1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 |
# File 'lib/maven/tools/dsl.rb', line 1030 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(*args) ⇒ Object
857 858 859 860 861 862 863 864 865 866 867 868 |
# File 'lib/maven/tools/dsl.rb', line 857 def extension( *args ) build = if @context == :build @current else @current.build ||= Build.new end args, = ( *args ) ext = fill_gav( Extension, args.join( ':' ) ) ( ext, ) build.extensions << ext ext end |
#file(options) ⇒ Object
677 678 679 680 681 682 |
# File 'lib/maven/tools/dsl.rb', line 677 def file( ) file = ActivationFile.new file.missing = [ :missing ] || [ 'missing' ] file.exists = [ :exists ] || [ 'exists' ] @current.file = file end |
#fill(receiver, method, args) ⇒ Object
827 828 829 830 831 832 833 834 835 836 837 838 |
# File 'lib/maven/tools/dsl.rb', line 827 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
821 822 823 824 825 |
# File 'lib/maven/tools/dsl.rb', line 821 def ( receiver, ) .each do |k,v| receiver.send( "#{k}=".to_sym, v ) end end |
#final_name(val) ⇒ Object
742 743 744 |
# File 'lib/maven/tools/dsl.rb', line 742 def final_name( val ) build_method( __method__, val ) end |
#find_dependency(container, dep) ⇒ Object
1062 1063 1064 1065 1066 |
# File 'lib/maven/tools/dsl.rb', line 1062 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
1249 1250 1251 |
# File 'lib/maven/tools/dsl.rb', line 1249 def gem( *args ) do_gem( false, *args ) end |
#gem!(*args) ⇒ Object
TODO useful ?
1254 1255 1256 |
# File 'lib/maven/tools/dsl.rb', line 1254 def gem!( *args ) do_gem( true, *args ) end |
#gem?(name) ⇒ Boolean
1239 1240 1241 1242 1243 |
# File 'lib/maven/tools/dsl.rb', line 1239 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
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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/maven/tools/dsl.rb', line 107 def gemfile( name = 'Gemfile', = {} ) if name.is_a? Hash = name name = 'Gemfile' end name = ::File.join( basedir, name ) unless ::File.exists?( name ) @inside_gemfile = true # the eval might need those options for gemspec declaration lockfile = ::File.( name + '.lock' ) if File.exists? lockfile pr = profile :gemfile do activation do file( :missing => name + '.lock' ) end FileUtils.cd( basedir ) do f = ::File.( name ) eval( ::File.read( f ), nil, f ) end end @inside_gemfile = :gemfile else FileUtils.cd( basedir ) do f = ::File.( name ) eval( ::File.read( f ), nil, f ) end @inside_gemfile = false end if @gemspec_args case @gemspec_args[ 0 ] when Hash gemspec( @gemspec_args[ 0 ].merge( ) ) when NilClass gemspec( @gemspec_args[ 0 ], ) else @gemspec_args[ 1 ].merge!( ) gemspec( *@gemspec_args ) end else setup_gem_support( ) jruby_plugin!( :gem ) do execute_goal :initialize, :id => 'install gems' end end if pr && pr.dependencies.empty? @current.profiles.delete( pr ) end if pr && !pr.dependencies.empty? profile :gemfile_lock do activation do file( :exists => name + '.lock' ) end locked = GemfileLock.new( lockfile ) done = add_scoped_hull( locked, pr.dependencies ) done += add_scoped_hull( locked, pr.dependencies, done, :provided ) add_scoped_hull( locked, pr.dependencies, done, :test ) end end if @has_path or @has_git gem 'bundler', VERSIONS[ :bundler_version ], :scope => :provided unless gem? 'bundler' jruby_plugin! :gem do execute_goal( :exec, :id => 'bundle install', :filename => 'bundle', :args => 'install' ) end end ensure @inside_gemfile = nil @gemspec_args = nil @has_path = nil @has_git = nil end |
#gemspec(name = nil, options = {}) ⇒ Object
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
# File 'lib/maven/tools/dsl.rb', line 349 def gemspec( name = nil, = {} ) if @inside_gemfile == true @gemspec_args = [ name, ] return end 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 f = ::File.( name ) spec_file = ::File.read( f ) begin spec = Gem::Specification.from_yaml( spec_file ) rescue FileUtils.cd( basedir ) do # TODO jruby java user.dir spec = eval( spec_file, nil, f ) end end self.spec( spec, name, ) end |
#git(*args) ⇒ Object
85 86 87 |
# File 'lib/maven/tools/dsl.rb', line 85 def git( *args ) warn 'git block not implemented' end |
#group(*args) ⇒ Object
100 101 102 103 104 105 |
# File 'lib/maven/tools/dsl.rb', line 100 def group( *args ) @group = args yield ensure @group = nil end |
#id(*args) ⇒ Object
518 519 520 521 522 523 524 525 526 527 528 529 530 |
# File 'lib/maven/tools/dsl.rb', line 518 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
700 701 702 |
# File 'lib/maven/tools/dsl.rb', line 700 def includes( *items ) @current.includes = items.flatten end |
#inherit(*args, &block) ⇒ Object Also known as: parent
840 841 842 843 844 845 846 847 |
# File 'lib/maven/tools/dsl.rb', line 840 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(*args, &block) ⇒ Object Also known as: issues
555 556 557 558 559 560 561 562 563 |
# File 'lib/maven/tools/dsl.rb', line 555 def issue_management( *args, &block ) issues = IssueManagement.new args, = ( *args ) issues.url = args[ 0 ] issues.system = args[ 1 ] ( issues, ) nested_block( :issue_management, issues, block ) if block @current.issue_management = issues end |
#jar!(*args) ⇒ Object
1245 1246 1247 |
# File 'lib/maven/tools/dsl.rb', line 1245 def jar!( *args ) _dependency!( :jar, *args ) end |
#jarfile(file = 'Jarfile', options = {}) ⇒ Object
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/maven/tools/dsl.rb', line 307 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| jarfile_dsl( dsl ) dsl.artifacts.each do |a| _dependency a end end else file.locked.each do |dep| artifact( dep ) end file.populate_unlocked do |dsl| jarfile_dsl( dsl ) dsl.artifacts.each do |a| if a[ :system_path ] dependeny a end end end end end |
#jruby_plugin(*gav, &block) ⇒ Object
893 894 895 |
# File 'lib/maven/tools/dsl.rb', line 893 def jruby_plugin( *gav, &block ) do_jruby_plugin( :plugin, *gav, &block ) end |
#jruby_plugin!(*gav, &block) ⇒ Object
897 898 899 |
# File 'lib/maven/tools/dsl.rb', line 897 def jruby_plugin!( *gav, &block ) do_jruby_plugin( :plugin!, *gav, &block ) end |
#license(*args, &block) ⇒ Object
498 499 500 501 502 503 504 505 506 507 |
# File 'lib/maven/tools/dsl.rb', line 498 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 |
#licenses ⇒ Object Also known as: developers, contributors, mailing_lists, notifiers, dependencies, repositories, plugin_repositories, extensions, resources, testResources, plugins
463 464 465 |
# File 'lib/maven/tools/dsl.rb', line 463 def licenses yield end |
#local(path, options = {}) ⇒ Object
1301 1302 1303 1304 1305 |
# File 'lib/maven/tools/dsl.rb', line 1301 def local( path, = {} ) path = ::File.( path ) _dependency( :jar, Maven::Tools::Artifact.new_local( path, :jar, ) ) end |
#mailing_list(*args, &block) ⇒ Object
613 614 615 616 617 618 619 620 621 |
# File 'lib/maven/tools/dsl.rb', line 613 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
37 38 39 40 41 42 43 |
# File 'lib/maven/tools/dsl.rb', line 37 def maven( val = nil, &block ) if @context == nil tesla( &block ) else @current.maven = val end end |
#model ⇒ Object
45 46 47 |
# File 'lib/maven/tools/dsl.rb', line 45 def model @model end |
#notifier(*args, &block) ⇒ Object
602 603 604 605 606 607 608 609 610 611 |
# File 'lib/maven/tools/dsl.rb', line 602 def notifier( *args, &block ) n = Notifier.new args, = ( *args ) n.type = args[ 0 ] n.address = args[ 1 ] ( n, ) nested_block( :notifier, n, block ) if block @current.notifiers << n n end |
#organization(*args, &block) ⇒ Object
484 485 486 487 488 489 490 491 492 493 494 495 496 |
# File 'lib/maven/tools/dsl.rb', line 484 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
637 638 639 |
# File 'lib/maven/tools/dsl.rb', line 637 def other_archives( *archives ) @current.other_archives = archives end |
#output_directory(val) ⇒ Object
750 751 752 |
# File 'lib/maven/tools/dsl.rb', line 750 def output_directory( val ) build_method( __method__, val ) end |
#overrides(&block) ⇒ Object Also known as: plugin_management, dependency_management
967 968 969 |
# File 'lib/maven/tools/dsl.rb', line 967 def overrides(&block) nested_block(:overrides, @current, block) if block end |
#path(*args) ⇒ Object
81 82 83 |
# File 'lib/maven/tools/dsl.rb', line 81 def path( *args ) warn 'path block not implemented' end |
#phase(name, &block) ⇒ Object
1173 1174 1175 1176 1177 1178 1179 1180 1181 |
# File 'lib/maven/tools/dsl.rb', line 1173 def phase( name, &block ) if @context != :plugin && block @phase = name yield @phase = nil else @current.phase = name end end |
#platforms(*args) ⇒ Object
94 95 96 97 98 |
# File 'lib/maven/tools/dsl.rb', line 94 def platforms( *args ) if is_jruby_platform( *args ) yield end end |
#plugin(*gav, &block) ⇒ Object
951 952 953 954 955 956 957 |
# File 'lib/maven/tools/dsl.rb', line 951 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
901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 |
# File 'lib/maven/tools/dsl.rb', line 901 def plugin!( *gav, &block ) gav, = plugin_gav( *gav ) ga = gav.sub( /:[^:]*$/, '' ) pl = plugins.detect do |p| "#{p.group_id}:#{p.artifact_id}" == ga 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(*args, &block) ⇒ Object
757 758 759 |
# File 'lib/maven/tools/dsl.rb', line 757 def plugin_repository( *args, &block ) do_repository( :plugin, *args, &block ) end |
#prepare_config(receiver, options) ⇒ Object
1375 1376 1377 1378 1379 |
# File 'lib/maven/tools/dsl.rb', line 1375 def prepare_config( receiver, ) return unless inherited = .delete( 'inherited' ) || .delete( :inherited ) receiver.inherited = inherited if inherited end |
#prerequisites(*args, &block) ⇒ Object
623 624 625 626 627 628 629 630 |
# File 'lib/maven/tools/dsl.rb', line 623 def prerequisites( *args, &block ) pre = Prerequisites.new args, = ( *args ) ( pre, ) nested_block( :prerequisites, pre, block ) if block @current.prerequisites = pre pre end |
#profile(*args, &block) ⇒ Object
1193 1194 1195 1196 1197 1198 1199 1200 1201 |
# File 'lib/maven/tools/dsl.rb', line 1193 def profile( *args, &block ) profile = Profile.new args, = ( *args ) profile.id = args[ 0 ] ( profile, ) @current.profiles << profile nested_block( :profile, profile, block ) if block profile end |
#profile!(id, &block) ⇒ Object
1183 1184 1185 1186 1187 1188 1189 1190 1191 |
# File 'lib/maven/tools/dsl.rb', line 1183 def profile!( id, &block ) profile = @current.profiles.detect { |p| p.id.to_s == id.to_s } if profile nested_block( :profile, profile, block ) if block profile else profile( id, &block ) end end |
#project(*args, &block) ⇒ Object
509 510 511 512 513 514 515 516 |
# File 'lib/maven/tools/dsl.rb', line 509 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
850 851 852 853 854 855 |
# File 'lib/maven/tools/dsl.rb', line 850 def properties(props = {}) props.each do |k,v| @current.properties[k.to_s] = v.to_s end @current.properties end |
#property(options) ⇒ Object
670 671 672 673 674 675 |
# File 'lib/maven/tools/dsl.rb', line 670 def property( ) prop = ActivationProperty.new prop.name = [ :name ] || [ 'name' ] prop.value = [ :value ] || [ 'value' ] @current.property = prop end |
#releases(config = nil, &block) ⇒ Object
781 782 783 784 |
# File 'lib/maven/tools/dsl.rb', line 781 def releases( config = nil, &block ) @current.releases = repository_policy( @current.releases, config, &block ) end |
#relocation(*args, &block) ⇒ Object
586 587 588 589 590 591 592 |
# File 'lib/maven/tools/dsl.rb', line 586 def relocation( *args, &block ) args, = ( *args ) relocation = fill_gav( Relocation, args.join( ':' ) ) ( relocation, ) nested_block( :relocation, relocation, block ) if block @current.relocation = relocation end |
#report_set(*reports, &block) ⇒ Object
1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 |
# File 'lib/maven/tools/dsl.rb', line 1216 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
1233 1234 1235 1236 1237 |
# File 'lib/maven/tools/dsl.rb', line 1233 def reporting( &block ) reporting = Reporting.new @current.reporting = reporting nested_block( :reporting, reporting, block ) if block end |
#repository(*args, &block) ⇒ Object
753 754 755 |
# File 'lib/maven/tools/dsl.rb', line 753 def repository( *args, &block ) do_repository( :repository=, *args, &block ) end |
#repository_policy(rp, config, &block) ⇒ Object
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 |
# File 'lib/maven/tools/dsl.rb', line 791 def repository_policy( rp, config, &block ) rp ||= RepositoryPolicy.new case config when Hash rp.enabled = config[ :enabled ] unless config[ :enabled ].nil? rp.update_policy = config[ :update ] || config[ :update_policy ] rp.checksum_policy = config[ :checksum ] || config[ :checksum_policy ] when TrueClass rp.enabled = true when FalseClass rp.enabled = false else rp.enabled = 'true' == config unless config.nil? end nested_block( :repository_policy, rp, block ) if block rp end |
#resource(options = {}, &block) ⇒ Object
721 722 723 724 725 726 727 728 729 730 |
# File 'lib/maven/tools/dsl.rb', line 721 def resource( = {}, &block ) resource = Resource.new ( resource, ) 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
1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 |
# File 'lib/maven/tools/dsl.rb', line 1081 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 args, = ( *args ) 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
666 667 668 |
# File 'lib/maven/tools/dsl.rb', line 666 def roles( *roles ) @current.roles = roles end |
#ruby(*args) ⇒ Object
77 78 79 |
# File 'lib/maven/tools/dsl.rb', line 77 def ruby( *args ) # ignore end |
#scope(name) ⇒ Object
1163 1164 1165 1166 1167 1168 1169 1170 1171 |
# File 'lib/maven/tools/dsl.rb', line 1163 def scope( name ) if @context == :dependency @current.scope = name else @scope = name yield @scope = nil end end |
#set_config(receiver, options) ⇒ Object
1381 1382 1383 1384 |
# File 'lib/maven/tools/dsl.rb', line 1381 def set_config( receiver, ) prepare_config( receiver, ) receiver.configuration = end |
#setup_jruby_plugins_version ⇒ Object
877 878 879 880 881 882 |
# File 'lib/maven/tools/dsl.rb', line 877 def setup_jruby_plugins_version if not @current.properties.key?( 'jruby.plugins.version' ) and not (@context == :profile and model.properties.key?( 'jruby.plugins.version' ) ) properties( 'jruby.plugins.version' => VERSIONS[ :jruby_plugins ] ) end end |
#site(*args, &block) ⇒ Object
532 533 534 535 536 537 538 539 540 541 |
# File 'lib/maven/tools/dsl.rb', line 532 def site( *args, &block ) site = Site.new args, = ( *args ) site.id = args[ 0 ] site.url = args[ 1 ] site.name = args[ 2 ] ( site, ) nested_block( :site, site, block) if block @current.site = site end |
#snapshot_repository(*args, &block) ⇒ Object
771 772 773 774 775 776 777 778 779 |
# File 'lib/maven/tools/dsl.rb', line 771 def snapshot_repository( *args, &block ) unless @current.respond_to?( :snapshot_repository= ) args, = ( *args ) set_policy( :releases, false, ) set_policy( :snapshots, true, ) args << end do_repository( :snapshot_repository=, *args, &block ) end |
#snapshots(config = nil, &block) ⇒ Object
786 787 788 789 |
# File 'lib/maven/tools/dsl.rb', line 786 def snapshots( config = nil, &block) @current.snapshots = repository_policy( @current.snapshots, config, &block ) end |
#source(*args) ⇒ Object
73 74 75 |
# File 'lib/maven/tools/dsl.rb', line 73 def source(*args) warn "ignore source #{args}" if !(args[0].to_s =~ /^https?:\/\/rubygems.org/) && args[0] != :rubygems end |
#source_control(*args, &block) ⇒ Object Also known as: scm
543 544 545 546 547 548 549 550 551 552 |
# File 'lib/maven/tools/dsl.rb', line 543 def source_control( *args, &block ) scm = Scm.new args, = ( *args ) scm.connection = args[ 0 ] scm.developer_connection = args[ 1 ] scm.url = args[ 2 ] ( scm, ) nested_block( :scm, scm, block ) if block @current.scm = scm end |
#spec(spec, name = nil, options = {}) ⇒ Object
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 |
# File 'lib/maven/tools/dsl.rb', line 381 def spec( spec, name = nil, = {} ) name ||= "#{spec.name}-#{spec.version}.gemspec" @gemfile_options = nil if @context == :project build.directory = '${basedir}/pkg' version = spec.version.to_s if [ :snapshot ] && spec.version.prerelease? version += '-SNAPSHOT' end id "rubygems:#{spec.name}:#{version}" name( spec.summary || spec.name ) description spec.description url spec.homepage if spec.homepage && spec.homepage.match( /github.com/ ) con = spec.homepage.sub( /http:/, 'https:' ).sub( /\/?$/, ".git" ) scm :url => spec.homepage, :connection => con end spec.licenses.each do |l| license( l ) end = [ spec. || [] ].flatten emails = [ spec.email || [] ].flatten .zip( emails ).each do |d| developer( :name => d[0], :email => d[1] ) end end has_jars = setup_gem_support( , spec ) if @context == :project and not [ :only_metadata ] packaging 'gem' if has_jars extension 'de.saumya.mojo:gem-with-jar-extension:${jruby.plugins.version}' else extension 'de.saumya.mojo:gem-extension:${jruby.plugins.version}' end end return if [ :only_metadata ] config = { :gemspec => name.sub( /^#{basedir}\/?/, '' ) } if [ :include_jars ] || [ 'include_jars' ] config[ :includeDependencies ] = true config[ :useRepositoryLayout ] = true end jruby_plugin!( :gem, config ) deps = nil if @inside_gemfile.is_a? Symbol profile! @inside_gemfile do deps = all_deps( spec ) end else deps = all_deps( spec ) end unless deps.java_runtime.empty? deps.java_runtime.each do |d| _dependency Maven::Tools::Artifact.new( *d ) end end end |
#system(*args) ⇒ Object
594 595 596 597 598 599 600 |
# File 'lib/maven/tools/dsl.rb', line 594 def system( *args ) if @current && @current.respond_to?( :system ) @current.system = args[ 0 ] else Kernel.system( *args ) end end |
#tesla(&block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/maven/tools/dsl.rb', line 12 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( /-SNAPSHOT/ ) } @current = @model snapshot_repository( 'rubygems-prereleases', 'http://rubygems-proxy.torquebox.org/prereleases' ) @current = nil end @needs_torquebox = nil end result = @model @context = nil @model = nil result end |
#test_resource(options = {}, &block) ⇒ Object
708 709 710 711 712 713 714 715 716 717 718 719 |
# File 'lib/maven/tools/dsl.rb', line 708 def test_resource( = {}, &block ) # strange behaviour when calling specs from Rakefile return if @current.nil? resource = Resource.new ( resource, ) nested_block( :test_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
1368 1369 1370 1371 1372 1373 |
# File 'lib/maven/tools/dsl.rb', line 1368 def xml( xml ) def xml.to_xml self end xml end |