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
13 changes: 13 additions & 0 deletions maven/jruby/src/it/.mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<extensions>
<extension>
<groupId>io.takari.polyglot</groupId>
<artifactId>polyglot-ruby</artifactId>
<version>0.1.12</version>
</extension>
<extension>
<groupId>de.saumya.mojo</groupId>
<artifactId>jruby9-extensions</artifactId>
<version>0.2.0</version>
</extension>
</extensions>
3 changes: 3 additions & 0 deletions maven/jruby/src/templates/hellowarld/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.ruby-*
pkg
*war
19 changes: 19 additions & 0 deletions maven/jruby/src/templates/hellowarld/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#-*- mode: ruby -*-

source 'https://rubygems.org'

gem 'leafy-complete', '~> 0.6'
gem 'sinatra', '~> 1.4'

group 'puma' do
gem 'puma', '~> 2.13'
end
group 'torquebox' do
gem 'torquebox', '4.0.0.beta2'
end

group 'development' do
gem 'rake', '~> 10.2'
end

# vim: syntax=Ruby
46 changes: 46 additions & 0 deletions maven/jruby/src/templates/hellowarld/Gemfile-rails4
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
source 'https://rubygems.org'

gem 'leafy-complete', '~> 0.6'

group 'puma' do
gem 'puma', '~> 2.13'
end
group 'torquebox' do
gem 'torquebox', '4.0.0.beta2'
end

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.3'
# Use jdbcsqlite3 as the database for Active Record
gem 'activerecord-jdbcsqlite3-adapter'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
gem 'therubyrhino'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
#gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

