module Buildr::Ant

Constants

VERSION

Which version of Ant we're using by default.

Public Class Methods

dependencies() click to toggle source

Ant classpath dependencies.

# File lib/buildr/java/ant.rb, line 34
def dependencies
  # Ant-Trax required for running the JUnitReport task, and there's no other place
  # to put it but the root classpath.
  @dependencies ||= ["org.apache.ant:ant:jar:#{version}", "org.apache.ant:ant-launcher:jar:#{version}"]
end
version() click to toggle source

Current version of Ant being used.

# File lib/buildr/java/ant.rb, line 29
def version
  Buildr.settings.build['ant'] || VERSION
end

Public Instance Methods

ant(name) { |AntProject| ... } → AntProject click to toggle source

Creates a new AntProject with the specified name, yield to the block for defining various Ant tasks, and executes each task as it's defined.

For example:

ant("hibernatedoclet') do |doclet|
  doclet.taskdef :name=>'hibernatedoclet',
    :classname=>'xdoclet.modules.hibernate.HibernateDocletTask', :classpath=>DOCLET
  doclet.hibernatedoclet :destdir=>dest_dir, :force=>'true' do
    hibernate :version=>'3.0'
    fileset :dir=>source, :includes=>'**/*.java'
  end
end
# File lib/buildr/java/ant.rb, line 60
def ant(name, &block)
  options = { :name=>name, :basedir=>Dir.pwd, :declarative=>true }
  options.merge!(:logger=> Logger.new(STDOUT), :loglevel=> Logger::DEBUG) if trace?(:ant)
  Java.load
  Antwrap::AntProject.new(options).tap do |project|
    # Set Ant logging level to debug (--trace), info (default) or error only (--quiet).
    project.project.getBuildListeners().get(0).
      setMessageOutputLevel((trace?(:ant) && 4) || (verbose && 2) || 0)
    yield project if block_given?
  end
end