Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6ceb5374cffa
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: bef5abfc2b4a
Choose a head ref
  • 2 commits
  • 10 files changed
  • 1 contributor

Commits on Jul 24, 2015

  1. added nested IsolatedScriptingContainer via jruby-mains test

    execute code inside a jar via jruby-mains, create an IsolatedSCriptingContainer
    which should inherit the environment from the jruby-mains, i.e. GEM_PATH, GEM_HOME,
    JARS_HOME, current working directory should all point inside the jars
    
    Sponsored by Lookout Inc.
    mkristian committed Jul 24, 2015
    Copy the full SHA
    e6632c0 View commit details
  2. get classloader root url right without an trailing slash

    OSGi url protocols do not like double // after the "host" part of the url.
    mkristian committed Jul 24, 2015
    Copy the full SHA
    bef5abf View commit details
Original file line number Diff line number Diff line change
@@ -124,7 +124,7 @@ protected void addLoadPath(String uri) {
}

public void addGemPath( ClassLoader cl ) {
addGemPath(new UriLikePathHelper(cl).getUriLikePath());
addGemPath(new UriLikePathHelper(cl).getUriLikePath("/specifications" + JRUBYDIR));
}

public void addGemPath( ClassLoader cl, String ref ) {
Original file line number Diff line number Diff line change
@@ -28,7 +28,6 @@
* the terms of any one of the EPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****/

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/util/UriLikePathHelper.java
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ public URL getResource(String ref) {
}

public String getUriLikePath() {
return createUri(".jrubydir");
return createUri("/.jrubydir");
}

public String getUriLikePath(String ref) {
11 changes: 7 additions & 4 deletions maven/jruby/src/it/runnable/Mavenfile
Original file line number Diff line number Diff line change
@@ -3,21 +3,21 @@
properties( 'tesla.dump.pom' => 'pom.xml',
'tesla.dump.readOnly' => true,
'jruby.version' => '@project.version@',
'jruby.plugins.version' => '1.0.8' )
'jruby.plugins.version' => '1.0.10' )

gemfile

gem 'bundler', '1.7.7'

pom 'org.jruby:jruby', '${jruby.version}'

jar 'de.saumya.mojo:jruby-mains', '0.2.0'
jar 'de.saumya.mojo:jruby-mains', '0.3.1'

build do
directory 'pkg'
end

files = [ '.rspec', 'config.ru', '*file', '*file.lock', '.jbundler/classpath.rb',
files = [ '.rspec', '*.rb', 'config.ru', '*file', '*file.lock', '.jbundler/classpath.rb',
'lib/**', 'app/**', 'config/**', 'vendor/**', 'spec/**' ]
jruby_plugin!( :gem,
# need a jruby-complete from maven central here
@@ -40,7 +40,7 @@ if File.file?('Jarfile.lock')
data = l.sub(/-\ /, '').strip.split(':')
if data.size > 3
data = Hash[ [:groupId, :artifactId, :type, :version, :classifier].zip( data ) ]
data[ :outputDirectory ] = File.join( '${project.build.outputDirectory}',
data[ :outputDirectory ] = File.join( '${project.build.outputDirectory}/jars',
data[:groupId].gsub(/[.]/, '/'),
data[:artifactId],
data[:version] )
@@ -81,6 +81,9 @@ phase :package do

execute_goal( :exec, :id => 'rspec',
:arguments => [ '-jar', 'runnable.jar', '-S', 'rspec' ] )

execute_goal( :exec, :id => 'nested IsolatedScriptingContainer',
:arguments => [ '-jar', 'runnable.jar', 'nested.rb' ] )

end
end
14 changes: 14 additions & 0 deletions maven/jruby/src/it/runnable/nested.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# TODO needs fix in jruby
#require_relative 'test'
require 'uri:classloader:/test'

# not use Singleton scope since in this case it would use the on global runtime
other = org.jruby.embed.IsolatedScriptingContainer.new(org.jruby.embed.LocalContextScope::THREADSAFE)

other.runScriptlet("$other = #{JRuby.runtime.object_id}")

# TODO needs fix in jruby
#other.runScriptlet( "require_relative 'test_other'" )
other.runScriptlet( "require 'uri:classloader:/test_other'" )

other.terminate
27 changes: 21 additions & 6 deletions maven/jruby/src/it/runnable/pom.xml
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
<properties>
<tesla.dump.readOnly>true</tesla.dump.readOnly>
<jruby.version>@project.version@</jruby.version>
<jruby.plugins.version>1.0.8</jruby.plugins.version>
<jruby.plugins.version>1.0.10</jruby.plugins.version>
<project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
<tesla.dump.pom>pom.xml</tesla.dump.pom>
</properties>
@@ -29,7 +29,7 @@
<dependency>
<groupId>de.saumya.mojo</groupId>
<artifactId>jruby-mains</artifactId>
<version>0.2.0</version>
<version>0.3.1</version>
</dependency>
</dependencies>
<repositories>
@@ -92,6 +92,7 @@
<includeBinStubs>true</includeBinStubs>
<includeRubyResources>
<includeRubyResource>.rspec</includeRubyResource>
<includeRubyResource>*.rb</includeRubyResource>
<includeRubyResource>config.ru</includeRubyResource>
<includeRubyResource>*file</includeRubyResource>
<includeRubyResource>*file.lock</includeRubyResource>
@@ -127,31 +128,31 @@
<type>jar</type>
<version>1.49</version>
<classifier />
<outputDirectory>${project.build.outputDirectory}/org/bouncycastle/bcpkix-jdk15on/1.49</outputDirectory>
<outputDirectory>${project.build.outputDirectory}/jars/org/bouncycastle/bcpkix-jdk15on/1.49</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<type>jar</type>
<version>1.6.4</version>
<classifier />
<outputDirectory>${project.build.outputDirectory}/org/slf4j/slf4j-simple/1.6.4</outputDirectory>
<outputDirectory>${project.build.outputDirectory}/jars/org/slf4j/slf4j-simple/1.6.4</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<type>jar</type>
<version>1.49</version>
<classifier />
<outputDirectory>${project.build.outputDirectory}/org/bouncycastle/bcprov-jdk15on/1.49</outputDirectory>
<outputDirectory>${project.build.outputDirectory}/jars/org/bouncycastle/bcprov-jdk15on/1.49</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<type>jar</type>
<version>1.6.4</version>
<classifier />
<outputDirectory>${project.build.outputDirectory}/org/slf4j/slf4j-api/1.6.4</outputDirectory>
<outputDirectory>${project.build.outputDirectory}/jars/org/slf4j/slf4j-api/1.6.4</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
@@ -233,6 +234,20 @@
</arguments>
</configuration>
</execution>
<execution>
<id>nested IsolatedScriptingContainer</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<arguments>
<argument>-jar</argument>
<argument>runnable.jar</argument>
<argument>nested.rb</argument>
</arguments>
</configuration>
</execution>
</executions>
<configuration>
<executable>java</executable>
2 changes: 1 addition & 1 deletion maven/jruby/src/it/runnable/spec/one_spec.rb
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
it "does something" do
expect(__FILE__).to eq 'uri:classloader:/spec/one_spec.rb'
expect($CLASSPATH.size).to eq 4
expect(Jars.home).to eq 'uri:classloader://'
expect(Jars.home).to eq 'uri:classloader://jars'
expect(Dir.pwd).to eq 'uri:classloader://'
$LOAD_PATH.each do |lp|
# bundler or someone else messes up the $LOAD_PATH
25 changes: 25 additions & 0 deletions maven/jruby/src/it/runnable/test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'minitest/autorun'

describe 'ENV' do

it 'has current directory inside classloader' do
Dir.pwd.must_equal 'uri:classloader://'
end

it 'has first entry LOAD_PATH' do
$LOAD_PATH.first.must_equal 'uri:classloader://'
end

it 'has GEM_HOME set' do
ENV['GEM_HOME'].must_equal 'uri:classloader://META-INF/jruby.home/lib/ruby/gems/shared'
end

it 'has GEM_PATH set' do
ENV['GEM_PATH'].must_equal 'uri:classloader://'
end

it 'has JARS_HOME set' do
ENV['JARS_HOME'].must_equal 'uri:classloader://jars'
end

end
29 changes: 29 additions & 0 deletions maven/jruby/src/it/runnable/test_other.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'minitest/autorun'

describe 'ENV' do

it 'has $other' do
$other.wont_equal JRuby.runtime.object_id
end

it 'has first entry LOAD_PATH' do
$LOAD_PATH.first.must_equal 'uri:classloader:/'
end

it 'has current directory inside classloader' do
Dir.pwd.must_equal 'uri:classloader:/'
end

it 'has GEM_HOME set' do
ENV['GEM_HOME'].must_equal 'uri:classloader:/'
end

it 'has GEM_PATH set' do
ENV['GEM_PATH'].must_equal 'uri:classloader:/'
end

it 'has JARS_HOME set' do
ENV['JARS_HOME'].must_equal 'uri:classloader:/jars'
end

end
14 changes: 13 additions & 1 deletion maven/jruby/src/it/runnable/verify.bsh
Original file line number Diff line number Diff line change
@@ -10,4 +10,16 @@ expected = "uri:classloader:/Rakefile []";
if ( !log.contains( expected ) ) throw new RuntimeException( "log file does not contain '" + expected + "'" );

expected = "uri:classloader:/Rakefile [\"spec\"]";
if ( !log.contains( expected ) ) throw new RuntimeException( "log file does not contain '" + expected + "'" );
if ( !log.contains( expected ) ) throw new RuntimeException( "log file does not contain '" + expected + "'" );

expected = "5 tests, 5 assertions, 0 failures, 0 errors, 0 skips";
if ( !log.contains( expected ) )
{
throw new RuntimeException( "log file does not contain '" + expected + "'" );
}

expected = "6 tests, 6 assertions, 0 failures, 0 errors, 0 skips";
if ( !log.contains( expected ) )
{
throw new RuntimeException( "log file does not contain '" + expected + "'" );
}