lib/java/ant.rb in buildr-1.1.3 vs lib/java/ant.rb in buildr-1.2.0
- old
+ new
@@ -1,73 +1,70 @@
require "core/project"
require "java/java"
+require "antwrap"
+require "core/help"
+
module Buildr
module Ant
- # Libraries used by #ant.
- REQUIRES = [ "ant:ant:jar:1.6.5", "ant:ant-launcher:jar:1.6.5", "xerces:xercesImpl:jar:2.6.2" ]
+ # Which version of Ant we're using by default.
+ VERSION = "1.7.0"
- # Make sure Ant and friends show on the classpath. Antwrap must only be loaded after RJB.
- Java.rjb.classpath << REQUIRES
- Java.rjb.onload { require "antwrap" }
+ # Libraries used by Ant.
+ REQUIRES = [ "org.apache.ant:ant:jar:#{VERSION}", "org.apache.ant:ant-launcher:jar:#{VERSION}", "xerces:xercesImpl:jar:2.6.2" ]
+ Java.rjb.onload { |rjb| rjb.classpath << REQUIRES }
class << self
- # :call-seq:
- # declarative(name, options?) => AntProject
- # declarative(name, options?) { |AntProject| ... } => AntProject
- #
- # Returns a declarative AntProject with the specified name. Ant tasks created in this project
- # are not executed until you tell them to.
- #
- # See #ant for more information about options and the block.
+ # *Deprecated* Use ant { ... } instead.
def declarative(name, options = nil, &block)
- options ||= {}
- options = (options || {}).merge(:name=>name, :base_dir=>Dir.pwd, :declarative=>false)
- Java.rjb { AntProject.new(options).tap { |project| yield project if block_given? } }
+ warn_deprecated "Use ant { ... } instead."
+ Buildr.ant name, options, &block
end
- # :call-seq:
- # executable(name, options?) => AntProject
- # executable(name, options?) { |AntProject| ... } => AntProject
- #
- # Returns an executable AntProject with the specified name. Ant tasks created in this project
- # are executed immediately.
- #
- # See #ant for more information about options and the block.
+ # *Deprecated* Use ant { ... } instead.
def executable(name, options = nil, &block)
- options ||= {}
- options = (options || {}).merge(:name=>name, :base_dir=>Dir.pwd, :declarative=>true)
- Java.rjb { AntProject.new(options).tap { |project| yield project if block_given? } }
+ warn_deprecated "Use ant { ... } instead."
+ Buildr.ant name, options, &block
end
+
end
# :call-seq:
- # ant(name, options?) => AntProject
- # ant(name, options?) { |AntProject| ... } => AntProject
+ # ant(name) { |AntProject| ... } => AntProject
#
- # Returns a new AntProject with the specified name. Ant tasks created in this project are
- # executed immediately.
+ # 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.
#
- # The options hash is passed to the Ant project definition, along with the current directory.
- # When used in a Buildr project, the Ant project will have the same base directory.
- # If you pass a block, yields to the block with the Ant project.
- #
# 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
def ant(name, options=nil, &block)
- Ant.executable(name, options, &block)
+ warn_deprecated "Options are ignored." if options
+ options = { :name=>name, :basedir=>Dir.pwd, :declarative=>true }
+ Java.rjb do
+ 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((Rake.application.options.trace && 4) || (verbose && 2) || 0)
+ yield project if block_given?
+ end
+ end
end
end
include Ant
+
+ task("help") do
+ puts
+ puts "Using Java #{Java.version}, Ant #{Ant::VERSION}."
+ end
end