Module: Buildr::Ivy::IvyExtension
- Includes:
- Extension
- Defined in:
- lib/buildr/ivy_extension.rb
Overview
The Ivy Buildr extension adding the new tasks for ivy.
To use ivy in a buildfile do something like:
ENV['BUILDR_EXT_DIR'] ||= '../Ivy'
require 'buildr/ivy_extension'
define 'ivy_project' do
[...]
ivy.compile_conf('compile').test_conf('test').package_conf('prod', 'server')
[...]
end
-
This will add the
compileconfiguration to compile and test tasks -
Add the
testconfiguration to test compilation and execution -
include the artifacts from
prodandserverto any generated war or ear -
The ENV variable is needed to automatically configure the load path for ivy libs. It assumes that you have the following dir structure
[BUILDR_EXT_DIR]/ivy-home/jars
For more configuration options see IvyConfig.
Class Method Summary collapse
- .add_copy_tasks_for_publish(project) ⇒ Object
- .add_ivy_deps_to_java_tasks(project) ⇒ Object
- .add_manifest_to_distributeables(project) ⇒ Object
- .add_prod_libs_to_distributeables(project) ⇒ Object
Instance Method Summary collapse
-
#ivy ⇒ Object
Returns the
ivyconfiguration for the project.
Class Method Details
.add_copy_tasks_for_publish(project) ⇒ Object
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 |
# File 'lib/buildr/ivy_extension.rb', line 529 def add_copy_tasks_for_publish(project) if project.ivy.own_file? Buildr.projects.each do |current| current.packages.each do |pkg| target_file = current.ivy.name[pkg] || File.basename(pkg.name).gsub(/-#{project.version}/, '') taskname = current.path_to(project.ivy.publish_from, target_file) if taskname != pkg.name project.file taskname => pkg.name do verbose "Ivy copying '#{pkg.name}' to '#{taskname}' for publishing" FileUtils.mkdir File.dirname(taskname) unless File.directory?(File.dirname(taskname)) FileUtils.cp pkg.name, taskname end end project.task 'ivy:publish' => taskname end end end end |
.add_ivy_deps_to_java_tasks(project) ⇒ Object
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 |
# File 'lib/buildr/ivy_extension.rb', line 461 def add_ivy_deps_to_java_tasks(project) resolve_target = project.ivy.file_project.task('ivy:resolve') project.task :compiledeps => resolve_target do includes = project.ivy.compile_include excludes = project.ivy.compile_exclude confs = [project.ivy.compile_conf].flatten if deps = project.ivy.filter(confs, :include => includes, :exclude => excludes) project.compile.with deps info "Ivy adding compile dependencies '#{confs.join(', ')}' to project '#{project.name}'" end end project.task :compile => "#{project.name}:compiledeps" project.task :testdeps => resolve_target do includes = project.ivy.test_include excludes = project.ivy.test_exclude confs = [project.ivy.test_conf, project.ivy.compile_conf].flatten.uniq if deps = project.ivy.filter(confs, :include => includes, :exclude => excludes) project.test.with deps info "Ivy adding test dependencies '#{confs.join(', ')}' to project '#{project.name}'" end end project.task "test:compile" => "#{project.name}:testdeps" project.task :javadocdeps => resolve_target do confs = [project.ivy.test_conf, project.ivy.compile_conf].flatten.uniq if deps = project.ivy.deps(confs) project.javadoc.with deps info "Ivy adding javadoc dependencies '#{confs.join(', ')}' to project '#{project.name}'" end end project.task :javadoc => "#{project.name}:javadocdeps" [project.task(:eclipse), project.task(:idea), project.task(:idea7x)].each do |task| task.prerequisites.each{|p| p.enhance ["#{project.name}:compiledeps", "#{project.name}:testdeps"]} end end |
.add_manifest_to_distributeables(project) ⇒ Object
500 501 502 503 504 505 506 507 508 509 510 |
# File 'lib/buildr/ivy_extension.rb', line 500 def add_manifest_to_distributeables(project) pkgs = project.packages.find_all { |pkg| [:jar, :war, :ear].member? pkg.type } pkgs.each do |pkg| name = "#{pkg.name}manifest" task = project.task name => project.ivy.file_project.task('ivy:resolve') do pkg.with :manifest => project.manifest.merge(project.ivy.manifest) info "Adding manifest entries to package '#{pkg.name}'" end project.task :build => task end end |
.add_prod_libs_to_distributeables(project) ⇒ Object
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
# File 'lib/buildr/ivy_extension.rb', line 512 def add_prod_libs_to_distributeables(project) pkgs = project.packages.find_all { |pkg| [:war, :ear].member? pkg.type } pkgs.each do |pkg| name = "#{pkg.name}deps" task = project.task name => project.ivy.file_project.task('ivy:resolve') do includes = project.ivy.package_include excludes = project.ivy.package_exclude confs = project.ivy.package_conf if deps = project.ivy.filter(confs, :include => includes, :exclude => excludes) pkg.with :libs => deps info "Adding production libs from conf '#{confs.join(', ')}' to package '#{pkg.name}' in project '#{project.name}'" end end project.task :build => task end end |