lib/java/packaging.rb in buildr-0.21.0 vs lib/java/packaging.rb in buildr-0.22.0

- old
+ new

@@ -104,11 +104,11 @@ class WarTask < JarTask def []=(key, value) #:nodoc: case key.to_sym when :libs - self.include artifacts(value), :path=>"WEB-INF/lib" + self.include Buildr.artifacts(value), :path=>"WEB-INF/lib" when :classes self.include value, :path=>"WEB-INF/classes", :as=>"." else super key, value end @@ -239,21 +239,26 @@ fail("Don't know how to create a package of type #{type}") packager.call(file_name, options) do |package| # Make it an artifact using the specifications, and tell it how to create a POM. package.extend ActsAsArtifact package.send :apply_spec, options - package.pom.enhance do |pom| + # Another task to create the POM file. + pom_spec = package.to_spec_hash.merge(:type=>:pom) + pom = file(Buildr.repositories.locate(pom_spec)) + pom.extend ActsAsArtifact + pom.send :apply_spec, pom_spec + pom.enhance do mkpath File.dirname(pom.name), :verbose=>false File.open(pom.name, "w") do |file| xml = Builder::XmlMarkup.new(:target=>file, :indent=>2) xml.instruct! xml.project do xml.modelVersion "4.0.0" - xml.groupId options[:group] - xml.artifactId options[:id] - xml.version options[:version] - xml.classifier options[:classifier] if options[:classifier] + xml.groupId pom.group + xml.artifactId pom.id + xml.version pom.version + xml.classifier pom.classifier if pom.classifier end end end # Make sure the package task creates it, and it invokes the build task first. @@ -262,30 +267,30 @@ # Install the artifact along with its POM. Since the artifact (package task) is created # in the target directory, we need to copy it into the local repository. However, the # POM artifact (created by calling artifact on its spec) is already mapped to its right # place in the local repository, so we only need to invoke it. - installed = file(repositories.locate(package)=>package) { |task| + installed = file(Buildr.repositories.locate(package)=>package) { |task| verbose(Rake.application.options.trace || false) do mkpath File.dirname(task.name), :verbose=>false cp package.name, task.name end puts "Installed #{task.name}" if verbose } - task "install"=>[installed, package.pom] + task "install"=>[installed, pom] task "uninstall" do |task| verbose(Rake.application.options.trace || false) do - [ installed, package.pom ].map(&:to_s).each { |file| rm file if File.exist?(file) } + [ installed, pom ].map(&:to_s).each { |file| rm file if File.exist?(file) } end end - task("deploy") { deploy(package, package.pom) } + task("deploy") { deploy(package, pom) } # Add the package to the list of packages created by this project, and # register it as an artifact. The later is required so if we look up the spec # we find the package in the project's target directory, instead of finding it # in the local repository and attempting to install it. packages << package - Artifact.register package, package.pom + Artifact.register package, pom end end # :call-seq: # packages() => tasks