Skip to content

Commit

Permalink
add bundler monkey patch
Browse files Browse the repository at this point in the history
  • Loading branch information
mkristian committed Jun 9, 2016
1 parent 4f7de5b commit dd3ed78
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 0 deletions.
91 changes: 91 additions & 0 deletions integration/runnable_w_bundler_test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.jruby.warbler</groupId>
<artifactId>integration-tests</artifactId>
<version>1.0</version>
</parent>

<artifactId>runnable_w_bundler_test</artifactId>
<packaging>jar</packaging>

<name>runnable_w_bundler_test</name>

<properties>
<test-file>test-file.tmp</test-file>
</properties>

<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>auto-clean</id>
<phase>pre-integration-test</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<excludeDefaultDirectories>true</excludeDefaultDirectories>
<filesets>
<fileset>
<directory>${project.build.directory}</directory>
<includes>
<include>${test-file}</include>
</includes>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>de.saumya.mojo</groupId>
<artifactId>jruby-maven-plugin</artifactId>
<executions>
<execution>
<id>warble</id>
<phase>pre-integration-test</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>test-rake-task</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<workingDirectory>${project.build.directory}</workingDirectory>
<arguments>
<argument>-jar</argument>
<argument>test.jar</argument>
<argument>-S</argument>
<argument>run.rb</argument>
<argument>${project.build.directory}/${test-file}</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<testFilename>${project.build.directory}/${test-file}</testFilename>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</project>
5 changes: 5 additions & 0 deletions integration/runnable_w_bundler_test/src/main/ruby/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source 'https://rubygems.org'

gem 'json', '1.8.3'

#gem 'warbler', :group => 'development'
18 changes: 18 additions & 0 deletions integration/runnable_w_bundler_test/src/main/ruby/bin/run.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require 'bundler/setup'

path = File.join(Gem.loaded_specs['json'].full_gem_path, 'lib')
File.open(ARGV[2], 'w') do |f|
f.puts("hello world")
f.puts path
f.puts $LOAD_PATH
end

unless $LOAD_PATH.member? path
raise "wrong load path, expected #{path} to be in #{$LOAD_PATH}"
end

$LOAD_PATH.each do |p|
unless p =~ /^uri:classloader:/
raise "expected path #{p} to start with uri:classloader:"
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Warbler::Config.new do |config|
config.features = %w(executable)
config.autodeploy_dir = "../../../target"
config.jar_name = "test"

config.includes = FileList["Gemfile*"] + FileList["bin/*rb"]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.jruby.warbler;

import java.net.*;
import java.io.*;
import org.junit.Assert;
import org.junit.Test;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;

/**
* Unit test for simple runnable war.
*/
public class RunnableWarTestIT
{
@Test
public void testApp() throws Exception
{
String testFilename = System.getProperty("testFilename");
File f = new File(testFilename);
Assert.assertTrue(testFilename + "should exist", f.exists());
}
}
15 changes: 15 additions & 0 deletions lib/warbler/templates/bundler.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,18 @@ ENV['BUNDLE_WITHOUT'] = '<%= config.bundle_without.join(':') %>'
<% if config.bundler[:frozen] -%>
ENV['BUNDLE_FROZEN'] = '1'
<% end -%>

module Bundler
module Patch
def clean_load_path
# nothing to be done for embedded JRuby
end
end
module SharedHelpers
def included(bundler)
bundler.send :include, Patch
end
end
end

require 'bundler/shared_helpers'

0 comments on commit dd3ed78

Please sign in to comment.