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: b204d8661f2e
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b799bfff8df5
Choose a head ref
  • 2 commits
  • 57 files changed
  • 1 contributor

Commits on Oct 5, 2015

  1. add webapp integration test

    using either rackup, puma or torquebox as server and sinatra as
    web framework, running from filesystem as is. further using bundler
    and having plenty of jar dependencies both locked down (Gemfile.lock
    and Jars.lock)
    mkristian committed Oct 5, 2015
    Copy the full SHA
    09d15b9 View commit details
  2. make clean behave more as you expect it

    it does delete bin/jruby and lib/jni but will recreate them immediately. this
    allows to run ```mvn clean install``` and have everything in place in fresh manner.
    mkristian committed Oct 5, 2015
    Copy the full SHA
    b799bff View commit details
Showing with 1,747 additions and 47 deletions.
  1. +1 −0 .gitignore
  2. +48 −31 core/pom.rb
  3. +52 −2 core/pom.xml
  4. +109 −0 maven/jruby/README.md
  5. +61 −13 maven/jruby/pom.rb
  6. +13 −0 maven/jruby/src/it/.mvn/extensions.xml
  7. +3 −0 maven/jruby/src/templates/hellowarld/.gitignore
  8. +19 −0 maven/jruby/src/templates/hellowarld/Gemfile
  9. +46 −0 maven/jruby/src/templates/hellowarld/Gemfile-rails4
  10. +186 −0 maven/jruby/src/templates/hellowarld/Gemfile-rails4.lock
  11. +60 −0 maven/jruby/src/templates/hellowarld/Gemfile.lock
  12. +34 −0 maven/jruby/src/templates/hellowarld/Jars.lock
  13. +274 −0 maven/jruby/src/templates/hellowarld/Mavenfile
  14. +15 −0 maven/jruby/src/templates/hellowarld/WEB-INF/init.rb
  15. +8 −0 maven/jruby/src/templates/hellowarld/WEB-INF/jboss-web.xml
  16. +70 −0 maven/jruby/src/templates/hellowarld/app-cuba/hellowarld.rb
  17. +1 −0 maven/jruby/src/templates/hellowarld/app-cuba/views/layout.erb
  18. +52 −0 maven/jruby/src/templates/hellowarld/app-cuba/views/person.erb
  19. 0 maven/jruby/src/templates/hellowarld/app-rails4/assets/images/.keep
  20. +16 −0 maven/jruby/src/templates/hellowarld/app-rails4/assets/javascripts/application.js
  21. +15 −0 maven/jruby/src/templates/hellowarld/app-rails4/assets/stylesheets/application.css
  22. +5 −0 maven/jruby/src/templates/hellowarld/app-rails4/controllers/application_controller.rb
  23. 0 maven/jruby/src/templates/hellowarld/app-rails4/controllers/concerns/.keep
  24. +28 −0 maven/jruby/src/templates/hellowarld/app-rails4/controllers/person_controller.rb
  25. +2 −0 maven/jruby/src/templates/hellowarld/app-rails4/helpers/application_helper.rb
  26. 0 maven/jruby/src/templates/hellowarld/app-rails4/mailers/.keep
  27. 0 maven/jruby/src/templates/hellowarld/app-rails4/models/.keep
  28. 0 maven/jruby/src/templates/hellowarld/app-rails4/models/concerns/.keep
  29. +1 −0 maven/jruby/src/templates/hellowarld/app-rails4/views/layouts/application.html.erb
  30. +52 −0 maven/jruby/src/templates/hellowarld/app-rails4/views/person/show.erb
  31. +60 −0 maven/jruby/src/templates/hellowarld/app-sinatra/hellowarld.rb
  32. +52 −0 maven/jruby/src/templates/hellowarld/app-sinatra/views/person.erb
  33. +3 −0 maven/jruby/src/templates/hellowarld/config-cuba.ru
  34. +7 −0 maven/jruby/src/templates/hellowarld/config-rails4.ru
  35. +7 −0 maven/jruby/src/templates/hellowarld/config-sinatra.ru
  36. +61 −0 maven/jruby/src/templates/hellowarld/config/application.rb
  37. +3 −0 maven/jruby/src/templates/hellowarld/config/boot.rb
  38. +23 −0 maven/jruby/src/templates/hellowarld/config/database.yml
  39. +5 −0 maven/jruby/src/templates/hellowarld/config/environment.rb
  40. +41 −0 maven/jruby/src/templates/hellowarld/config/environments/development.rb
  41. +79 −0 maven/jruby/src/templates/hellowarld/config/environments/production.rb
  42. +42 −0 maven/jruby/src/templates/hellowarld/config/environments/test.rb
  43. +11 −0 maven/jruby/src/templates/hellowarld/config/initializers/assets.rb
  44. +7 −0 maven/jruby/src/templates/hellowarld/config/initializers/backtrace_silencers.rb
  45. +3 −0 maven/jruby/src/templates/hellowarld/config/initializers/cookies_serializer.rb
  46. +4 −0 maven/jruby/src/templates/hellowarld/config/initializers/filter_parameter_logging.rb
  47. +16 −0 maven/jruby/src/templates/hellowarld/config/initializers/inflections.rb
  48. +4 −0 maven/jruby/src/templates/hellowarld/config/initializers/mime_types.rb
  49. +3 −0 maven/jruby/src/templates/hellowarld/config/initializers/session_store.rb
  50. +14 −0 maven/jruby/src/templates/hellowarld/config/initializers/wrap_parameters.rb
  51. +23 −0 maven/jruby/src/templates/hellowarld/config/locales/en.yml
  52. +62 −0 maven/jruby/src/templates/hellowarld/config/routes.rb
  53. +22 −0 maven/jruby/src/templates/hellowarld/config/secrets.yml
  54. +6 −0 maven/jruby/src/templates/hellowarld/pom.xml
  55. +1 −1 maven/pom.rb
  56. +8 −0 pom.rb
  57. +9 −0 pom.xml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -87,6 +87,7 @@ install/updates.xml

# generated ITs
maven/jruby/src/it/osgi_*
maven/jruby/src/it/hellowarld_*
maven/jruby/src/it/j2ee_wlp
maven/jruby-complete/src/it/osgi*
maven/jruby-complete/pom.xml
79 changes: 48 additions & 31 deletions core/pom.rb
Original file line number Diff line number Diff line change
@@ -208,7 +208,9 @@
'filesets' => [ { 'directory' => '${project.build.sourceDirectory}',
'includes' => [ '${Constants.java}' ] },
{ 'directory' => '${project.basedir}/..',
'includes' => [ 'bin/jruby' ] } ],
'includes' => [ 'bin/jruby' ] },
{ 'directory' => '${project.basedir}/..',
'includes' => [ 'lib/jni/**' ] } ],
'failOnError' => 'false' )
end

@@ -274,53 +276,68 @@
end
end

jruby_bin_config = [ 'run', { :id => 'copy',
'tasks' => {
'exec' => {
'@executable' => '/bin/sh',
'@osfamily' => 'unix',
'arg' => {
'@line' => '-c \'cp "${jruby.basedir}/bin/jruby.bash" "${jruby.basedir}/bin/jruby"\''
}
},
'chmod' => {
'@file' => '${jruby.basedir}/bin/jruby',
'@perm' => '755'
}
} } ]

phase :clean do
plugin :antrun do
execute_goals( *jruby_bin_config )
end
end

profile 'jruby.bash' do

activation do
file( :missing => '../bin/jruby' )
end

plugin :antrun do
execute_goals( 'run',
:id => 'copy',
:phase => 'initialize',
'tasks' => {
'exec' => {
'@executable' => '/bin/sh',
'@osfamily' => 'unix',
'arg' => {
'@line' => '-c \'cp "${jruby.basedir}/bin/jruby.bash" "${jruby.basedir}/bin/jruby"\''
}
},
'chmod' => {
'@file' => '${jruby.basedir}/bin/jruby',
'@perm' => '755'
}
} )
phase :initialize do
plugin :antrun do
execute_goals( *jruby_bin_config )
end
end

end

jni_config = [ 'unpack', { :id => 'unzip native',
'excludes' => 'META-INF,META-INF/*',
'artifactItems' => [ { 'groupId' => 'com.github.jnr',
'artifactId' => 'jffi',
'version' => '${jffi.version}',
'type' => 'jar',
'classifier' => 'native',
'overWrite' => 'false',
'outputDirectory' => '${jruby.basedir}/lib' } ] } ]

phase :clean do
plugin :dependency do
execute_goals( *jni_config )
end
end

profile 'native' do

activation do
file( :missing => '../lib/jni' )
end

