lib/appengine-tools/appcfg.rb in appengine-tools-0.0.14 vs lib/appengine-tools/appcfg.rb in appengine-tools-0.0.15.pre
- old
+ new
@@ -20,65 +20,10 @@
require 'appengine-tools/update_check'
require 'yaml'
module AppEngine
module Admin
- if defined? Java
- AppCfg = AppEngine::SDK.load_appcfg
- import Java.ComGoogleAppengineToolsAdmin.AppAdminFactory
- import Java.ComGoogleAppengineToolsUtil.Logging
-
- $CLASSPATH << File.dirname(__FILE__)
- import Java.ComGoogleAppengineJruby.AppVersionUploadDelegate
- import Java.ComGoogleAppengineJruby.JRubyAppVersionUpload
-
- class UploadDelegate
- include AppVersionUploadDelegate
-
- def index_yaml(app)
- indexes = merge_indexes(app)
- if indexes
- return indexes.to_yaml
- end
- ''
- end
-
- def cron_yaml(app)
- cron = File.join(app.path, 'cron.yaml')
- if File.exists?(cron)
- return IO.read(cron)
- end
- end
-
- def queue_yaml(app)
- queue = File.join(app.path, 'queue.yaml')
- if File.exists?(queue)
- return IO.read(queue)
- end
- end
-
- def merge_indexes(app)
- if app.indexes_xml
- indexes = YAML.load(app.indexes_xml.to_yaml)['indexes']
- end
- indexes ||= []
- index_yaml = File.join(app.path, 'index.yaml')
- if File.exist?(index_yaml)
- manual_indexes = YAML.load_file(index_yaml)['indexes'] || []
- manual_indexes.each do |index|
- indexes << index unless indexes.include?(index)
- end
- end
- if indexes.size > 0
- {'indexes' => indexes}
- else
- nil
- end
- end
- end
- end
-
class JRubyAppCfg
NO_XML_COMMANDS = %w{version}
RUBY_COMMANDS = %w{gem bundle help run generate_app}
COMMAND_SUMMARY = <<EOF
run: run jruby in your application environment.
@@ -93,26 +38,19 @@
return
end
if command && !NO_XML_COMMANDS.include?(command)
path = parsed_args[0]
AppEngine::Admin.bundle_app(path)
- AppEngine::Development.boot_jruby
updater = AppEngine::Admin::UpdateCheck.new(path)
updater.nag
- else
- AppEngine::Development.boot_jruby
end
puts "=> Running AppCfg"
run_appcfg(args)
end
-
+
def run_appcfg(args)
- JRubyAppVersionUpload.set_delegate(UploadDelegate.new)
- factory = AppAdminFactory.new
- factory.setAppVersionUploadClass(JRubyAppVersionUpload.java_class)
- Logging.initializeLogging
- AppCfg.new(factory, args.to_java(java.lang.String))
+ exec *(appcfg_command + args)
end
def generate_app(*args)
if args and args.size > 0
appdir = args.pop
@@ -156,26 +94,26 @@
end
def gem(*args)
gem_help
end
-
+
def gem_help
help = <<EOF
Sorry, the 'appcfg.rb gem' option is deprecated.
Simply update the 'Gemfile' and run 'appcfg.rb bundle .' instead.
EOF
puts help
end
-
+
def run(*args)
AppEngine::Admin.bundle_deps('.')
AppEngine::Development.boot_app('.', args)
end
-
+
def run_help
help = <<EOF
#{$0} run [ruby args]
Starts the jruby interpreter within your application's environment.
@@ -183,22 +121,27 @@
Must be run from the application directory, after running bundle.
EOF
end
+ def appcfg_command
+ plugin_jar = File.join(File.dirname(__FILE__), 'app_yaml.jar')
+ command = %W(java -cp #{AppEngine::SDK::TOOLS_JAR})
+ command << "-Dcom.google.appengine.plugin.path=#{plugin_jar}"
+ command << 'com.google.appengine.tools.admin.AppCfg'
+ end
+
def help(command=nil)
puts
if command != 'help' && RUBY_COMMANDS.include?(command)
puts send("#{command}_help")
else
- java_args = %W(java -cp #{AppEngine::SDK::TOOLS_JAR})
- java_args << 'com.google.appengine.tools.admin.AppCfg'
- java_args << 'help'
+ java_args = appcfg_command << 'help'
java_args << command if command
print_help(%x{#{java_args.map{|x| x.inspect}.join(' ')}}, !command)
end
end
-
+
def print_help(help, summary)
help.gsub!('AppCfg', $0)
count = 0
help.each_line do |line|
line.chomp!