#group :development, :test do
#end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
186 changes: 186 additions & 0 deletions maven/jruby/src/templates/hellowarld/Gemfile-rails4.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.3)
actionpack (= 4.2.3)
actionview (= 4.2.3)
activejob (= 4.2.3)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.3)
actionview (= 4.2.3)
activesupport (= 4.2.3)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.3)
activesupport (= 4.2.3)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.3)
activesupport (= 4.2.3)
globalid (>= 0.3.0)
activemodel (4.2.3)
activesupport (= 4.2.3)
builder (~> 3.1)
activerecord (4.2.3)
activemodel (= 4.2.3)
activesupport (= 4.2.3)
arel (~> 6.0)
activerecord-jdbc-adapter (1.3.17)
activerecord (>= 2.2)
activerecord-jdbcsqlite3-adapter (1.3.17)
activerecord-jdbc-adapter (~> 1.3.17)
jdbc-sqlite3 (>= 3.7.2, < 3.9)
activesupport (4.2.3)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.2)
builder (3.2.2)
coffee-rails (4.1.0)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.9.1.1)
erubis (2.7.0)
execjs (2.5.2)
globalid (0.3.5)
activesupport (>= 4.1.0)
i18n (0.7.0)
jar-dependencies (0.2.2)
jbuilder (2.3.1)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
jdbc-sqlite3 (3.8.10.1)
jquery-rails (4.0.4)
rails-dom-testing (~> 1.0)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.3-java)
leafy-complete (0.6.2-java)
leafy-health (~> 0.6.2)
leafy-logger (~> 0.6.2)
leafy-metrics (~> 0.6.2)
leafy-rack (~> 0.6.2)
leafy-health (0.6.2-java)
jar-dependencies (~> 0.1)
leafy-logger (0.6.2-java)
jar-dependencies (~> 0.1)
leafy-metrics (~> 0.6.2)
leafy-metrics (0.6.2-java)
jar-dependencies (~> 0.1)
leafy-rack (0.6.2-java)
jar-dependencies (~> 0.1)
leafy-health (~> 0.6.2)
leafy-logger (~> 0.6.2)
leafy-metrics (~> 0.6.2)
loofah (2.0.2)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
mime-types (2.6.1)
minitest (5.7.0)
multi_json (1.11.2)
nokogiri (1.6.6.2-java)
puma (2.13.4-java)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.3)
actionmailer (= 4.2.3)
actionpack (= 4.2.3)
actionview (= 4.2.3)
activejob (= 4.2.3)
activemodel (= 4.2.3)
activerecord (= 4.2.3)
activesupport (= 4.2.3)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.3)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.6)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.2)
loofah (~> 2.0)
railties (4.2.3)
actionpack (= 4.2.3)
activesupport (= 4.2.3)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
sass (3.4.16)
sass-rails (5.0.3)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (~> 1.1)
sprockets (3.2.0)
rack (~> 1.0)
sprockets-rails (2.3.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
therubyrhino (2.0.4)
therubyrhino_jar (>= 1.7.3)
therubyrhino_jar (1.7.6)
thor (0.19.1)
thread_safe (0.3.5-java)
tilt (1.4.1)
torquebox (4.0.0.beta2-java)
torquebox-caching (= 4.0.0.beta2)
torquebox-core (= 4.0.0.beta2)
torquebox-messaging (= 4.0.0.beta2)
torquebox-scheduling (= 4.0.0.beta2)
torquebox-web (= 4.0.0.beta2)
torquebox-caching (4.0.0.beta2-java)
torquebox-core (= 4.0.0.beta2)
torquebox-core (4.0.0.beta2-java)
torquebox-messaging (4.0.0.beta2-java)
torquebox-core (= 4.0.0.beta2)
torquebox-scheduling (4.0.0.beta2-java)
torquebox-core (= 4.0.0.beta2)
torquebox-web (4.0.0.beta2-java)
rack (>= 1.4.0, < 2.0)
torquebox-core (= 4.0.0.beta2)
turbolinks (2.5.3)
coffee-rails
tzinfo (1.2.2)
thread_safe (~> 0.1)
tzinfo-data (1.2015.5)
tzinfo (>= 1.0.0)
uglifier (2.7.1)
execjs (>= 0.3.0)
json (>= 1.8.0)

PLATFORMS
java

DEPENDENCIES
activerecord-jdbcsqlite3-adapter
coffee-rails (~> 4.1.0)
jbuilder (~> 2.0)
jquery-rails
leafy-complete (~> 0.6)
puma (~> 2.13)
rails (= 4.2.3)
sass-rails (~> 5.0)
therubyrhino
torquebox (= 4.0.0.beta2)
turbolinks
tzinfo-data
uglifier (>= 1.3.0)

BUNDLED WITH
1.10.6
60 changes: 60 additions & 0 deletions maven/jruby/src/templates/hellowarld/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
GEM
remote: https://rubygems.org/
specs:
jar-dependencies (0.2.2)
leafy-complete (0.6.2-java)
leafy-health (~> 0.6.2)
leafy-logger (~> 0.6.2)
leafy-metrics (~> 0.6.2)
leafy-rack (~> 0.6.2)
leafy-health (0.6.2-java)
jar-dependencies (~> 0.1)
leafy-logger (0.6.2-java)
jar-dependencies (~> 0.1)
leafy-metrics (~> 0.6.2)
leafy-metrics (0.6.2-java)
jar-dependencies (~> 0.1)
leafy-rack (0.6.2-java)
jar-dependencies (~> 0.1)
leafy-health (~> 0.6.2)
leafy-logger (~> 0.6.2)
leafy-metrics (~> 0.6.2)
puma (2.13.4-java)
rack (1.6.4)
rack-protection (1.5.3)
rack
rake (10.4.2)
sinatra (1.4.6)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
tilt (2.0.1)
torquebox (4.0.0.beta2-java)
torquebox-caching (= 4.0.0.beta2)
torquebox-core (= 4.0.0.beta2)
torquebox-messaging (= 4.0.0.beta2)
torquebox-scheduling (= 4.0.0.beta2)
torquebox-web (= 4.0.0.beta2)
torquebox-caching (4.0.0.beta2-java)
torquebox-core (= 4.0.0.beta2)
torquebox-core (4.0.0.beta2-java)
torquebox-messaging (4.0.0.beta2-java)
torquebox-core (= 4.0.0.beta2)
torquebox-scheduling (4.0.0.beta2-java)
torquebox-core (= 4.0.0.beta2)
torquebox-web (4.0.0.beta2-java)
rack (>= 1.4.0, < 2.0)
torquebox-core (= 4.0.0.beta2)

PLATFORMS
java

DEPENDENCIES
leafy-complete (~> 0.6)
puma (~> 2.13)
rake (~> 10.2)
sinatra (~> 1.4)
torquebox (= 4.0.0.beta2)

BUNDLED WITH
1.10.6
34 changes: 34 additions & 0 deletions maven/jruby/src/templates/hellowarld/Jars.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
io.dropwizard.metrics:metrics-healthchecks:3.1.0:compile:
org.slf4j:slf4j-api:1.7.7:compile:
io.dropwizard.metrics:metrics-jvm:3.1.0:compile:
io.dropwizard.metrics:metrics-core:3.1.0:compile:
io.dropwizard.metrics:metrics-graphite:3.1.0:compile:
io.dropwizard:dropwizard-logging:0.8.0-rc5:compile:
io.dropwizard:dropwizard-jackson:0.8.0-rc5:compile:
com.google.guava:guava:18.0:compile:
io.dropwizard:dropwizard-util:0.8.0-rc5:compile:
com.google.code.findbugs:jsr305:3.0.0:compile:
com.fasterxml.jackson.core:jackson-core:2.5.1:compile:
com.fasterxml.jackson.datatype:jackson-datatype-jdk7:2.5.1:compile:
com.fasterxml.jackson.datatype:jackson-datatype-guava:2.5.1:compile:
com.fasterxml.jackson.module:jackson-module-afterburner:2.5.1:compile:
com.fasterxml.jackson.datatype:jackson-datatype-joda:2.5.1:compile:
io.dropwizard:dropwizard-validation:0.8.0-rc5:compile:
org.hibernate:hibernate-validator:5.1.3.Final:compile:
javax.validation:validation-api:1.1.0.Final:compile:
org.jboss.logging:jboss-logging:3.1.3.GA:compile:
com.fasterxml:classmate:1.0.0:compile:
org.glassfish:javax.el:3.0.0:compile:
io.dropwizard.metrics:metrics-logback:3.1.0:compile:
org.slf4j:jul-to-slf4j:1.7.10:compile:
ch.qos.logback:logback-core:1.1.2:compile:
ch.qos.logback:logback-classic:1.1.2:compile:
org.slf4j:log4j-over-slf4j:1.7.10:compile:
org.slf4j:jcl-over-slf4j:1.7.10:compile:
org.eclipse.jetty:jetty-util:9.2.9.v20150224:compile:
io.dropwizard:dropwizard-configuration:0.8.0-rc5:compile:
com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.5.1:compile:
org.apache.commons:commons-lang3:3.3.2:compile:
io.dropwizard.metrics:metrics-json:3.1.0:compile:
com.fasterxml.jackson.core:jackson-databind:2.4.2:compile:
com.fasterxml.jackson.core:jackson-annotations:2.4.0:compile:
274 changes: 274 additions & 0 deletions maven/jruby/src/templates/hellowarld/Mavenfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,274 @@
#-*- mode: ruby -*-

gemfile

gem 'bundler', '1.10.6'
gem 'cuba', '3.4.0'

name '${cmd} ${framework} from ${package}'

packaging 'pom'

# TODO add extension to .mvn/extensions.xml
extension 'de.saumya.mojo', 'jruby9-extensions', '${jruby9.plugins.version}'

properties( 'jruby.plugins.version' => '1.1.0',
'jruby9.plugins.version' => '0.2.0' )

# integration tests
###################

properties( 'gem.home' => '${basedir}/../rubygems-hellowarld',
# inherited from invoker config
'jars.home' => '${localRepository}',
:baseurl => 'http://localhost:9292' )

profile 'sinatra' do
properties :framework => 'sinatra'
end

profile 'cuba' do
properties :framework => 'cuba'
end

profile 'rails4' do
properties :framework => 'rails4', 'wildfly.javaOpts' => '-XX:MaxPermSize=192m'
end

profile 'webrick' do
properties :cmd => 'rackup'
end

profile 'puma' do
properties :cmd => 'puma'
end

profile 'torquebox' do
properties :cmd => 'torquebox run', :baseurl => 'http://localhost:8080'
end

File.read('Jars.lock').each_line do |line|
data = line.sub(/-\ /, '').strip.split(':')
if data.size > 3
data = Hash[ [:groupId, :artifactId, :version, :scope].zip( data ) ]
jar data[:groupId], data[:artifactId], data[:version]
end
end

profile 'filesystem' do
properties( :executable => 'JARS_HOME=${jars.home} GEM_PATH=${gem.home} GEM_HOME=${gem.home}' )
end

profile 'runnable' do
properties( :package => 'runnable',
:executable => 'java -jar ${project.build.directory}/${project.build.finalName}.jar -S' )

build do
resource( :directory => '${basedir}',
:includes => ['Gemfile*', '*lock', 'config*.ru', 'app/**', 'config/**' ] )
end
end

profile 'warfile' do
properties :package => 'warfile', :baseurl => 'http://localhost:8080'

jruby_plugin!( 'jruby9-war', '${jruby9.plugins.version}',
:webResources => [ { :directory => '${basedir}',
:includes => [ 'WEB-INF/*' ] } ] )

build do
resource( :directory => '${basedir}',
:includes => ['Gemfile*', '*lock', 'config*.ru', 'app/**', 'config/**' ] )
end
end

profile 'jetty' do

properties :cmd => 'jetty'

plugin( 'org.eclipse.jetty:jetty-maven-plugin', '9.1.3.v20140225',
:war => '${project.build.directory}/${project.build.finalName}.war',
:stopPort => 9999,
:stopKey => 'foo' ) do
# deploy-war will use the exploded war from
# ${project.build.directory}/${project.build.finalName}
execute_goal( 'deploy-war', :id => 'start jetty', :phase => 'pre-integration-test', :daemon => true )
execute_goal( 'stop', :id => 'stop jetty', :phase => 'post-integration-test' )
end
end

profile 'tomcat' do

properties :cmd => 'tomcat'

plugin( 'org.codehaus.mojo:tomcat-maven-plugin', '1.1',
:path => '/', :ignorePackaging => true,
:warDirectory => '${project.build.directory}/${project.build.finalName}' ) do
execute_goals( 'run-war-only',
:id => 'start tomcat',
:phase => 'pre-integration-test',
:fork => true )
execute_goals( 'shutdown',
:id => 'stop tomcat',
:phase => 'post-integration-test' )
end
end

[ 'wildfly_unpacked', 'wildfly_packed' ].each do |name|

profile name do
properties :cmd => name

plugin( 'org.wildfly.plugins:wildfly-maven-plugin', '1.0.2.Final' ) do
execute_goals( :start,
:id => 'start wildfly',
:phase => 'pre-integration-test' )
execute_goals( :shutdown,
:id => 'stop wildfly',
:phase => 'post-integration-test' )
end
end
end

profile! 'wildfly_unpacked' do
plugin!( 'org.wildfly.plugins:wildfly-maven-plugin' ) do
execute_goals( :start,
:id => 'start wildfly',
:phase => 'pre-integration-test' )
execute_goals( :shutdown,
:id => 'stop wildfly',
:phase => 'post-integration-test' )
execute_goals( 'deploy-only',
:id => 'deploy to wildfly',
:phase => 'pre-integration-test',
:filename => '${project.build.finalName}.war',
:name => 'test.war')
end
end

profile! 'wildfly_packed' do
execute 'deploy to wildfly', 'pre-integration-test' do |ctx|
baseurl = ctx.project.properties['baseurl']
dir = Dir[ 'target/wildfly-run/*' ].first
war = Dir[ 'target/*.war' ].first
FileUtils.cp( war, dir + '/standalone/deployments/test.war' )
loop do
sleep 1
begin
if open( "#{baseurl}/ping" ).string == 'pong'
break
end
rescue => e
puts e.message
end
end
puts "started ..."
end
end

[ 'filesystem', 'runnable'].each do |name|
profile! name do

properties( :package => name )

execute 'start up', :phase => 'pre-integration-test' do |ctx|
baseurl = ctx.project.properties['baseurl']
cmd = ctx.project.properties['cmd']
executable = ctx.project.properties['executable']
config_ru = "config-#{ctx.project.properties['framework']}.ru"
# just in case - during debugging it can happen
open( "#{baseurl}/shutdown" ) rescue nil
Thread.new do
command = "#{executable} #{cmd}"
puts "starting #{command}"
puts "#{baseurl}/ping"
`#{command}`
end.run
loop do
sleep 1
begin
if open( "#{baseurl}/ping" ).string == 'pong'
break
end
rescue => e
puts e.message
end
end
puts "started ..."
end

execute 'shutdown', :phase => 'post-integration-test' do |ctx|
baseurl = ctx.project.properties['baseurl']
open( "#{baseurl}/shutdown" ) rescue nil
puts "stopped"
end
end
end

require 'open-uri'
results = []
execute 'download', :phase => 'integration-test' do |ctx|
baseurl = ctx.project.properties['baseurl']
puts baseurl
results << open( "#{baseurl}/app" ).string
results << open( "#{baseurl}/admin" ).string
results << open( "#{baseurl}/admin/ping" ).string
results << open( "#{baseurl}/admin/health" ).string
results << open( "#{baseurl}/admin/metrics" ).string
results << open( "#{baseurl}/admin/threads" ).read
results << open( "#{baseurl}/ping" ).string
results << open( "#{baseurl}/health" ).string
results << open( "#{baseurl}/metrics" ).string
results << open( "#{baseurl}/threads" ).read
results.each { |r| puts r[0..20] }
end

# verify the downloads
execute 'verify downloads', :phase => :verify do
expected = 'christian'
unless results[0].match( /#{expected}/ )
raise "missed expected string in download: #{expected}"
end
expected = 'menu'
unless results[1].match( /#{expected}/ )
raise "missed expected string in download: #{expected}"
end
expected = 'pong'
unless results[2].match( /#{expected}/ )
raise "missed expected string in download: #{expected}"
end
require 'json'
json = JSON.parse( results[3] )
unless json["app.health"]["healthy"]
raise "healthy expected"
end
json = JSON.parse( results[4] )
unless json["meters"]["webapp.responseCodes.ok"]["count"] == 1
raise "one OK request expected"
end
unless results[5].length > 10000
puts result[5]
raise "expected thread dump to be big"
end
expected = 'pong'
unless results[6].match( /#{expected}/ )
raise "missed expected string in download: #{expected}"
end
json = JSON.parse( results[7] )
unless json["app.health"]["healthy"]
raise "healthy expected"
end
json = JSON.parse( results[8] )
unless json["meters"]["webapp.responseCodes.ok"]["count"] == 1
raise "one OK request expected"
end
unless json["meters"]["collected.responseCodes.2xx"]["count"] == 1
raise "one 2xx request expected"
end
unless results[9].length > 10000
puts result[9]
raise "expected thread dump to be big"
end
sleep 1
end

15 changes: 15 additions & 0 deletions maven/jruby/src/templates/hellowarld/WEB-INF/init.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# bundler includes Bundler::SharedHelpers into its runtime
# adding the included method allows to monkey patch the runtime
# the moment it is used. i.e. no need to activate the bundler gem
module Bundler
module Patch
def clean_load_path
# nothing to be done for JRuby
end
end
module SharedHelpers
def included(bundler)
bundler.send :include, Patch
end
end
end
8 changes: 8 additions & 0 deletions maven/jruby/src/templates/hellowarld/WEB-INF/jboss-web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.jboss.com/xml/ns/javaee
http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd">
<context-root>/</context-root>
</jboss-web>
70 changes: 70 additions & 0 deletions maven/jruby/src/templates/hellowarld/app-cuba/hellowarld.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
require 'cuba'
require "cuba/render"
require 'cuba/safe'
require 'json'
require 'ostruct'
require 'leafy/metrics'
require 'leafy/health'
require 'leafy/instrumented/instrumented'
require 'leafy/instrumented/collected_instrumented'
require 'leafy/rack/admin'
require 'leafy/rack/instrumented'

data = OpenStruct.new
data.surname = 'meier'
data.firstname = 'christian'

Cuba.plugin Cuba::Safe
Cuba.plugin Cuba::Render
Cuba.settings[:render][:views] = "./app/views"

begin
metrics = Leafy::Metrics::Registry.new
health = Leafy::Health::Registry.new

Cuba.use( Leafy::Rack::Admin, metrics, health )
Cuba.use( Leafy::Rack::Metrics, metrics )
Cuba.use( Leafy::Rack::Health, health )
Cuba.use( Leafy::Rack::Ping )
Cuba.use( Leafy::Rack::ThreadDump )
Cuba.use( Leafy::Rack::Instrumented, Leafy::Instrumented::Instrumented.new( metrics, 'webapp' ) )
Cuba.use( Leafy::Rack::Instrumented, Leafy::Instrumented::CollectedInstrumented.new( metrics, 'collected' ) )

metrics.register_gauge('app.data_length' ) do
data.surname.length + data.firstname.length
end

health.register( 'app.health' ) do
if data.surname.length + data.firstname.length < 4
"stored names are too short"
end
end

Cuba.settings[:histogram] = metrics.register_histogram( 'app.name_length' )
end

Cuba.define do
on get do
on 'shutdown' do
java.lang.Runtime.runtime.exit 0
end

on 'app' do
p @person = data
render('person')
end

on 'person' do
p @person = data
content_type 'application/json'
res.write( { :surname => data.surname, :firstname => data.firstname }.to_json )
end
end

on env["REQUEST_METHOD"] == "PATCH", 'person' do
payload = JSON.parse request.body.read
data.send :"#{payload.keys.first}=", payload.values.first
Cuba.settings[:histogram].update( data.surname.length + data.firstname.length )
res.status 205
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= content %>
52 changes: 52 additions & 0 deletions maven/jruby/src/templates/hellowarld/app-cuba/views/person.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!DOCTYPE html>
<html>
<head>
<title><%= @person.firstname %> <%= @person.surname %></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>

$(document).ready(function(){

$("#reload").click(function(){
$.getJSON("person", function(result) {
$("title").text(result.firstname + " " + result.surname);
})
});

$("#firstname").last().click(function(){
$.ajax({ url:"person",
contentType:"application/json",
type:"PATCH",
data: '{"firstname":"' + $("#first").val() + '"}',
success:function(result){
}});
});

$("#surname").last().click(function(){
$.ajax({ url:"person",
contentType:"application/json",
type:"PATCH",
data: '{"surname":"' + $("#sur").val() + '"}',
success:function(result){
}});
});

});
</script>
</head>
<body>

<h1>person</h1>

<div>
Firstname <input type="text" size="30" id="first" value="<%=@person.firstname %>" /> <button id="firstname">update</button>
</div>

<div>
Surname <input type="text" size="30" id="sur" value="<%=@person.surname %>" /> <button id="surname">update</button>
</div>

<button id="reload">update title from server data</button>

</body>
</html>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
end
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class PersonController < ApplicationController

protect_from_forgery :only => :nothing

def shutdown
java.lang.Runtime.runtime.exit 0
end

def app
p @person = Myapp::Application.config.data
render('person/show')
end

def get
p @person = Myapp::Application.config.data
render json: { :surname => Myapp::Application.config.data.surname, :firstname => Myapp::Application.config.data.firstname }
end

def patch
payload = JSON.parse request.body.read
Myapp::Application.config.data.send :"#{payload.keys.first}=", payload.values.first
Myapp::Application.config.histogram.update( Myapp::Application.config.data.surname.length + Myapp::Application.config.data.firstname.length )

# did not find a way tp set status 205 and tell rails NOT to set a
# content-type so rack/lint does not bail out
render status: 200, nothing: true
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ApplicationHelper
end
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= yield %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!DOCTYPE html>
<html>
<head>
<title><%= @person.firstname %> <%= @person.surname %></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>

$(document).ready(function(){

$("#reload").click(function(){
$.getJSON("person", function(result) {
$("title").text(result.firstname + " " + result.surname);
})
});

$("#firstname").last().click(function(){
$.ajax({ url:"person",
contentType:"application/json",
type:"PATCH",
data: '{"firstname":"' + $("#first").val() + '"}',
success:function(result){
}});
});

$("#surname").last().click(function(){
$.ajax({ url:"person",
contentType:"application/json",
type:"PATCH",
data: '{"surname":"' + $("#sur").val() + '"}',
success:function(result){
}});
});

});
</script>
</head>
<body>

<h1>person</h1>

<div>
Firstname <input type="text" size="30" id="first" value="<%=@person.firstname %>" /> <button id="firstname">update</button>
</div>

<div>
Surname <input type="text" size="30" id="sur" value="<%=@person.surname %>" /> <button id="surname">update</button>
</div>

<button id="reload">update title from server data</button>

</body>
</html>
60 changes: 60 additions & 0 deletions maven/jruby/src/templates/hellowarld/app-sinatra/hellowarld.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
require 'sinatra'
require 'json'
require 'ostruct'
require 'leafy/metrics'
require 'leafy/health'
require 'leafy/instrumented/instrumented'
require 'leafy/instrumented/collected_instrumented'
require 'leafy/rack/admin'
require 'leafy/rack/instrumented'

data = OpenStruct.new
data.surname = 'meier'
data.firstname = 'christian'

configure do
metrics = Leafy::Metrics::Registry.new
health = Leafy::Health::Registry.new

use( Leafy::Rack::Admin, metrics, health )
use( Leafy::Rack::Metrics, metrics )
use( Leafy::Rack::Health, health )
use( Leafy::Rack::Ping )
use( Leafy::Rack::ThreadDump )
use( Leafy::Rack::Instrumented, Leafy::Instrumented::Instrumented.new( metrics, 'webapp' ) )
use( Leafy::Rack::Instrumented, Leafy::Instrumented::CollectedInstrumented.new( metrics, 'collected' ) )

metrics.register_gauge('app.data_length' ) do
data.surname.length + data.firstname.length
end

health.register( 'app.health' ) do
if data.surname.length + data.firstname.length < 4
"stored names are too short"
end
end

set :histogram, metrics.register_histogram( 'app.name_length' )
end

get '/shutdown' do
java.lang.Runtime.runtime.exit 0
end

get '/app' do
p @person = data
erb :person
end

get '/person' do
p @person = data
content_type 'application/json'
{ :surname => data.surname, :firstname => data.firstname }.to_json
end

patch '/person' do
payload = JSON.parse request.body.read
data.send :"#{payload.keys.first}=", payload.values.first
settings.histogram.update( data.surname.length + data.firstname.length )
status 205
end
52 changes: 52 additions & 0 deletions maven/jruby/src/templates/hellowarld/app-sinatra/views/person.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!DOCTYPE html>
<html>
<head>
<title><%= @person.firstname %> <%= @person.surname %></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>

$(document).ready(function(){

$("#reload").click(function(){
$.getJSON("person", function(result) {
$("title").text(result.firstname + " " + result.surname);
})
});

$("#firstname").last().click(function(){
$.ajax({ url:"person",
contentType:"application/json",
type:"PATCH",
data: '{"firstname":"' + $("#first").val() + '"}',
success:function(result){
}});
});

$("#surname").last().click(function(){
$.ajax({ url:"person",
contentType:"application/json",
type:"PATCH",
data: '{"surname":"' + $("#sur").val() + '"}',
success:function(result){
}});
});

});
</script>
</head>
<body>

<h1>person</h1>

<div>
Firstname <input type="text" size="30" id="first" value="<%=@person.firstname %>" /> <button id="firstname">update</button>
</div>

<div>
Surname <input type="text" size="30" id="sur" value="<%=@person.surname %>" /> <button id="surname">update</button>
</div>

<button id="reload">update title from server data</button>

</body>
</html>
3 changes: 3 additions & 0 deletions maven/jruby/src/templates/hellowarld/config-cuba.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require './app/hellowarld'

run Cuba
7 changes: 7 additions & 0 deletions maven/jruby/src/templates/hellowarld/config-rails4.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file is used by Rack-based servers to start the application.

# fix the env to development since production needs more setup
ENV['RAILS_ENV'] = 'development'

require ::File.expand_path('../config/environment', __FILE__)
run Rails.application
7 changes: 7 additions & 0 deletions maven/jruby/src/templates/hellowarld/config-sinatra.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'bundler/setup'

require './app/hellowarld'

map '/' do
run Sinatra::Application
end
61 changes: 61 additions & 0 deletions maven/jruby/src/templates/hellowarld/config/application.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
require File.expand_path('../boot', __FILE__)

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

require 'leafy/metrics'
require 'leafy/health'
require 'leafy/instrumented/instrumented'
require 'leafy/instrumented/collected_instrumented'
require 'leafy/rack/admin'
require 'leafy/rack/instrumented'


module Myapp
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.

# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'

# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de

# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true

metrics = Leafy::Metrics::Registry.new
health = Leafy::Health::Registry.new

config.middleware.use( Leafy::Rack::Admin, metrics, health )
config.middleware.use( Leafy::Rack::Metrics, metrics )
config.middleware.use( Leafy::Rack::Health, health )
config.middleware.use( Leafy::Rack::Ping )
config.middleware.use( Leafy::Rack::ThreadDump )
config.middleware.use( Leafy::Rack::Instrumented, Leafy::Instrumented::Instrumented.new( metrics, 'webapp' ) )
config.middleware.use( Leafy::Rack::Instrumented, Leafy::Instrumented::CollectedInstrumented.new( metrics, 'collected' ) )

config.data = OpenStruct.new
config.data.surname = 'meier'
config.data.firstname = 'christian'

metrics.register_gauge('app.data_length' ) do
Myapp::Application.config.data.surname.length + Myapp::Application.config.data.firstname.length
end

health.register( 'app.health' ) do
if Myapp::Application.config.data.surname.length + Myapp::Application.config.data.firstname.length < 4
"stored names are too short"
end
end

config.histogram = metrics.register_histogram( 'app.name_length' )
end
end
3 changes: 3 additions & 0 deletions maven/jruby/src/templates/hellowarld/config/boot.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)

require 'bundler/setup' # Set up gems listed in the Gemfile.
23 changes: 23 additions & 0 deletions maven/jruby/src/templates/hellowarld/config/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# SQLite version 3.x
# gem 'activerecord-jdbcsqlite3-adapter'
#
# Configure Using Gemfile
# gem 'activerecord-jdbcsqlite3-adapter'
#
default: &default
adapter: sqlite3

development:
<<: *default
database: <%= ENV_JAVA['user.dir'] %>/db/development.sqlite3

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3

production:
<<: *default
database: db/production.sqlite3
5 changes: 5 additions & 0 deletions maven/jruby/src/templates/hellowarld/config/environment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Load the Rails application.
require File.expand_path('../application', __FILE__)

# Initialize the Rails application.
Rails.application.initialize!
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false

# Do not eager load code on boot.
config.eager_load = false

# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false

# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false

# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log

# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load

# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true

# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true

# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true

# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

# Code is not reloaded between requests.
config.cache_classes = true

# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true

# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true

# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like
# NGINX, varnish or squid.
# config.action_dispatch.rack_cache = true

# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?

# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass

# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false

# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true

# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb

# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX

# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true

# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug

# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]

# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)

# Use a different cache store in production.
# config.cache_store = :mem_cache_store

# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'

# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false

# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true

# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify

# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new

# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end
42 changes: 42 additions & 0 deletions maven/jruby/src/templates/hellowarld/config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true

# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false

# Configure static file server for tests with Cache-Control for performance.
config.serve_static_files = true
config.static_cache_control = 'public, max-age=3600'

# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false

# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false

# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false

# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test

# Randomize the order test cases are executed.
config.active_support.test_order = :random

# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr

# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
end
11 changes: 11 additions & 0 deletions maven/jruby/src/templates/hellowarld/config/initializers/assets.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'

# Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_path

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails.application.config.assets.precompile += %w( search.js )
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Be sure to restart your server when you modify this file.

# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }

# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers!
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Be sure to restart your server when you modify this file.

Rails.application.config.action_dispatch.cookies_serializer = :json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Be sure to restart your server when you modify this file.

# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password]
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Be sure to restart your server when you modify this file.

# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end

# These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym 'RESTful'
# end
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Be sure to restart your server when you modify this file.

# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Be sure to restart your server when you modify this file.

Rails.application.config.session_store :cookie_store, key: '_myapp_session'
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Be sure to restart your server when you modify this file.

# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.

# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
end

# To enable root element in JSON for ActiveRecord objects.
# ActiveSupport.on_load(:active_record) do
# self.include_root_in_json = true
# end
23 changes: 23 additions & 0 deletions maven/jruby/src/templates/hellowarld/config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Files in the config/locales directory are used for internationalization
# and are automatically loaded by Rails. If you want to use locales other
# than English, add the necessary files in this directory.
#
# To use the locales, use `I18n.t`:
#
# I18n.t 'hello'
#
# In views, this is aliased to just `t`:
#
# <%= t('hello') %>
#
# To use a different locale, set it with `I18n.locale`:
#
# I18n.locale = :es
#
# This would use the information in config/locales/es.yml.
#
# To learn more, please read the Rails Internationalization guide
# available at http://guides.rubyonrails.org/i18n.html.

en:
hello: "Hello world"
62 changes: 62 additions & 0 deletions maven/jruby/src/templates/hellowarld/config/routes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
Rails.application.routes.draw do

get 'shutdown' => 'person#shutdown'
get 'app' => 'person#app'
get 'person' => 'person#get'
patch 'person' => 'person#patch'

# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".

# You can have the root of your site routed with "root"
# root 'welcome#index'

# Example of regular route:
# get 'products/:id' => 'catalog#view'

# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase

# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products

# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end

# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end

# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end

# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable

# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end
22 changes: 22 additions & 0 deletions maven/jruby/src/templates/hellowarld/config/secrets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Be sure to restart your server when you modify this file.

# Your secret key is used for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!

# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
# You can use `rake secret` to generate a secure secret key.

# Make sure the secrets in this file are kept private
# if you're sharing your code publicly.

development:
secret_key_base: 6d5e533901e719e8b1061913126ea32238dd203ef4bb0d7766fbcf6a386fb810e635038027bfc88c66d37c556ba3907522805c178b3251d2b67ce40b95b4d453

test:
secret_key_base: 6efc436756a14efdfce1a415541ee77c90305a713e427c2812e63a3fc07d42410f3a1a707596dafb138ac760f11da45bafaa410a25916f7e7cfeeab02b0585b4

# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
6 changes: 6 additions & 0 deletions maven/jruby/src/templates/hellowarld/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>dummy</groupId>
<artifactId>dummy</artifactId>
<version>0.0.0</version>
</project>
2 changes: 1 addition & 1 deletion maven/pom.rb
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
end

# module to profile map
map = { 'jruby' => [ :release, :main, :osgi, :j2ee, :snapshots ],
map = { 'jruby' => [ :apps, :release, :main, :osgi, :j2ee, :snapshots ],
'jruby-complete' => [ :release, :complete, :osgi, :'jruby_complete_jar_extended', :snapshots],
'jruby-jars' => [ :release, :'jruby-jars', :snapshots ],
'jruby-dist' => [ :release, :dist, :snapshots ]
8 changes: 8 additions & 0 deletions pom.rb
Original file line number Diff line number Diff line change
@@ -237,6 +237,14 @@
end
end

profile 'apps' do
modules ['maven']

build do
default_goal 'install'
end
end

profile 'jruby_complete_jar_extended' do

modules [ 'test', 'maven' ]
9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -777,6 +777,15 @@ DO NOT MODIFIY - GENERATED CODE
<invoker.skip>false</invoker.skip>
</properties>
</profile>
<profile>
<id>apps</id>
<build>
<defaultGoal>install</defaultGoal>
</build>
<modules>
<module>maven</module>
</modules>
</profile>
<profile>
<id>jruby_complete_jar_extended</id>
<build>