Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created March 21, 2018 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save havenwood/a69b8f6a079711d16ec6a98d9acf7887 to your computer and use it in GitHub Desktop.
Save havenwood/a69b8f6a079711d16ec6a98d9acf7887 to your computer and use it in GitHub Desktop.
require 'fileutils'
require 'open-uri'
require 'rexml/document'
JAR_DIR = 'jars'
LAMBDA_JAVA_URL = 'http://central.maven.org/maven2/com/amazonaws/aws-lambda-java-core'
FileUtils.mkdir_p JAR_DIR
def save_jar jar_url
IO.copy_stream open(jar_url), File.join(JAR_DIR, File.basename(jar_url))
end
##
# Fetch the latest jruby-complete.jar:
html = open 'http://jruby.org/download', &:read
save_jar html[/[^']*.jar/]
##
# Fetch the latest aws-lambda-java-core.jar:
xml = open "#{LAMBDA_JAVA_URL}/maven-metadata.xml", &:read
rexml = REXML::Document.new xml
version = rexml.elements['metadata/versioning/latest'].text
save_jar "#{LAMBDA_JAVA_URL}/#{version}/aws-lambda-java-core-#{version}.jar"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment