Created
May 16, 2012 15:04
-
-
Save vbatts/2711030 to your computer and use it in GitHub Desktop.
warbler: store a local webserver jar, instead of in ~/.m2/
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
#!/bin/sh | |
ruby \ | |
-I$(dirname $(gem which warbler)) -r warbler/web_server \ | |
-I./ -r local_web_server \ | |
-S warble \ | |
--trace |
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
module Warbler | |
class WebServer | |
class LocalArtifact < Struct.new(:path, :group_id, :artifact_id, :version, :url) | |
def path_fragment | |
@path_fragment ||= "lib/jars/#{artifact_id}-#{version}.jar" | |
end | |
def cached_path | |
@cached_path ||= File.join(Dir.pwd,path_fragment) | |
end | |
def local_path | |
unless FileTest.file?(cached_path) | |
puts "Downloading #{url} to #{cached_path}" | |
FileUtils.mkdir_p File.dirname(cached_path) | |
require 'open-uri' | |
begin | |
open(url) do |stream| | |
File.open(cached_path, "wb") do |f| | |
while buf = stream.read(4096) | |
f << buf | |
end | |
end | |
end | |
rescue => e | |
e.message.concat " - #{url}" | |
raise e | |
end | |
end | |
cached_path | |
end | |
end | |
end | |
class LocalWinstoneServer < WinstoneServer | |
attr_reader :artifact | |
def initialize | |
d = File.dirname(File.dirname(File.expand_path(__FILE__))) | |
@artifact = LocalArtifact.new(d, "lib.jars", | |
"winstone","0.9.10-jenkins-35", | |
"http://maven.jenkins-ci.org/content/groups/artifacts/org/jenkins-ci/winstone/0.9.10-jenkins-35/winstone-0.9.10-jenkins-35.jar" | |
) | |
end | |
end | |
WEB_SERVERS.update({"local.winstone" => LocalWinstoneServer.new}) | |
end | |
# vim:set sts=2 shiftwidth=2 ai et: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment