Created
May 15, 2014 05:42
-
-
Save gin0606/0d771faee1d9b0b3d9a7 to your computer and use it in GitHub Desktop.
build-toolsのバージョン上がるたびにファイル書き換えるの面倒で書いたけど、みんなどうしてるの
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AndroidSDKPackage | |
def initialize line | |
id_name = line[0].split('or').map { |l| l.strip } | |
@id = id_name[0].split(':')[1].strip | |
@name = id_name[1].delete('"') | |
@type = line[1].split(':')[1].strip | |
@description = line[2].split(':')[1].strip | |
end | |
attr_accessor :id, :name, :type, :description | |
end | |
def setup_android_sdk package_name | |
command_output = `android list sdk --extended --all`.split('----------').map {|line| line.strip} | |
command_output.delete_at 0 # 0個目は`Refresh Sources`なので捨てる | |
package_list = command_output.map{|line| line.split(/\n/).map{|l| l.strip}} | |
packages = package_list.map { |e| AndroidSDKPackage.new e } | |
packages.find {|p| p.name.start_with? package_name} | |
end | |
if __FILE__ == $0 | |
print setup_android_sdk('build-tools').name | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
build_tool=`ruby ./scripts/setup_android_sdk.rb` | |
echo y | android update sdk --filter tools,$build_tool,platform-tools,android-14 --no-ui --force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment