appengine-tools 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -3
- data/lib/appengine-tools/boot.rb +3 -3
- data/lib/appengine-tools/bundler.rb +52 -15
- data/lib/appengine-tools/dev_appserver.rb +2 -4
- data/lib/appengine-tools/web-xml.rb +3 -3
- data/spec/web.xml +11 -8
- metadata +3 -3
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ require 'date'
|
|
5
5
|
require 'spec/rake/spectask'
|
6
6
|
|
7
7
|
GEM = "appengine-tools"
|
8
|
-
GEM_VERSION = "0.0.
|
8
|
+
GEM_VERSION = "0.0.2"
|
9
9
|
AUTHOR = "Ryan Brown"
|
10
10
|
EMAIL = "ribrdb@gmail.com"
|
11
11
|
HOMEPAGE = "http://code.google.com/p/appengine-jruby"
|
@@ -28,7 +28,7 @@ spec = Gem::Specification.new do |s|
|
|
28
28
|
s.executables = [ 'appcfg.rb', 'dev_appserver.rb' ]
|
29
29
|
s.add_dependency('appengine-rack')
|
30
30
|
s.add_dependency('appengine-sdk')
|
31
|
-
s.add_dependency('jruby-
|
31
|
+
s.add_dependency('appengine-jruby-jars')
|
32
32
|
end
|
33
33
|
|
34
34
|
task :default => :spec
|
@@ -54,4 +54,4 @@ task :make_spec do
|
|
54
54
|
File.open("#{GEM}.gemspec", "w") do |file|
|
55
55
|
file.puts spec.to_ruby
|
56
56
|
end
|
57
|
-
end
|
57
|
+
end
|
data/lib/appengine-tools/boot.rb
CHANGED
@@ -23,11 +23,11 @@ module AppEngine
|
|
23
23
|
def boot_jruby(root=nil)
|
24
24
|
unless defined?(JRUBY_VERSION)
|
25
25
|
require 'rubygems'
|
26
|
-
require 'jruby-
|
26
|
+
require 'appengine-jruby-jars'
|
27
27
|
|
28
28
|
jars = [
|
29
|
-
|
30
|
-
|
29
|
+
AppEngine::JRubyJars.jruby_jar,
|
30
|
+
AppEngine::JRubyJars.rubygems_jar,
|
31
31
|
AppEngine::SDK::TOOLS_JAR,
|
32
32
|
]
|
33
33
|
|
@@ -18,6 +18,8 @@
|
|
18
18
|
require 'appengine-rack'
|
19
19
|
require 'appengine-tools/web-xml'
|
20
20
|
require 'appengine-tools/xml-formatter'
|
21
|
+
require 'fileutils'
|
22
|
+
require 'yaml'
|
21
23
|
|
22
24
|
module AppEngine
|
23
25
|
module Admin
|
@@ -41,6 +43,10 @@ module AppEngine
|
|
41
43
|
path('WEB-INF', 'lib')
|
42
44
|
end
|
43
45
|
|
46
|
+
def generation_dir
|
47
|
+
path('WEB-INF', 'appengine-generated')
|
48
|
+
end
|
49
|
+
|
44
50
|
def config_ru
|
45
51
|
path('config.ru')
|
46
52
|
end
|
@@ -53,10 +59,18 @@ module AppEngine
|
|
53
59
|
path('WEB-INF', 'appengine-web.xml')
|
54
60
|
end
|
55
61
|
|
62
|
+
def build_status
|
63
|
+
path('WEB-INF', 'appengine-generated', 'build_status.yaml')
|
64
|
+
end
|
65
|
+
|
56
66
|
def public_root
|
57
67
|
path(AppEngine::Rack.app.public_root) if AppEngine::Rack.app.public_root
|
58
68
|
end
|
59
69
|
|
70
|
+
def persistent_path_token
|
71
|
+
path(public_root, '__preserve__')
|
72
|
+
end
|
73
|
+
|
60
74
|
def rack_app
|
61
75
|
AppEngine::Rack.app
|
62
76
|
end
|
@@ -64,14 +78,14 @@ module AppEngine
|
|
64
78
|
end
|
65
79
|
|
66
80
|
class AppBundler
|
67
|
-
EXISTING_JRUBY = /^jruby
|
81
|
+
EXISTING_JRUBY = /^appengine-jruby-.*jar$/
|
68
82
|
EXISTING_RACK = /jruby-rack.*jar$/
|
69
83
|
EXISTING_APIS = /^appengine-api.*jar$/
|
70
84
|
JRUBY_RACK = 'jruby-rack-0.9.4.jar'
|
71
|
-
JRUBY_RACK_URL = 'http://kenai.com/projects/jruby-rack/
|
72
|
-
|
85
|
+
JRUBY_RACK_URL = 'http://kenai.com/projects/jruby-rack/' +
|
86
|
+
"downloads/download/#{JRUBY_RACK}"
|
73
87
|
RACKUP = %q{Dir.chdir('..') if Dir.pwd =~ /WEB-INF$/;} +
|
74
|
-
|
88
|
+
%q{eval IO.read('config.ru'), nil, 'config.ru', 1}
|
75
89
|
|
76
90
|
def initialize(root_path)
|
77
91
|
@app = Application.new(root_path)
|
@@ -79,7 +93,6 @@ module AppEngine
|
|
79
93
|
|
80
94
|
def bundle
|
81
95
|
create_webinf
|
82
|
-
create_public
|
83
96
|
copy_jruby
|
84
97
|
copy_rack
|
85
98
|
copy_sdk
|
@@ -93,13 +106,14 @@ module AppEngine
|
|
93
106
|
def create_webinf
|
94
107
|
Dir.mkdir(app.webinf) unless File.exists?(app.webinf)
|
95
108
|
Dir.mkdir(app.webinf_lib) unless File.exists?(app.webinf_lib)
|
109
|
+
Dir.mkdir(app.generation_dir) unless File.exists?(app.generation_dir)
|
96
110
|
end
|
97
111
|
|
98
112
|
def create_public
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
113
|
+
return if app.public_root.nil?
|
114
|
+
Dir.mkdir(app.public_root) unless File.exists?(app.public_root)
|
115
|
+
token = app.persistent_path_token
|
116
|
+
FileUtils.touch(token) unless File.exists?(token)
|
103
117
|
end
|
104
118
|
|
105
119
|
def convert_config_ru
|
@@ -107,25 +121,28 @@ module AppEngine
|
|
107
121
|
if !File.exists?(app.config_ru)
|
108
122
|
if File.exists?(app.web_xml)
|
109
123
|
unless File.exists?(app.aeweb_xml)
|
110
|
-
puts "Error: you either need a #{app.config_ru} or "
|
124
|
+
puts "!! Error: you either need a #{app.config_ru} or "
|
111
125
|
puts " #{app.aeweb_xml}."
|
112
126
|
exit 1
|
113
127
|
end
|
114
128
|
else
|
115
129
|
# TODO auto generate a config.ru
|
116
|
-
puts "Error: you need to create #{app.config_ru}."
|
130
|
+
puts "!! Error: you need to create #{app.config_ru}."
|
117
131
|
exit 1
|
118
132
|
end
|
119
133
|
else
|
120
134
|
generate_xml
|
135
|
+
create_public
|
121
136
|
end
|
122
137
|
end
|
123
138
|
|
124
139
|
def copy_jruby
|
125
140
|
current_jruby = find_jars(EXISTING_JRUBY)
|
126
141
|
if current_jruby.empty?
|
127
|
-
|
128
|
-
|
142
|
+
puts "=> Installing JRuby"
|
143
|
+
require 'appengine-jruby-jars'
|
144
|
+
FileUtils.cp([AppEngine::JRubyJars.jruby_jar,
|
145
|
+
AppEngine::JRubyJars.rubygems_jar],
|
129
146
|
app.webinf_lib)
|
130
147
|
end
|
131
148
|
# TODO else warn if out of date
|
@@ -135,8 +152,8 @@ module AppEngine
|
|
135
152
|
current_rack = find_jars(EXISTING_RACK)
|
136
153
|
if current_rack.empty?
|
137
154
|
# TODO cache this somewhere
|
155
|
+
puts "=> Retrieving jruby-rack"
|
138
156
|
require 'open-uri'
|
139
|
-
puts 'Downloading jruby-rack...'
|
140
157
|
open(JRUBY_RACK_URL) do |src|
|
141
158
|
open(File.join(app.webinf_lib, JRUBY_RACK), 'wb') do |dest|
|
142
159
|
dest.write(src.read)
|
@@ -148,6 +165,7 @@ module AppEngine
|
|
148
165
|
def copy_sdk
|
149
166
|
current_apis = find_jars(EXISTING_APIS)
|
150
167
|
if current_apis.empty?
|
168
|
+
puts "=> Installing appengine-sdk"
|
151
169
|
require 'appengine-sdk'
|
152
170
|
jars = Dir.glob(
|
153
171
|
"#{AppEngine::SDK::SDK_ROOT}/lib/user/appengine-api*.jar")
|
@@ -161,8 +179,22 @@ module AppEngine
|
|
161
179
|
def find_jars(regex)
|
162
180
|
Dir.entries(app.webinf_lib).grep(regex) rescue []
|
163
181
|
end
|
164
|
-
|
182
|
+
|
183
|
+
def valid_build
|
184
|
+
return false unless File.exists? app.build_status
|
185
|
+
return false unless File.exists? app.web_xml
|
186
|
+
return false unless File.exists? app.aeweb_xml
|
187
|
+
yaml = YAML.load_file app.build_status
|
188
|
+
return false unless yaml.is_a? Hash
|
189
|
+
return false unless File.stat(app.config_ru).mtime.eql? yaml[:config_ru]
|
190
|
+
return false unless File.stat(app.web_xml).mtime.eql? yaml[:web_xml]
|
191
|
+
return false unless File.stat(app.aeweb_xml).mtime.eql? yaml[:aeweb_xml]
|
192
|
+
true
|
193
|
+
end
|
194
|
+
|
165
195
|
def generate_xml
|
196
|
+
return if valid_build
|
197
|
+
puts "=> Generating configuration files"
|
166
198
|
Dir.glob("#{app.webinf_lib}/*.jar").each do |path|
|
167
199
|
$: << path
|
168
200
|
end
|
@@ -185,6 +217,11 @@ module AppEngine
|
|
185
217
|
xml = AppEngine::Rack::XmlFormatter.format(app.rack_app.to_xml)
|
186
218
|
aeweb.write(xml)
|
187
219
|
end
|
220
|
+
yaml = {
|
221
|
+
:config_ru => File.stat(app.config_ru).mtime,
|
222
|
+
:aeweb_xml => File.stat(app.aeweb_xml).mtime,
|
223
|
+
:web_xml => File.stat(app.web_xml).mtime }
|
224
|
+
open(app.build_status, 'w') { |f| YAML.dump(yaml, f) }
|
188
225
|
end
|
189
226
|
end
|
190
227
|
|
@@ -29,8 +29,6 @@ module AppEngine
|
|
29
29
|
unless ENV['BOOTING_DEVAPPSERVER']
|
30
30
|
puts "=> Booting DevAppServer"
|
31
31
|
puts "=> Press Ctrl-C to shutdown server"
|
32
|
-
print "=> "
|
33
|
-
$stdout.flush
|
34
32
|
ENV['BOOTING_DEVAPPSERVER'] = 'true'
|
35
33
|
end
|
36
34
|
AppEngine::Admin.bundle_app(path)
|
@@ -47,8 +45,8 @@ module AppEngine
|
|
47
45
|
def get_jruby_home(path)
|
48
46
|
return unless path
|
49
47
|
Dir.chdir("#{path}/WEB-INF/lib") do
|
50
|
-
jars = Dir.glob("jruby
|
51
|
-
/^jruby
|
48
|
+
jars = Dir.glob("appengine-jruby-*.jar").grep(
|
49
|
+
/^appengine-jruby-\d+[.]\d+[.]\d+[.]jar$/)
|
52
50
|
if !jars.empty?
|
53
51
|
jar = File.expand_path(jars[0])
|
54
52
|
return "file:/#{jar}!/META-INF/jruby.home"
|
@@ -32,8 +32,8 @@ class WebXmlBuilder < Rack::Builder
|
|
32
32
|
|
33
33
|
def add_jruby_rack_defaults(rackup)
|
34
34
|
use JavaContextParams, :rackup => rackup
|
35
|
-
|
36
|
-
|
35
|
+
use JavaServletFilter, 'org.jruby.rack.RackFilter',
|
36
|
+
{ :name => 'RackFilter', :wildcard => true }
|
37
37
|
use JavaContextListener, 'org.jruby.rack.RackServletContextListener'
|
38
38
|
end
|
39
39
|
|
@@ -83,4 +83,4 @@ class WebXmlBuilder < Rack::Builder
|
|
83
83
|
yield path, value
|
84
84
|
end
|
85
85
|
end
|
86
|
-
end
|
86
|
+
end
|
data/spec/web.xml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
<web-app version='2.5' xmlns='http://java.sun.com/xml/ns/javaee'>
|
2
2
|
<security-constraint>
|
3
3
|
<web-resource-collection>
|
4
|
+
<url-pattern>/private</url-pattern>
|
4
5
|
<url-pattern>/private/*</url-pattern>
|
5
6
|
</web-resource-collection>
|
6
7
|
<auth-constraint>
|
@@ -9,6 +10,7 @@
|
|
9
10
|
</security-constraint>
|
10
11
|
<security-constraint>
|
11
12
|
<web-resource-collection>
|
13
|
+
<url-pattern>/admin2</url-pattern>
|
12
14
|
<url-pattern>/admin2/*</url-pattern>
|
13
15
|
</web-resource-collection>
|
14
16
|
<auth-constraint>
|
@@ -17,6 +19,7 @@
|
|
17
19
|
</security-constraint>
|
18
20
|
<security-constraint>
|
19
21
|
<web-resource-collection>
|
22
|
+
<url-pattern>/secure</url-pattern>
|
20
23
|
<url-pattern>/secure/*</url-pattern>
|
21
24
|
</web-resource-collection>
|
22
25
|
<user-data-constraint>
|
@@ -67,14 +70,14 @@
|
|
67
70
|
<param-name>rackup</param-name>
|
68
71
|
<param-value>rackup</param-value>
|
69
72
|
</context-param>
|
70
|
-
<
|
71
|
-
<
|
72
|
-
<
|
73
|
-
</
|
74
|
-
<
|
75
|
-
<
|
76
|
-
<url-pattern
|
77
|
-
</
|
73
|
+
<filter>
|
74
|
+
<filter-name>RackFilter</filter-name>
|
75
|
+
<filter-class>org.jruby.rack.RackFilter</filter-class>
|
76
|
+
</filter>
|
77
|
+
<filter-mapping>
|
78
|
+
<filter-name>RackFilter</filter-name>
|
79
|
+
<url-pattern>/*</url-pattern>
|
80
|
+
</filter-mapping>
|
78
81
|
<listener>
|
79
82
|
<listener-class>org.jruby.rack.RackServletContextListener</listener-class>
|
80
83
|
</listener>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appengine-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Brown
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-08-13 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: "0"
|
34
34
|
version:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
|
-
name: jruby-
|
36
|
+
name: appengine-jruby-jars
|
37
37
|
type: :runtime
|
38
38
|
version_requirement:
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|