Skip to content

Commit

Permalink
fixes commandline execution of internal java -cp ... org.jruby.Main c…
Browse files Browse the repository at this point in the history
…ommand

it is a regression from 1.7.21 since gems with native extensions (thrift-0.9.2.0)
can not be installed with jruby-complete anymore. this patch treats the command
as series of arguments in case of the internal "jruby" command gets executed.

Sponsored by Lookout Inc.
mkristian committed Jul 24, 2015
1 parent bef5abf commit 917d0e7
Showing 2 changed files with 144 additions and 118 deletions.
5 changes: 5 additions & 0 deletions core/src/main/java/org/jruby/util/ShellLauncher.java
Original file line number Diff line number Diff line change
@@ -1178,6 +1178,11 @@ public void verifyExecutableForShell() {
execArgs[0] = shell;
execArgs[1] = shell.endsWith("sh") ? "-c" : "/c";

// HACK to get the builtin command right
if (cmdline.startsWith("\"java -cp") && cmdline.contains("org.jruby.Main\"")) {
cmdline = cmdline.replace("\"java -cp", "java -cp")
.replace("org.jruby.Main\"", "org.jruby.Main");
}
if (Platform.IS_WINDOWS) {
// that's how MRI does it too
execArgs[2] = "\"" + cmdline + "\"";
257 changes: 139 additions & 118 deletions maven/jruby-complete/src/it/integrity/pom.xml
Original file line number Diff line number Diff line change
@@ -19,145 +19,166 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<configuration>
<executable>java</executable>
<environmentVariables>
<PATH>${basedir}</PATH>
<HOME>${basedir}</HOME>
<GEM_PATH>${basedir}</GEM_PATH>
<GEM_HOME>${basedir}</GEM_HOME>
</environmentVariables>
</configuration>
<executions>
<execution>
<id>gem list</id>
<phase>test</phase>
<goals>
<configuration>
<executable>java</executable>
<environmentVariables>
<HOME>${basedir}/doe2notex1st2</HOME>
<GEM_PATH>${basedir}</GEM_PATH>
<GEM_HOME>${basedir}</GEM_HOME>
</environmentVariables>
</configuration>
<executions>
<execution>
<id>gem list</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>org.jruby.Main</argument>
<argument>-S</argument>
<argument>gem</argument>
<argument>list</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>rake executable</id>
<phase>test</phase>
<goals>
<configuration>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>org.jruby.Main</argument>
<argument>-S</argument>
<argument>gem</argument>
<argument>list</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>rake executable</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>org.jruby.Main</argument>
<argument>-S</argument>
<argument>rake</argument>
<argument>--version</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>rdoc executable</id>
<phase>test</phase>
<goals>
<configuration>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>org.jruby.Main</argument>
<argument>-S</argument>
<argument>rake</argument>
<argument>--version</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>rdoc executable</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>org.jruby.Main</argument>
<argument>-S</argument>
<argument>rdoc</argument>
<argument>--version</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>count installed gems</id>
<phase>test</phase>
<goals>
<configuration>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>org.jruby.Main</argument>
<argument>-S</argument>
<argument>rdoc</argument>
<argument>--version</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>count installed gems</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>org.jruby.Main</argument>
<argument>-e</argument>
<argument>
require 'stringio'
require 'rubygems/commands/list_command'
require 'rubygems/user_interaction'
s = StringIO.new
l = Gem::Commands::ListCommand.new
l.ui= Gem::StreamUI.new( STDIN, s, STDERR, true )
l.execute
c = s.string.split( /\n/ ).count
puts 'gems count ' + c.to_s
</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>load default gems</id>
<phase>test</phase>
<goals>
<configuration>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>org.jruby.Main</argument>
<argument>-e</argument>
<argument>
require 'stringio'
require 'rubygems/commands/list_command'
require 'rubygems/user_interaction'
s = StringIO.new
l = Gem::Commands::ListCommand.new
l.ui= Gem::StreamUI.new( STDIN, s, STDERR, true )
l.execute
c = s.string.split( /\n/ ).count
puts 'gems count ' + c.to_s
</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>load default gems</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<!-- automatically creates the classpath using all project dependencies,
also adding the project build directory -->
<classpath/>
<argument>org.jruby.Main</argument>
<argument>-e</argument>
<!-- make sure openssl loads -->
<argument>
require 'jar-dependencies'
require 'openssl'
puts Gem.loaded_specs.keys.sort.join(',')
</argument>
<argument>-classpath</argument>
<!-- automatically creates the classpath using all project dependencies,
also adding the project build directory -->
<classpath/>
<argument>org.jruby.Main</argument>
<argument>-e</argument>
<!-- make sure openssl loads -->
<argument>
require 'jar-dependencies'
require 'openssl'
puts Gem.loaded_specs.keys.sort.join(',')
</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>ensure there is no org.objectweb.asm.ClassWriter</id>
<phase>test</phase>
<goals>
</execution>
<execution>
<id>ensure there is no org.objectweb.asm.ClassWriter</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<!-- automatically creates the classpath using all project dependencies,
also adding the project build directory -->
<classpath/>
<argument>org.jruby.Main</argument>
<argument>-e</argument>
<!-- make sure openssl loads -->
<argument>
begin
import_java "org.objectweb.asm.ClassWriter"
raise "error there is org.objectweb.asm.ClassWriter on the classpath"
rescue NameError => e
puts "there is NO org.objectweb.asm.ClassWriter on the classpath"
<argument>-classpath</argument>
<!-- automatically creates the classpath using all project dependencies,
also adding the project build directory -->
<classpath/>
<argument>org.jruby.Main</argument>
<argument>-e</argument>
<!-- make sure openssl loads -->
<argument>
begin
import_java "org.objectweb.asm.ClassWriter"
raise "error there is org.objectweb.asm.ClassWriter on the classpath"
rescue NameError => e
puts "there is NO org.objectweb.asm.ClassWriter on the classpath"
end
</argument>
</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>gem install thrift -v0.9.2.0 - GH-3141</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<!-- automatically creates the classpath using all project dependencies,
also adding the project build directory -->
<classpath/>
<argument>org.jruby.Main</argument>
<argument>-S</argument>
<argument>gem</argument>
<argument>install</argument>
<argument>thrift</argument>
<argument>-v0.9.2.0</argument>
</arguments>
</configuration>
</execution>
</executions>
</execution>
</executions>
</plugin>
</plugins>
</build>

0 comments on commit 917d0e7

Please sign in to comment.