Created
July 23, 2014 14:35
-
-
Save suzukaze/0cde6c1c4434a2abddf7 to your computer and use it in GitHub Desktop.
Android Studioでjarファイルをrubyで簡単に作成する ref: http://qiita.com/suzukaze/items/7f54f1b76369b397cbf2
This file contains 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
dependencies { | |
compile files('libs/Hoge.jar') | |
} |
This file contains 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
$ ./gradlew clean | |
$ ./gradlew aR |
This file contains 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
$ gem install rubyzip |
This file contains 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
$ ruby make_jar.rb ./Hoge.aar |
This file contains 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
require 'zip' | |
if ARGV.size == 0 | |
puts 'usage : ruby unzip.rb [aar filname]' | |
exit | |
end | |
aar_file = ARGV[0] | |
TEMP_DIR = 'temp' | |
Dir.mkdir(TEMP_DIR) unless FileTest.exist?(TEMP_DIR) | |
FileUtils.copy(aar_file, "#{TEMP_DIR}/#{aar_file}", {}) | |
Dir.chdir(TEMP_DIR) do | |
Zip::File.open(aar_file) do |zip| | |
zip.each do |entry| | |
zip.extract(entry, entry.to_s) { true } | |
end | |
end | |
end | |
filename = File.basename(aar_file, ".aar") | |
lib_filename = "#{filename}.jar" | |
Dir.chdir(TEMP_DIR) do | |
FileUtils.mv('classes.jar', lib_filename) | |
end | |
FileUtils.copy("#{TEMP_DIR}/#{lib_filename}", "#{lib_filename}") | |
FileUtils.rm_rf(TEMP_DIR) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment