@@ -82,6 +82,36 @@ namespace "artifact" do
8282 res
8383 end
8484
85+ def duplicated_gems_exclude_paths
86+ shared_gems_path = 'vendor/jruby/lib/ruby/gems/shared/gems'
87+ bundle_gems_path = 'vendor/bundle/jruby/*/gems'
88+
89+ exclusions = [ ]
90+ shared_gem_names = Dir . glob ( File . join ( shared_gems_path , '*' ) ) . map do |path |
91+ match = File . basename ( path ) . match ( /^(.+?)-\d +/ )
92+ match ? match [ 1 ] : nil
93+ end . compact
94+
95+ bundle_gem_names = Dir . glob ( File . join ( bundle_gems_path , '*' ) ) . map do |path |
96+ match = File . basename ( path ) . match ( /^(.+?)-\d +/ )
97+ match ? match [ 1 ] : nil
98+ end . compact
99+
100+ duplicates = shared_gem_names & bundle_gem_names
101+ puts "Adding duplicate gems to exclude path: #{ duplicates . sort . join ( ', ' ) } "
102+
103+ duplicates . each do |gem_name |
104+ # remove contents as well as top level directory of bundled gems
105+ gem_content_path = "vendor/jruby/lib/ruby/gems/shared/gems/#{ gem_name } -*/**/*"
106+ gem_path = "vendor/jruby/lib/ruby/gems/shared/gems/#{ gem_name } -*"
107+ spec_path = "vendor/jruby/lib/ruby/gems/shared/specifications/#{ gem_name } -*.gemspec"
108+ exclusions << gem_content_path
109+ exclusions << gem_path
110+ exclusions << spec_path
111+ end
112+ exclusions
113+ end
114+
85115 def default_exclude_paths
86116 return @exclude_paths if @exclude_paths
87117
@@ -101,18 +131,8 @@ namespace "artifact" do
101131 @exclude_paths << 'vendor/**/gems/**/Gemfile.lock'
102132 @exclude_paths << 'vendor/**/gems/**/Gemfile'
103133
104- @exclude_paths << 'vendor/jruby/lib/ruby/gems/shared/gems/rake-*'
105- # exclude ruby-maven-libs 3.3.9 jars until JRuby ships with >= 3.8.9
106- @exclude_paths << 'vendor/bundle/jruby/**/gems/ruby-maven-libs-3.3.9/**/*'
107-
108- # remove this after JRuby includes rexml 3.3.x
109- @exclude_paths << 'vendor/jruby/lib/ruby/gems/shared/gems/rexml-3.2.5/**/*'
110- @exclude_paths << 'vendor/jruby/lib/ruby/gems/shared/specifications/rexml-3.2.5.gemspec'
111-
112- # remove this after JRuby includes net-imap-0.2.4+
113- @exclude_paths << 'vendor/jruby/lib/ruby/gems/shared/specifications/net-imap-0.2.3.gemspec'
114- @exclude_paths << 'vendor/jruby/lib/ruby/gems/shared/gems/net-imap-0.2.3/**/*'
115-
134+ @exclude_paths . concat ( duplicated_gems_exclude_paths )
135+ puts "Full exclude_paths list: #{ @exclude_paths } "
116136 @exclude_paths . freeze
117137 end
118138
0 commit comments