Permalink
Please sign in to comment.
Browse files
Somewhat hacky modifications to allow RubyGems to install Maven artif…
…acts. Incorporates maven_gem into main repository for now.
- Loading branch information...
Showing
with
439 additions
and 73 deletions.
- +61 −52 lib/ruby/site_ruby/1.8/rubygems/remote_fetcher.rb
- +84 −21 lib/ruby/site_ruby/1.8/rubygems/spec_fetcher.rb
- +26 −0 lib/ruby/site_ruby/shared/maven_gem.rb
- +31 −0 lib/ruby/site_ruby/shared/maven_gem/pom_fetcher.rb
- +188 −0 lib/ruby/site_ruby/shared/maven_gem/pom_spec.rb
- +49 −0 lib/ruby/site_ruby/shared/maven_gem/xml_utils.rb
@@ -0,0 +1,26 @@ | ||
+$:.unshift(File.dirname(__FILE__)) unless | ||
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) | ||
+ | ||
+require 'maven_gem/xml_utils' | ||
+require 'maven_gem/pom_spec' | ||
+require 'maven_gem/pom_fetcher' | ||
+require 'rubygems' | ||
+require 'rubygems/gem_runner' | ||
+ | ||
+module MavenGem | ||
+ def self.install(group, artifact = nil, version = nil) | ||
+ gem = build(group, artifact, version) | ||
+ Gem::GemRunner.new.run(["install", gem]) | ||
+ ensure | ||
+ FileUtils.rm_f(gem) if gem | ||
+ end | ||
+ | ||
+ def self.build(group, artifact = nil, version = nil) | ||
+ gem = if artifact | ||
+ url = MavenGem::PomSpec.to_maven_url(group, artifact, version) | ||
+ MavenGem::PomSpec.build(url) | ||
+ else | ||
+ MavenGem::PomSpec.build(group) | ||
+ end | ||
+ end | ||
+end |
@@ -0,0 +1,31 @@ | ||
+require 'net/http' | ||
+require 'uri' | ||
+ | ||
+module MavenGem | ||
+ class PomFetcher | ||
+ | ||
+ def self.fetch(path, options = {}) | ||
+ puts "Reading POM from #{path}" if options[:verbose] | ||
+ | ||
+ fetch_pom(path, options) | ||
+ end | ||
+ | ||
+ def self.clean_pom(pom) #avoid namespaces errors and gotchas | ||
+ pom.gsub(/<project[^>]+/, '<project>') | ||
+ end | ||
+ | ||
+ def self.fetch_pom(path, options = {}) | ||
+ path =~ /^http:\/\// ? fetch_from_url(path, options) : | ||
+ fetch_from_file(path, options) | ||
+ end | ||
+ | ||
+ private | ||
+ def self.fetch_from_url(path, options = {}) | ||
+ Net::HTTP.get(URI.parse(path)) | ||
+ end | ||
+ | ||
+ def self.fetch_from_file(path, options = {}) | ||
+ File.read(path) | ||
+ end | ||
+ end | ||
+end |

Oops, something went wrong.
0 comments on commit
eeda764