Created
November 23, 2014 12:57
-
-
Save tily/e6ba5059cf8fda9b2a82 to your computer and use it in GitHub Desktop.
jar が入っているディレクトリのファイル一覧を gradle 用の依存ライブラリ宣言へ変換
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
# Usage: ruby jar2mvn.rb /path/to/your/libs/ | |
require 'httparty' | |
def main | |
libdir = ARGV.first | |
Dir[File.join(libdir, '*.jar')].each do |path| | |
file = File.basename(path) | |
m = file.chomp.match(/^(.+)-(.+)\.jar$/) | |
a, v = m[1], m[2] | |
r = HTTParty.get( | |
'http://search.maven.org/solrsearch/select', | |
:query => {q: "a:#{a} AND v:#{v}", core: 'gav', rows: 20, wt: 'json'} | |
) | |
docs = r['response']['docs'] | |
if docs.empty? | |
STDERR.puts "WARN: #{path} does not match any" | |
elsif docs.size > 1 | |
STDERR.puts "WARN: #{path} is ambiguous" | |
else | |
docs.each do |doc| | |
puts "compile '#{doc['g']}:#{doc['a']}:#{doc['v']}' // #{path}" | |
end | |
end | |
end | |
end | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment