Change droidgap create to not use 'grep' and have better error messages

This commit is contained in:
davejohnson 2010-10-11 20:30:54 +08:00 committed by Bryce Curtis
parent 3fd372f9d1
commit 5164464d28
2 changed files with 12 additions and 4 deletions

View File

@ -49,8 +49,16 @@ class Classic
# runs android create project # runs android create project
# TODO need to allow more flexible SDK targetting via config.xml # TODO need to allow more flexible SDK targetting via config.xml
def create_android def create_android
target_id = `android list targets | grep id:`.split("\n").last.match(/\d+/).to_a.first IO.popen("android list targets") { |f|
targets = f.readlines(nil)[0].scan(/id\:.*$/)
if (targets.length > 0)
target_id = targets.last.match(/\d+/).to_a.first
`android create project -t #{ target_id } -k #{ @pkg } -a #{ @name } -n #{ @name } -p #{ @path }` `android create project -t #{ target_id } -k #{ @pkg } -a #{ @name } -n #{ @name } -p #{ @path }`
else
puts "No Android targets found. Please run 'android' and install at least one SDK package."
puts "If that makes no sense then you need to go read the Android SDK documentation."
end
}
end end
# copies the project/www folder into tmp/android/www # copies the project/www folder into tmp/android/www

View File

@ -29,8 +29,8 @@ class Create < Classic
@content = 'index.html' @content = 'index.html'
# stop executation on errors # stop executation on errors
raise 'No index.html found!' unless File.exists? File.join(path, 'index.html') raise 'Expected index.html in the following folder #{ path }.\nThe path is expected to be the directory droidgap create is run from or specified as a command line arg like droidgap create my_path.' unless File.exists? File.join(path, 'index.html')
raise 'Could not find android in your path!' if @android_sdk_path.empty? raise 'Could not find android in your PATH!' if @android_sdk_path.empty?
end end
# reads in a config.xml file # reads in a config.xml file