Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't install non-default gems to stdlib #4083

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 0 additions & 8 deletions .gitignore
Expand Up @@ -48,27 +48,19 @@ lib/native
lib/ruby/cext/
lib/ruby/gems
lib/ruby/stdlib/*.jar
lib/ruby/stdlib/did_you_mean*
lib/ruby/stdlib/gauntlet_rdoc.rb
lib/ruby/stdlib/jar*
lib/ruby/stdlib/jline
lib/ruby/stdlib/jopenssl*
lib/ruby/stdlib/krypt*
lib/ruby/stdlib/net-telnet.rb
lib/ruby/stdlib/net/telnet*
lib/ruby/stdlib/openssl*
lib/ruby/stdlib/org/
lib/ruby/stdlib/ripper.jar
lib/ruby/stdlib/rubygems/defaults/jruby_native.rb
lib/ruby/stdlib/racc*
lib/ruby/stdlib/rake*
lib/ruby/stdlib/json*
lib/ruby/stdlib/rdoc*
lib/ruby/stdlib/test*
lib/ruby/stdlib/hoe*
lib/ruby/stdlib/readline*
lib/ruby/stdlib/minitest*
lib/ruby/stdlib/power_assert*
lib/ruby/stdlib/psych*
release.properties
share
Expand Down
103 changes: 59 additions & 44 deletions lib/pom.rb
Expand Up @@ -5,7 +5,7 @@ class Gem::Installer
def say(message)
if message != spec.post_install_message || !MORE_QUIET
super
end
end
end
end
end
Expand All @@ -28,17 +28,17 @@ def initialize( name, version, default_spec = true )
[
ImportedGem.new( 'jruby-openssl', '0.9.17' ),
ImportedGem.new( 'jruby-readline', '1.1.dev-SNAPSHOT', false ),
ImportedGem.new( 'rake', '${rake.version}' ),
ImportedGem.new( 'rake', '${rake.version}', false ),
ImportedGem.new( 'rdoc', '${rdoc.version}' ),
ImportedGem.new( 'minitest', '${minitest.version}' ),
ImportedGem.new( 'test-unit', '${test-unit.version}' ),
ImportedGem.new( 'power_assert', '${power_assert.version}' ),
ImportedGem.new( 'minitest', '${minitest.version}', false ),
ImportedGem.new( 'test-unit', '${test-unit.version}', false ),
ImportedGem.new( 'power_assert', '${power_assert.version}', false ),
ImportedGem.new( 'psych', '2.0.17' ),
ImportedGem.new( 'json', '${json.version}' ),
ImportedGem.new( 'jar-dependencies', '${jar-dependencies.version}' ),
ImportedGem.new( 'racc', '${racc.version}'),
ImportedGem.new( 'net-telnet', '0.1.1'),
ImportedGem.new( 'did_you_mean', '1.0.1'),
ImportedGem.new( 'net-telnet', '0.1.1', false),
ImportedGem.new( 'did_you_mean', '1.0.1', false),
]

project 'JRuby Lib Setup' do
Expand Down Expand Up @@ -154,49 +154,48 @@ def installer.ensure_required_ruby_version_met; end
pom_version = ctx.project.properties.get( g.version[2..-2] ) || g.version
version = pom_version.sub( /-SNAPSHOT/, '' )

# install the gem unless already installed
if Dir[ File.join( default_specs, "#{g.name}-#{version}*.gemspec" ) ].empty?

log
log "--- gem #{g.name}-#{version} ---"
if g.default_spec
# install the gem unless already installed
if Dir[ File.join( default_specs, "#{g.name}-#{version}*.gemspec" ) ].empty?

# copy the gem content to stdlib
log
log "--- gem #{g.name}-#{version} ---"

log "copy gem content to #{stdlib_dir}"
# assume default require_path
require_base = File.join( gems, "#{g.name}-#{version}*", 'lib' )
require_files = File.join( require_base, '*' )
# copy the gem content to stdlib
log "copy gem content to #{stdlib_dir}"
# assume default require_path
require_base = File.join( gems, "#{g.name}-#{version}*", 'lib' )
require_files = File.join( require_base, '*' )

# copy in new ones and mark writable for future updates (e.g. minitest)
stdlib_locs = Dir[ require_files ].map do |f|
log " copying: #{f} to #{stdlib_dir}" if $VERBOSE
FileUtils.cp_r( f, stdlib_dir )
# copy in new ones and mark writable for future updates (e.g. minitest)
stdlib_locs = Dir[ require_files ].map do |f|
log " copying: #{f} to #{stdlib_dir}" if $VERBOSE
FileUtils.cp_r( f, stdlib_dir )

stdlib_loc = f.sub( File.dirname(f), stdlib_dir )
File.directory?(stdlib_loc) ? Dir[stdlib_loc + "/*"].to_a : stdlib_loc
end
stdlib_locs.flatten!

# fix permissions on copied files
stdlib_locs.each do |f|
next if File.writable? f
log " fixing permissions: #{f}" if $VERBOSE
# TODO: better way to just set it writable without changing all modes?
FileUtils.chmod_R(0644, f)
end
stdlib_loc = f.sub( File.dirname(f), stdlib_dir )
File.directory?(stdlib_loc) ? Dir[stdlib_loc + "/*"].to_a : stdlib_loc
end
stdlib_locs.flatten!

# fix permissions on copied files
stdlib_locs.each do |f|
next if File.writable? f
log " fixing permissions: #{f}" if $VERBOSE
# TODO: better way to just set it writable without changing all modes?
FileUtils.chmod_R(0644, f)
end

# copy bin files if the gem has any
bin = File.join( gems, "#{g.name}-#{version}", 'bin' )
if File.exists? bin
Dir[ File.join( bin, '*' ) ].each do |f|
log "copy to bin: #{File.basename( f )}"
target = File.join( bin_stubs, f.sub( /#{gems}/, '' ) )
FileUtils.mkdir_p( File.dirname( target ) )
FileUtils.cp_r( f, target )
# copy bin files if the gem has any
bin = File.join( gems, "#{g.name}-#{version}", 'bin' )
if File.exists? bin
Dir[ File.join( bin, '*' ) ].each do |f|
log "copy to bin: #{File.basename( f )}"
target = File.join( bin_stubs, f.sub( /#{gems}/, '' ) )
FileUtils.mkdir_p( File.dirname( target ) )
FileUtils.cp_r( f, target )
end
end
end

if g.default_spec
specfile_wildcard = "#{g.name}-#{version}*.gemspec"
specfile = Dir[ File.join( specs, specfile_wildcard ) ].first

Expand All @@ -212,6 +211,22 @@ def installer.ensure_required_ruby_version_met; end
f.print( spec.to_ruby )
end
end
else
gem_path = ctx.project.artifacts.find { |a| a.artifact_id == g.name }.file.to_pathname
if Dir[ File.join( jruby_gems, 'cache', File.basename( gem_path ).sub( /.gem/, '*.gem' ) ) ].empty?
log
log "--- gem #{g.name}-#{version} ---"
log "install non-default gem: #{g.name}"
log gem_path if $VERBOSE

installer = Gem::Installer.new( gem_path,
:wrappers => true,
:ignore_dependencies => true,
:install_dir => jruby_gems )
def installer.ensure_required_ruby_version_met; end
installer.install
installer.write_spec
end
end
end

Expand Down Expand Up @@ -287,7 +302,7 @@ def installer.ensure_required_ruby_version_met; end

resource do
directory '${gem.home}'
includes 'gems/rake-${rake.version}/bin/r*', 'gems/rdoc-${rdoc.version}/bin/r*', 'specifications/default/*.gemspec'
includes 'gems/**', 'specifications/*.gemspec', 'specifications/default/*.gemspec'
target_path '${jruby.complete.gems}'
end

Expand Down
4 changes: 2 additions & 2 deletions lib/pom.xml
Expand Up @@ -220,8 +220,8 @@ DO NOT MODIFIY - GENERATED CODE
<targetPath>${jruby.complete.gems}</targetPath>
<directory>${gem.home}</directory>
<includes>
<include>gems/rake-${rake.version}/bin/r*</include>
<include>gems/rdoc-${rdoc.version}/bin/r*</include>
<include>gems/**</include>
<include>specifications/*.gemspec</include>
<include>specifications/default/*.gemspec</include>
</includes>
</resource>
Expand Down
6 changes: 3 additions & 3 deletions pom.rb
Expand Up @@ -71,9 +71,9 @@
'rspec-expectations.version' => '3.4.0',
'rspec-mocks.version' => '3.4.1',
'rspec-support.version' => '3.4.1',
'minitest.version' => '5.4.1',
'test-unit.version' => '3.1.1',
'power_assert.version' => '0.2.3',
'minitest.version' => '5.8.3',
'test-unit.version' => '3.1.5',
'power_assert.version' => '0.2.6',
'diff-lcs.version' => '1.1.3',
'racc.version' => '1.4.14',
# versions for default gems with bin executables
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Expand Up @@ -109,7 +109,7 @@ DO NOT MODIFIY - GENERATED CODE
<racc.version>1.4.14</racc.version>
<its.j2ee>j2ee*/pom.xml</its.j2ee>
<jruby.basedir>${project.basedir}</jruby.basedir>
<minitest.version>5.4.1</minitest.version>
<minitest.version>5.8.3</minitest.version>
<ant.version>1.9.2</ant.version>
<diff-lcs.version>1.1.3</diff-lcs.version>
<jffi.version>1.2.12</jffi.version>
Expand All @@ -120,7 +120,7 @@ DO NOT MODIFIY - GENERATED CODE
<rspec-expectations.version>3.4.0</rspec-expectations.version>
<its.osgi>osgi*/pom.xml</its.osgi>
<base.javac.version>1.7</base.javac.version>
<test-unit.version>3.1.1</test-unit.version>
<test-unit.version>3.1.5</test-unit.version>
<rdoc.version>4.2.0</rdoc.version>
<rspec.version>3.4.0</rspec.version>
<base.java.version>1.7</base.java.version>
Expand All @@ -129,7 +129,7 @@ DO NOT MODIFIY - GENERATED CODE
<invoker.skip>true</invoker.skip>
<json.version>1.8.3</json.version>
<jar-dependencies.version>0.3.5</jar-dependencies.version>
<power_assert.version>0.2.3</power_assert.version>
<power_assert.version>0.2.6</power_assert.version>
<version.jruby>${project.version}</version.jruby>
<bouncy-castle.version>1.47</bouncy-castle.version>
<main.basedir>${project.basedir}</main.basedir>
Expand Down