Skip to content

Commit

Permalink
move maven/jruby-stdlib/ into lib/
Browse files Browse the repository at this point in the history
  • Loading branch information
mkristian committed Mar 17, 2015
1 parent 76d4914 commit 42f65bc
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 255 deletions.
88 changes: 78 additions & 10 deletions lib/pom.rb
Expand Up @@ -54,14 +54,18 @@ def to_pathname
version = File.read( File.join( basedir, '..', 'VERSION' ) ).strip

model_version '4.0.0'
id 'jruby-lib'
id 'jruby-stdlib'
inherit "org.jruby:jruby-parent", version
packaging 'pom'

properties( 'tesla.dump.pom' => 'pom.xml',
'tesla.dump.readonly' => true,
'tesla.version' => '0.1.1',
'jruby.plugins.version' => '1.0.5' )
'jruby.plugins.version' => '1.0.5',
'gem.home' => '${basedir}/ruby/gems/shared',
# we copy everything into the target/classes/META-INF
# so the jar plugin just packs it - see build/resources below
'jruby.complete.home' => '${project.build.outputDirectory}/META-INF/jruby.home',
'jruby.complete.gems' => '${jruby.complete.home}/lib/ruby/gems/shared' )

unless version =~ /-SNAPSHOT/
properties 'jruby.home' => '${basedir}/..'
Expand All @@ -86,18 +90,13 @@ def to_pathname
end
end

# this is not an artifact for maven central
plugin :deploy, :skip => true

plugin :invoker, :skipInstallation => true

gem 'ruby-maven', '3.1.1.0.8', :scope => :provided

plugin :dependency, :useRepositoryLayout => true, :outputDirectory => 'ruby/stdlib', :excludeGroupIds => 'rubygems', :includeScope => :runtime do
execute_goal 'copy-dependencies', :phase => 'package'
end

execute :install_gems, :'package' do |ctx|
execute :install_gems, :'initialize' do |ctx|
require 'fileutils'

puts "using jruby #{JRUBY_VERSION}"
Expand Down Expand Up @@ -233,5 +232,74 @@ def to_pathname
( Dir[ File.join( jruby_gems, '**/*' ) ] + Dir[ File.join( jruby_gems, '**/.*' ) ] ).each do |f|
File.chmod( 0644, f ) rescue nil if File.file?( f )
end
end
end

execute( 'fix shebang on gem bin files and add *.bat files',
'prepare-resources' ) do |ctx|

