ulbrich-jruby-enginize 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -72,18 +72,18 @@ an unstable version and don't want to risk your users getting exceptions.
72
72
 
73
73
  You can try the new version by opening e.g.
74
74
 
75
- http://3.latest.foobar.appspot.com
75
+ <tt>http://3.latest.foobar.appspot.com</tt>
76
76
 
77
77
  and replacing "3" with the version number you want to run.
78
78
 
79
79
  Switch the application to the new version as default (stable version) by
80
80
  opening
81
81
 
82
- http://appengine.google.com/deployment?&app_id=foobar
82
+ <tt>http://appengine.google.com/deployment?&app_id=foobar</tt>
83
83
 
84
84
  and setting a new default available at
85
85
 
86
- http://foobar.appspot.com
86
+ <tt>http://foobar.appspot.com</tt>
87
87
 
88
88
  A small README with these and a few more application specific hints is
89
89
  generated along with the source code. Have fun.
@@ -5,11 +5,12 @@ something more meaningful... ;-)
5
5
 
6
6
  GOOGLE APPENGINE DEPLOYMENT
7
7
 
8
- As a basic requirement, copy and split the JRuby-JAR calling
9
-
10
- jrake jruby:splitjars
11
-
12
- once and after each upgrade to a new version of JRuby.
8
+ !!Attention: As a basic requirement, the JRuby archive "jruby-complete.jar"
9
+ has to be placed in the "lib" directory of your app and this is way to large
10
+ to include it in the generator. If you have this file on your disk, copy it
11
+ over and be sure to rename it to "jruby-complete.jar". If missing, the
12
+ deployment will download the file for you. Expect a 10 MB download (only done
13
+ once).
13
14
 
14
15
  Deploy the application with
15
16
 
@@ -2,10 +2,30 @@ require 'rake'
2
2
  require 'rake/testtask'
3
3
  require 'rake/rdoctask'
4
4
 
5
+ require 'net/http'
6
+
5
7
  Dir[File.join(File.dirname(__FILE__), 'lib', 'tasks', '*.rake')].each do |ext|
6
8
  load ext
7
9
  end
8
10
 
11
+ # Helper for retrieving HTML files. Only used to check or trigger things so
12
+ # no highclass implementation...
13
+
14
+ def fetch(uri, limit = 10)
15
+ raise ArgumentError, 'HTTP redirect too deep' if limit == 0
16
+
17
+ response = Net::HTTP.get_response(URI.parse(uri))
18
+
19
+ case response
20
+ when Net::HTTPSuccess then
21
+ return response
22
+ when Net::HTTPRedirection then
23
+ return fetch(response['location'], limit - 1)
24
+ else
25
+ return response.error!
26
+ end
27
+ end
28
+
9
29
  desc 'Display some help and the README'
10
30
  task :help do
11
31
  puts 'Call "jruby -S rake --tasks" to learn what tasks are available...'
@@ -16,24 +36,45 @@ end
16
36
  task :default => [:help]
17
37
 
18
38
  namespace :jruby do
19
- desc 'Split the way too large JRuby JAR into two smaller files'
20
- task :splitjars do
21
- puts 'Split the way too large JRuby JAR into two smaller files.'
22
- libdir = File.join(File.dirname(__FILE__), 'lib')
23
- puts `#{libdir}/split-jruby.sh`
39
+ desc 'Download current "jruby-complete.jar" from dist.codehaus.org.'
40
+ task :download do
41
+ puts 'Download current "jruby-complete.jar" from dist.codehaus.org.'
42
+
43
+ begin
44
+ baseurl = 'http://dist.codehaus.org/jruby/current'
45
+ directory = fetch(baseurl)
46
+
47
+ if directory.kind_of? Net::HTTPOK and
48
+ (match = directory.body.match(/.*"(jruby-complete-[^"]*\.jar)".*/)) and
49
+ match.length == 2
50
+ then
51
+ `(curl -o lib/jruby-complete.jar "#{baseurl}/#{match[1]}") 1>&2`
52
+ raise Errno::ENOENT if $? != 0
53
+ else
54
+ raise Errno::ENOENT
55
+ end
56
+ rescue Exception
57
+ puts '!!Could not download "jruby-complete.jar". Retry or download manually.'
58
+ exit(1)
59
+ end
24
60
  end
25
61
 