plugin :dependency do
execute_goals( 'unpack',
:id => 'unzip native',
:phase => 'process-classes',
'excludes' => 'META-INF,META-INF/*',
'artifactItems' => [ { 'groupId' => 'com.github.jnr',
'artifactId' => 'jffi',
'version' => '${jffi.version}',
'type' => 'jar',
'classifier' => 'native',
'overWrite' => 'false',
'outputDirectory' => '${jruby.basedir}/lib' } ] )
phase 'process-classes' do
plugin :dependency do
execute_goals( *jni_config )
end
end

end

profile 'test' do
54 changes: 52 additions & 2 deletions core/pom.xml
Original file line number Diff line number Diff line change
@@ -545,6 +545,12 @@ DO NOT MODIFIY - GENERATED CODE
<include>bin/jruby</include>
</includes>
</fileset>
<fileset>
<directory>${project.basedir}/..</directory>
<includes>
<include>lib/jni/**</include>
</includes>
</fileset>
</filesets>
<failOnError>false</failOnError>
</configuration>
@@ -597,6 +603,52 @@ DO NOT MODIFIY - GENERATED CODE
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>clean</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<exec executable="/bin/sh" osfamily="unix">
<arg line="-c 'cp &quot;${jruby.basedir}/bin/jruby.bash&quot; &quot;${jruby.basedir}/bin/jruby&quot;'" />
</exec>
<chmod file="${jruby.basedir}/bin/jruby" perm="755" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unzip native</id>
<phase>clean</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<excludes>META-INF,META-INF/*</excludes>
<artifactItems>
<artifactItem>
<groupId>com.github.jnr</groupId>
<artifactId>jffi</artifactId>
<version>${jffi.version}</version>
<type>jar</type>
<classifier>native</classifier>
<overWrite>false</overWrite>
<outputDirectory>${jruby.basedir}/lib</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
@@ -877,7 +929,6 @@ DO NOT MODIFIY - GENERATED CODE
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>initialize</phase>
<goals>
<goal>run</goal>
@@ -909,7 +960,6 @@ DO NOT MODIFIY - GENERATED CODE
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unzip native</id>
<phase>process-classes</phase>
<goals>
<goal>unpack</goal>
109 changes: 109 additions & 0 deletions maven/jruby/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# running tests #

important for the rails4 warfile tests to increase the PermGen Space
for jdk7

```
export MAVEN_OPTS='-XX:MaxPermSize=192m'
```


all tests
```
mvn verify -Papps
```

to pick a single tests
```
mvn verify -Papps -Dinvoker.test=hellowarld_jetty_unpacked_warfile_cuba
```

see the directory listing of ```./src/it/hellowarld_*``` - each directory is a single test.

you also can use wildcards to pick test runs
```
mvn verify -Papps -Dinvoker.test=hellowarld_*_cuba
mvn verify -Papps -Dinvoker.test=hellowarld_jetty_*
mvn verify -Papps -Dinvoker.test=hellowarld_jetty_*rails4
mvn verify -Papps -Dinvoker.test=hellowarld*warfile*sinatra
```

## the application is implemented with different web-framework

it is a simple application demonstrating the PATCH http verb and adds various monitoring rack plugins which uses quite some numbers of jar dependencies.

### cuba

does not use bundler and almost a pure rack application as cuba has tiny codebase.

### sinatra

uses bundler (even it could just do the same as the cuba app). bundler adds another workaround here in there inside the packed applications.

### rails4

rails is heavily bound to its filesystem layout which can cause problems with packing it in jar/war and run it from there (without unpacking it).

## webservers no servlets

### webrick

default from ruby

### puma

something which is working with jruby

### torquebox

it comes with its own tools to pack jars and wars which is NOT used. but it executes a config.ru like the other to webservers

## webservers - servlets engine

### jetty

### tomcat

### wildfly

it can run war-files packed or deploy them which includes an unpacking on disk. both cases are tested

## package format

### filesystem

using one of the webserver (not servlets)

### runnable

pack the whole application into a jar file and execute the webserver from within the jar and run the whole application from within the jar

### warfile

needs a servlet container to run

# problems

* nokogiri (from rails) does not work with jdk8 with servlets since it
usese com.sun.* classes which do not exist anymore. not sure why it
works outside a servelt engine - at least with wildfly

* with jdk7 rails on servlet needs more perm space

# PENDING

* websphere which just needs more copy paste from another template here

* rails5

* glassfish, resin would be nice to have as well

* ear files with jruby part of the ear-container and then war-container inherits this classpath

* web-archive-bundle, i.e. OSGi bundle with a web-application packed. here jruby could be external dependency and its own OSGi bundle

* actually trigger the PATCH request and test its outcome

* run jetty and tomcat both packed and unpacked. probably needs just some custom context.xml

* get the jruby9 extensions into the ruby DSL and clean up the runy DSL a bit (jars_lock to pick the jar dependencies from there, etc).
74 changes: 61 additions & 13 deletions maven/jruby/pom.rb
Original file line number Diff line number Diff line change
@@ -9,10 +9,6 @@
# keep it a jar even without sources - easier to add to a project
packaging 'jar'

properties( 'tesla.dump.pom' => 'pom.xml',
'tesla.dump.readonly' => true,
'main.basedir' => '${project.parent.parent.basedir}' )

jar 'org.jruby:jruby-core:${project.version}'
jar 'org.jruby:jruby-stdlib:${project.version}'

@@ -23,16 +19,68 @@
# this plugin is configured to attach empty jars for sources and javadocs
plugin( 'org.codehaus.mojo:build-helper-maven-plugin' )

plugin( :invoker )
plugin( :invoker, :properties => { 'localRepository' => '${settings.localRepository}' } )

profile :apps do
activation do
property :name => 'invoker.test'
end

properties 'invoker.skip' => false, 'invoker.test' => 'hellowarld_*'

execute 'setup web applications', :phase => 'pre-integration-test' do |ctx|
def setup(ctx, framework, package, type, server)
puts [framework, package, server].join "\t"

source = File.join( ctx.basedir.to_pathname, 'src', 'templates', 'hellowarld' )
target = File.join( ctx.basedir.to_pathname, "src/it/hellowarld_#{server}_#{package}_#{framework}" )

FileUtils.rm_rf( target )
FileUtils.cp_r( source, target )
FileUtils.mv( "#{target}/config-#{framework}.ru", "#{target}/config.ru" )
FileUtils.mv( "#{target}/app-#{framework}", "#{target}/app" )
file = "#{target}/Gemfile-#{framework}"
FileUtils.mv( file, "#{target}/Gemfile" ) if File.exists?( file )
file = "#{target}/Gemfile-#{framework}.lock"
FileUtils.mv( file, "#{target}/Gemfile.lock" ) if File.exists?( file )
file = File.join( target, 'Mavenfile')
File.write(file, File.read(file).sub(/pom/, type))
File.open( File.join( target, 'invoker.properties' ), 'w' ) do |f|
f.puts "invoker.profiles = #{package},#{server},#{framework}"
end
end

[ 'cuba', 'sinatra', 'rails4' ].each do |framework|
[ ['filesystem', 'pom'], ['runnable','jrubyJar'] ].each do |package|
[ 'webrick', 'puma', 'torquebox' ].each do |server|
setup(ctx, framework, *package, server)
end
end
[ ['warfile', 'jrubyWar'] ].each do |package|
[ 'jetty', 'tomcat', 'wildfly_unpacked', 'wildfly_packed' ].each do |server|
#', 'websphere' ].each do |server|
# rails4 on wildfly complains about missing com.sun.org.apache.xpath.internal.VariableStack which are actually xalan classes used by nokogiri
setup(ctx, framework, *package, server) unless framework == 'rails4' and server =~ /wildfly/
end
end
end
end
end

profile :osgi do
activation do
property :name => 'invoker.test'
end

execute 'setup other osgi frameworks', :phase => 'pre-integration-test' do |ctx|
source = File.join( ctx.basedir.to_pathname, 'src', 'templates', 'osgi_all_inclusive' )
[ 'knoplerfish', 'equinox-3.6', 'equinox-3.7', 'felix-3.2', 'felix-4.4'].each do |m|
target = File.join( ctx.basedir.to_pathname, 'src', 'it', 'osgi_all_inclusive_' + m )
FileUtils.rm_rf( target )
FileUtils.cp_r( source, target )
File.open( File.join( target, 'invoker.properties' ), 'w' ) do |f|
f.puts 'invoker.profiles = ' + m
execute 'setup osgi integration tests', :phase => 'pre-integration-test' do |ctx|
source = File.join( ctx.basedir.to_pathname, 'src', 'templates', 'osgi_all_inclusive' )
[ 'knoplerfish', 'equinox-3.6', 'equinox-3.7', 'felix-3.2', 'felix-4.4'].each do |m|
target = File.join( ctx.basedir.to_pathname, 'src', 'it', 'osgi_all_inclusive_' + m )
FileUtils.rm_rf( target )
FileUtils.cp_r( source, target )
File.open( File.join( target, 'invoker.properties' ), 'w' ) do |f|
f.puts 'invoker.profiles = ' + m
end
end
end
end
Loading