From f5ee4a18a8f63ebf41f1733566831f6f6e41398c Mon Sep 17 00:00:00 2001 From: David Calavera Date: Wed, 24 Mar 2010 01:07:42 +0100 Subject: [PATCH] it gets the version from the parent if it doesnt exit --- lib/maven_gem/pom_spec.rb | 2 +- maven_gem.gemspec | 51 --------------------------------- spec/maven_gem/pom_spec_spec.rb | 8 ++++++ 3 files changed, 9 insertions(+), 52 deletions(-) delete mode 100644 maven_gem.gemspec diff --git a/lib/maven_gem/pom_spec.rb b/lib/maven_gem/pom_spec.rb index 992fa1d..f8d8bd5 100644 --- a/lib/maven_gem/pom_spec.rb +++ b/lib/maven_gem/pom_spec.rb @@ -65,7 +65,7 @@ def self.parse_pom(pom_doc, options = {}) pom.group = xpath_group(document) pom.artifact = xpath_text(document, '/project/artifactId') - pom.maven_version = xpath_text(document, '/project/version') + pom.maven_version = xpath_text(document, '/project/version') || xpath_text(document, '/project/parent/version') pom.version = maven_to_gem_version(pom.maven_version) pom.description = xpath_text(document, '/project/description') pom.url = xpath_text(document, '/project/url') diff --git a/maven_gem.gemspec b/maven_gem.gemspec deleted file mode 100644 index 148e587..0000000 --- a/maven_gem.gemspec +++ /dev/null @@ -1,51 +0,0 @@ -# Generated by jeweler -# DO NOT EDIT THIS FILE DIRECTLY -# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command -# -*- encoding: utf-8 -*- - -Gem::Specification.new do |s| - s.name = %q{maven_gem} - s.version = "0.0.3" - - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Charles Nutter", "David Calavera"] - s.date = %q{2009-12-19} - s.default_executable = %q{maven_gem} - s.description = %q{MavenGem is a command and RubyGems plugin for packaging Maven artifacts as gems.} - s.email = %q{headius@headius.com} - s.executables = ["maven_gem"] - s.files = [ - "History.txt", - "Rakefile", - "VERSION", - "bin/maven_gem", - "lib/maven_gem.rb", - "lib/maven_gem/pom_fetcher.rb", - "lib/maven_gem/pom_spec.rb", - "lib/maven_gem/xml_utils.rb", - "lib/rubygems/commands/maven_command.rb", - "lib/rubygems_plugin.rb" - ] - s.homepage = %q{http://github.com/jruby/maven_gem} - s.rdoc_options = ["--charset=UTF-8"] - s.require_paths = ["lib"] - s.rubygems_version = %q{1.3.5} - s.summary = %q{Packaging Maven artifacts as Rubygems.} - - if s.respond_to? :specification_version then - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION - s.specification_version = 3 - - if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then - s.add_development_dependency(%q, [">= 0"]) - s.add_development_dependency(%q, [">= 0"]) - else - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - end - else - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - end -end - diff --git a/spec/maven_gem/pom_spec_spec.rb b/spec/maven_gem/pom_spec_spec.rb index adb3171..912657b 100644 --- a/spec/maven_gem/pom_spec_spec.rb +++ b/spec/maven_gem/pom_spec_spec.rb @@ -111,6 +111,14 @@ pom.jar_file.should == 'ant-1.6.6-SNAPSHOT.jar' pom.gem_file.should == 'ant.ant-1.6.6-java.gem' end + + it "uses the version from the parent when its version doesn't exit" do + pom = MavenGem::PomFetcher.fetch(File.join(FIXTURES, 'hudson-rake.pom')) + pom_without_version = pom.gsub(/1.7-SNAPSHOT<\/version>/, '') + + pom_spec = MavenGem::PomSpec.parse_pom(pom_without_version) + pom_spec.version.should == '1.319' + end end describe "generate_spec" do