26
- desc 'Runs the splitjars task if splitted files not already exist'
27
- task :check4jars do
28
- file1 = File.join(File.dirname(__FILE__), 'lib', 'jruby-core.jar')
29
- file2 = File.join(File.dirname(__FILE__), 'lib', 'ruby-stdlib.jar')
62
+ desc 'Run the jruby:download task if the JRuby JAR is missing.'
63
+ task :check4jar do
64
+ file = File.join(File.dirname(__FILE__), 'lib', 'jruby-complete.jar')
65
+
66
+ puts 'Run the jruby:download task if the JRuby JAR is missing.'
30
67
 
31
68
  begin
32
- File.stat(file1)
33
- File.stat(file2)
69
+ File.stat(file)
70
+
71
+ `(unzip -l #{file}) 2>&1`
72
+ raise Errno::ENOENT if $? != 0
73
+
74
+ puts 'JRuby JAR already exists.'
34
75
  rescue Errno::ENOENT
35
- puts 'Need to copy and split JAR files. Generating them on the fly now...'
36
- Rake::Task['jruby:splitjars'].invoke
76
+ puts 'Need to download JRuby JAR. Downloading now...'
77
+ Rake::Task['jruby:download'].invoke
37
78
  end
38
79
  end
39
80
  end
@@ -42,27 +83,27 @@ namespace :appengine do
42
83
  desc 'Create the WAR file for deployment'
43
84
  task :war do
44
85
  puts 'Create the WAR file for deployment.'
45
- puts `jruby -S warble`
86
+ `(jruby -S warble) 1>&2`
46
87
  end
47
88
 
48
89
  desc 'Upload the new application code'
49
90
  task :upload do
50
91
  puts 'Upload the new application code (this may take a while).'
51
- puts `appcfg.sh --enable_jar_splitting --email={{email}} update tmp/war`
92
+ `(appcfg.sh --enable_jar_splitting --email={{email}} update tmp/war) 1>&2`
52
93
  end
53
94
 
54
95
  desc 'Roll back a blocked and halfway broken deploy'
55
96
  task :rollback do
56
97
  puts 'Roll back a blocked and halfway broken deploy.'
57
- puts `appcfg.sh --enable_jar_splitting rollback tmp/war`
98
+ `(appcfg.sh --enable_jar_splitting rollback tmp/war) 1>&2`
58
99
  end
59
100
 
60
101
  desc 'Remove temp stuff'
61
102
  task :clean do
62
103
  puts 'Remove temp stuff.'
63
- puts `rm -rf tmp slingyard.war`
104
+ `rm -rf tmp {{name}}.war`
64
105
  end
65
106
 
66
- desc 'Deploy the application (generating WAR plus uploading files)'
67
- task :deploy => ['jruby:check4jars', :war, :upload]
107
+ desc 'Deploy the application (generating WAR and uploading files)'
108
+ task :deploy => ['jruby:check4jar', :war, :upload]
68
109
  end
@@ -32,17 +32,11 @@ Warbler::Config.new do |config|
32
32
 
33
33
  # Gems to be included. You need to tell Warbler which gems your application needs
34
34
  # so that they can be packaged in the war file.
35
- # The Rails gems are included by default unless the vendor/rails directory is present.
36
- # config.gems += ["activerecord-jdbcmysql-adapter", "jruby-openssl"]
37
- # config.gems << "tzinfo"
38
35
  config.gems = ['sinatra', 'haml']
39
36
 
40
- # Uncomment this if you don't want to package rails gem.
41
- # config.gems -= ["rails"]
42
-
43
37
  # The most recent versions of gems are used.
44
38
  # You can specify versions of gems by using a hash assignment:
45
- # config.gems["rails"] = "2.0.2"
39
+ # config.gems["foo"] = "2.0.2"
46
40
 
47
41
  # You can also use regexps or Gem::Dependency objects for flexibility or
48
42
  # fine-grained control.
@@ -59,19 +53,17 @@ Warbler::Config.new do |config|
59
53
  # Pathmaps for controlling how public HTML files are copied into the .war
60
54
  # config.pathmaps.public_html = ["%{public/,}p"]
61
55
 
62
- # Name of the war file (without the .war) -- defaults to the basename
63
- # of RAILS_ROOT
56
+ # Name of the war file (without the .war)
64
57
  config.war_name = "{{name}}"
65
58
 
66
59
  # Name of the MANIFEST.MF template for the war file. Defaults to the
67
60
  # MANIFEST.MF normally generated by `jar cf`.
68
61
  # config.manifest_file = "config/MANIFEST.MF"
69
62
 
70
- # Value of RAILS_ENV for the webapp -- default as shown below
71
- # config.webxml.rails.env = ENV['RAILS_ENV'] || 'production'
63
+ # Value of environment variables
64
+ # config.webxml.foo.env = ENV['FOO_ENV']
72
65
 