puts 'fix the gem stub files'
jruby_home = ctx.project.basedir.to_pathname + '/../'
bindir = File.join( jruby_home, 'lib', 'ruby', 'gems', 'shared', 'bin' )
Dir[ File.join( bindir, '*' ) ].each do |f|
content = File.read( f )
new_content = content.sub( /#!.*/, "#!/usr/bin/env jruby
" )
File.open( f, "w" ) { |file| file.print( new_content ) }
end

puts 'generate the missing bat files'
Dir[File.join( jruby_home, 'bin', '*' )].each do |fn|
next unless File.file?(fn)
next if fn =~ /.bat$/
next if File.exist?("#{fn}.bat")
next unless File.open(fn, 'r', :internal_encoding => 'ASCII-8BIT') do |io|
line = io.readline rescue ""
line =~ /^#!.*ruby/
end
puts "Generating #{File.basename(fn)}.bat"
File.open("#{fn}.bat", "wb") do |f|
f.print "@ECHO OFF\r\n"
f.print "@\"%~dp0jruby.exe\" -S #{File.basename(fn)} %*\r\n"
end
end
end

execute( 'copy bin/jruby.bash to bin/jruby',
'process-resources' ) do |ctx|
require 'fileutils'
jruby_complete = ctx.project.properties.get_property( 'jruby.complete.home' )
FileUtils.cp( File.join( jruby_complete, 'bin', 'jruby.bash' ),
File.join( jruby_complete, 'bin', 'jruby' ) )
end

execute 'jrubydir', 'prepare-package' do |ctx|
require( ctx.project.basedir.to_pathname + '/../core/src/main/ruby/jruby/commands.rb' )
JRuby::Commands.generate_dir_info( ctx.project.build.output_directory.to_pathname + '/META-INF/jruby.home' )
end

# we have no sources and attach an empty jar later in the build to
# satisfy oss.sonatype.org upload

plugin( :source, 'skipSource' => 'true' )

# this plugin is configured to attach empty jars for sources and javadocs
plugin( 'org.codehaus.mojo:build-helper-maven-plugin' )

build do

# both resources are includes for the $jruby_home/lib directory

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

resource do
directory '${basedir}/..'
includes 'bin/ast*', 'bin/gem*', 'bin/irb*', 'bin/jgem*', 'bin/jirb*', 'bin/jruby*', 'bin/rake*', 'bin/ri*', 'bin/rdoc*', 'bin/testrb*', 'lib/ruby/stdlib/**', 'lib/ruby/truffle/**'
excludes 'bin/jruby', 'bin/jruby*_*', 'bin/jruby*-*', '**/.*', 'lib/ruby/stdlib/rubygems/defaults/jruby_native.rb'
target_path '${jruby.complete.home}'
end
end
end
87 changes: 84 additions & 3 deletions lib/pom.xml
Expand Up @@ -7,13 +7,15 @@
<artifactId>jruby-parent</artifactId>
<version>9.0.0.0-SNAPSHOT</version>
</parent>
<artifactId>jruby-lib</artifactId>
<packaging>pom</packaging>
<artifactId>jruby-stdlib</artifactId>
<name>JRuby Lib Setup</name>
<properties>
<tesla.dump.readonly>true</tesla.dump.readonly>
<jruby.complete.gems>${jruby.complete.home}/lib/ruby/gems/shared</jruby.complete.gems>
<gem.home>${basedir}/ruby/gems/shared</gem.home>
<jruby.plugins.version>1.0.5</jruby.plugins.version>
<tesla.dump.pom>pom.xml</tesla.dump.pom>
<jruby.complete.home>${project.build.outputDirectory}/META-INF/jruby.home</jruby.complete.home>
<tesla.version>0.1.1</tesla.version>
</properties>
<dependencies>
Expand Down Expand Up @@ -158,6 +160,42 @@
</repository>
</repositories>
<build>
<resources>
<resource>
<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>specifications/default/*.gemspec</include>
</includes>
</resource>
<resource>
<targetPath>${jruby.complete.home}</targetPath>
<directory>${basedir}/..</directory>
<includes>
<include>bin/ast*</include>
<include>bin/gem*</include>
<include>bin/irb*</include>
<include>bin/jgem*</include>
<include>bin/jirb*</include>
<include>bin/jruby*</include>
<include>bin/rake*</include>
<include>bin/ri*</include>
<include>bin/rdoc*</include>
<include>bin/testrb*</include>
<include>lib/ruby/stdlib/**</include>
<include>lib/ruby/truffle/**</include>
</includes>
<excludes>
<exclude>bin/jruby</exclude>
<exclude>bin/jruby*_*</exclude>
<exclude>bin/jruby*-*</exclude>
<exclude>**/.*</exclude>
<exclude>lib/ruby/stdlib/rubygems/defaults/jruby_native.rb</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
Expand Down Expand Up @@ -207,14 +245,24 @@
<includeScope>runtime</includeScope>
</configuration>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<configuration>
<skipSource>true</skipSource>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>io.tesla.polyglot</groupId>
<artifactId>tesla-polyglot-maven-plugin</artifactId>
<version>${tesla.version}</version>
<executions>
<execution>
<id>install_gems</id>
<phase>package</phase>
<phase>initialize</phase>
<goals>
<goal>execute</goal>
</goals>
Expand All @@ -223,6 +271,39 @@
<nativePom>pom.rb</nativePom>
</configuration>
</execution>
<execution>
<id>fix shebang on gem bin files and add *.bat files</id>
<phase>prepare-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<taskId>fix shebang on gem bin files and add *.bat files</taskId>
<nativePom>pom.rb</nativePom>
</configuration>
</execution>
<execution>
<id>copy bin/jruby.bash to bin/jruby</id>
<phase>process-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<taskId>copy bin/jruby.bash to bin/jruby</taskId>
<nativePom>pom.rb</nativePom>
</configuration>
</execution>
<execution>
<id>jrubydir</id>
<phase>prepare-package</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<taskId>jrubydir</taskId>
<nativePom>pom.rb</nativePom>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
Expand Down
File renamed without changes.
101 changes: 0 additions & 101 deletions maven/jruby-stdlib/pom.rb

This file was deleted.

0 comments on commit 42f65bc

Please sign in to comment.