lib/maven/tools/gem_project.rb in maven-tools-0.32.0 vs lib/maven/tools/gem_project.rb in maven-tools-0.32.1
- old
+ new
@@ -1,5 +1,25 @@
+#
+# Copyright (C) 2013 Christian Meier
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy of
+# this software and associated documentation files (the "Software"), to deal in
+# the Software without restriction, including without limitation the rights to
+# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+# the Software, and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all
+# copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
# TODO make nice require after ruby-maven uses the same ruby files
require File.join(File.dirname(File.dirname(__FILE__)), 'model', 'model.rb')
require File.join(File.dirname(__FILE__), 'gemfile_lock.rb')
require File.join(File.dirname(__FILE__), 'versions.rb')
require File.join(File.dirname(__FILE__), 'jarfile.rb')
@@ -123,11 +143,18 @@
versions = dep.requirement.requirements.collect do |req|
# use this construct to get the same result in 1.8.x and 1.9.x
req.collect{ |i| i.to_s }.join
end
- gem(dep.name, versions).scope = scope
+ add_gem(dep.name, versions).scope = scope
+ if @lock
+ # add its dependencies as well to have the version
+ # determine by the dependencyManagement
+ @lock.dependency_hull(dep.name).map.each do |d|
+ add_gem(d[0], d[1]).scope = scope unless gem? d[0]
+ end
+ end
end
spec.requirements.each do |req|
begin
eval req
@@ -173,10 +200,19 @@
end
eval content
# we have a Gemfile so we add the bundler plugin
plugin(:bundler)
+
+ # cleanup versions from deps
+ if @lock
+ dependencies.each do |d|
+ if d.group_id == 'rubygems' && @lock.keys.member?( d.artifact_id )
+ d.version = nil
+ end
+ end
+ end
else
self
end
end
@@ -278,11 +314,11 @@
if plugin?(:bundler)
bundler = plugin(:bundler)
bundler.version = "${jruby.plugins.version}" unless bundler.version
unless gem?(:bundler)
- gem("bundler")
+ gem("bundler").scope :test
end
end
if gem?('bundler') && !gem('bundler').version?
gem('bundler').version = nil
@@ -504,6 +540,6 @@
proj.load(ARGV[0] || 'Gemfile')
end
proj.load(ARGV[1] || 'Mavenfile')
proj.add_defaults
puts proj.to_xml
-end
+end
\ No newline at end of file