73
- # Application booter to use, one of :rack, :rails, or :merb. (Default :rails)
74
- # config.webxml.booter = :rack
66
+ # Application booter to use, one of :rack, :rails, or :merb
75
67
  config.webxml.booter = :rack
76
68
 
77
69
  # When using the :rack booter, "Rackup" script to use.
@@ -80,7 +72,7 @@ Warbler::Config.new do |config|
80
72
  # config.webxml.rackup = %{require './lib/demo'; run Rack::Adapter::Camping.new(Demo)}
81
73
  # config.webxml.rackup = require 'cgi' && CGI::escapeHTML(File.read("config.ru"))
82
74
 
83
- # Control the pool of Rails runtimes. Leaving unspecified means
75
+ # Control the pool of runtimes. Leaving unspecified means
84
76
  # the pool will grow as needed to service requests. It is recommended
85
77
  # that you fix these values when running a production server!
86
78
  # config.webxml.jruby.min.runtimes = 2
@@ -89,7 +81,5 @@ Warbler::Config.new do |config|
89
81
  config.webxml.jruby.max.runtimes = 1
90
82
  config.webxml.jruby.init.serial = true
91
83
 
92
- # JNDI data source name
93
- # config.webxml.jndi = 'jdbc/rails'
94
84
  config.java_libs = []
95
85
  end
@@ -2,6 +2,6 @@ namespace :sinatra do
2
2
  desc 'Start a local test server on part 4567'
3
3
  task :run do
4
4
  puts 'Start a local test server on part 4567'
5
- puts `jruby -S app.rb`
5
+ `(jruby -S app.rb) 1>&2`
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ulbrich-jruby-enginize
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.3"
4
+ version: "0.4"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Ulbrich
@@ -36,7 +36,6 @@ files:
36
36
  - templates/shared/README
37
37
  - templates/shared/Rakefile
38
38
  - templates/shared/public/images/appengine_logo.png
39
- - templates/shared/lib/split-jruby.sh
40
39
  - templates/shared/lib/jruby-rack-0.9.4.jar
41
40
  - templates/shared/appengine-web.xml
42
41
  - README.rdoc
@@ -1,67 +0,0 @@
1
- #!/bin/sh
2
- # Utility script for splitting the JRuby JAR into two smaller JAR files. This
3
- # is a workaround for a limitation of the JAR size in Google AppEngine.
4
- #
5
- # The code for this script has been taken from hints and links found at
6
- # http://jruby-rack.appspot.com.
7
-
8
- SCRIPTHOME=`dirname $0`
9
- JRUBY=`which jruby`
10
-
11
- if [ ! -x "$JRUBY" ]; then
12
- echo "!!Missing jruby executable. Please check installation." > /dev/stderr
13
- exit 1
14
- fi
15
-
16
- # See where the jruby binary is installed and find the JRuby JAR from there.
17
-
18
- PREFIX=`dirname \`dirname $JRUBY\``
19
- JARFILE="$PREFIX/share/java/jruby/lib/jruby-complete.jar"
20
-
21
- if [ ! -f "$JARFILE" ]; then
22
- PREFIX=`dirname \`dirname $JRUBY\``
23
- JARFILE="$PREFIX/lib/jruby-complete.jar"
24
- fi
25
-
26
- if [ ! -f "$JARFILE" ]; then
27
- echo "!!Missing JRuby JAR. Please check installation." > /dev/stderr
28
- exit 1
29
- fi
30
-
31
- echo "Using $JARFILE for splitting"
32
- echo "and assembling a AppEngine savvy version of the JRuby JAR in the lib "
33
- echo "directory."
34
-
35
- cd $SCRIPTHOME
36
-
37
- rm -rf jruby-core.jar
38
- rm -rf ruby-stdlib.jar
39
- rm -rf tmp_unpack
40
-
41
- mkdir -p tmp_unpack
42
- cd tmp_unpack
43
-
44
- jar xf $JARFILE
45
-
46
- cd ..
47
-
48
- mkdir -p jruby-core
49
-
50
- mv tmp_unpack/org jruby-core
51
- mv tmp_unpack/com jruby-core
52
- mv tmp_unpack/jline jruby-core
53
- mv tmp_unpack/jay jruby-core
54
- mv tmp_unpack/jruby jruby-core
55
-
56
- cd jruby-core
57
-
58
- jar cf ../jruby-core.jar .
59
-
60
- cd ../tmp_unpack
61
-
62
- jar cf ../ruby-stdlib.jar .
63
-
64
- cd ..
65
-
66
- rm -rf jruby-core
67
- rm -rf tmp_unpack