lib/java/packaging.rb in buildr-1.2.5 vs lib/java/packaging.rb in buildr-1.2.6
- old
+ new
@@ -168,14 +168,58 @@
@classes |= [value].flatten.map { |dir| file(dir.to_s) }
end
end
+ # Extends the JarTask to create an AAR file (Axis2 service archive).
+ #
+ # Supports all the same options as JarTask, with the addition of :wsdls, :services_xml and :libs.
+ #
+ # * :wsdls -- WSDL files to include (under META-INF). By default packaging will include all WSDL
+ # files found under src/main/axis2.
+ # * :services_xml -- Location of services.xml file (included under META-INF). By default packaging
+ # takes this from src/main/axis2/services.xml. Use a different path if you genereate the services.xml
+ # file as part of the build.
+ # * :libs -- Array of files, tasks, artifact specifications, etc that will be added to the /lib directory.
+ #
+ # For example:
+ # package(:aar).with(:libs=>"log4j:log4j:jar:1.1")
+ #
+ # filter.from("src/main/axis2").into("target").include("services.xml", "*.wsdl").using("http_port"=>"8080")
+ # package(:aar).wsdls.clear
+ # package(:aar).with(:services_xml=>_("target/services.xml"), :wsdls=>_("target/*.wsdl"))
+ class AarTask < JarTask
+ # Artifacts to include under /lib.
+ attr_accessor :libs
+ # WSDLs to include under META-INF (defaults to all WSDLs under src/main/axis2).
+ attr_accessor :wsdls
+ # Location of services.xml file (defaults to src/main/axis2/services.xml).
+ attr_accessor :services_xml
+
+ def initialize(*args) #:nodoc:
+ super
+ @libs = []
+ @wsdls = []
+ prepare do
+ path("META-INF").include @wsdls
+ path("META-INF").include @services_xml, :as=>["services.xml"] if @services_xml
+ path("lib").include Buildr.artifacts(@libs) unless @libs.nil? || @libs.empty?
+ end
+ end
+
+ def libs=(value) #:nodoc:
+ @libs = Buildr.artifacts(value)
+ end
+
+ def wsdls=(value) #:nodoc:
+ @wsdls |= Array(value)
+ end
+ end
+
end
end
-
Project.on_define do |project|
# Need to run buildr before package, since package is often used as a dependency by tasks that
# expect build to happen.
task "package"=>task("build")
end
@@ -362,10 +406,11 @@
if options[:include]
warn_deprecated "The :include option in package(:jar) is deprecated, please use package(:jar).include(files) instead."
jar.include options[:include]
else
jar.with compile.target unless compile.sources.empty?
+ jar.with resources.target unless resources.sources.empty?
end
end
else
rake_check_options options, *PACKAGE_OPTIONS
end
@@ -387,10 +432,11 @@
if options.has_key?(:classes)
warn_deprecated "The :classes option in package(:war) is deprecated, please use package(:war).with(:classes=>) instead."
war.with :classes=>options[:classes]
else
war.with :classes=>compile.target unless compile.sources.empty?
+ war.with :classes=>resources.target unless resources.sources.empty?
end
if options.has_key?(:libs)
warn_deprecated "The :libs option in package(:war) is deprecated, please use package(:war).with(:libs=>) instead."
war.with :libs=>options[:libs].collect
else
@@ -408,10 +454,25 @@
rake_check_options options, *PACKAGE_OPTIONS
end
file(file_name)
end
+ def package_as_aar(file_name, options) #:nodoc:
+ rake_check_options options, *PACKAGE_OPTIONS
+ unless Rake::Task.task_defined?(file_name)
+ Java::Packaging::AarTask.define_task(file_name).tap do |aar|
+ aar.with :manifest=>manifest, :meta_inf=>meta_inf
+ aar.with :wsdls=>path_to("src/main/axis2/*.wsdl")
+ aar.with :services_xml=>path_to("src/main/axis2/services.xml")
+ aar.with compile.target unless compile.sources.empty?
+ aar.with resources.target unless resources.sources.empty?
+ aar.with :libs=>compile.classpath
+ end
+ end
+ file(file_name)
+ end
+
def package_as_zip(file_name, options) #:nodoc:
unless Rake::Task.task_defined?(file_name)
rake_check_options options, *PACKAGE_OPTIONS + [:include]
ZipTask.define_task(file_name).tap do |zip|
if options[:include]
@@ -424,21 +485,16 @@
end
file(file_name)
end
def package_as_tar(file_name, options) #:nodoc:
+ rake_check_options options, *PACKAGE_OPTIONS
unless Rake::Task.task_defined?(file_name)
- TarballTask.define_task(file_name)
+ TarTask.define_task(file_name)
end
file(file_name)
end
-
- def package_as_tgz(file_name, options) #:nodoc:
- unless Rake::Task.task_defined?(file_name)
- TarballTask.define_task(file_name)
- end
- file(file_name)
- end
+ alias :package_as_tgz :package_as_tar
def package_as_sources(file_name, options) #:nodoc:
rake_check_options options, *PACKAGE_OPTIONS
options.merge!(:type=>:zip, :classifier=>"sources")
file_name = path_to(:target, Artifact.hash_to_file_name(options))