Skip to content

Commit

Permalink
Breaking dependency of buck build on ant
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed Dec 11, 2016
1 parent 52a89fd commit 0e4c719
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions rake-tasks/buck.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ def self.download
out_dir = File.dirname out
FileUtils.mkdir_p(out_dir) unless File.exist?(out_dir)

# Cut-and-pasted from rake-tasks/crazy_fun/mappings/java.rb. We duplicate the code here so
# we can delete that file and have this continue working, but once we delete that file, we
# should also stop using this version of ant and just use the ant bundled with jruby.
dir = 'third_party/java/ant'
Dir[File.join(dir, '*.jar')].each { |jar| require jar }
# we set ANT_HOME to avoid JRuby trying to load its own Ant
ENV['ANT_HOME'] = dir
require "ant"

ant.get('src' => url, 'dest' => out, 'verbose' => true)
require "third_party/java/httpcomponents/httpcore-4.4.4"
require "third_party/java/httpcomponents/httpclient-4.5.2"
require "third_party/java/commons-logging/commons-logging-1.2"
require "third_party/java/commons-io/commons-io-2.5"

httpclient = org.apache.http.impl.client.HttpClients.custom().setRedirectStrategy(org.apache.http.impl.client.LaxRedirectStrategy.new()).build()
httpget = org.apache.http.client.methods.HttpGet.new(url)
response = httpclient.execute(httpget)
entity = response.getEntity()
org.apache.commons.io.FileUtils.copyInputStreamToFile(entity.getContent(), java.io.File.new(out))
org.apache.http.util.EntityUtils.consume(entity) unless entity.nil?

File.chmod(0755, out)
cmd = (windows?) ? ["python", out] : [out]
sh cmd.join(" ") + " kill", :verbose => true
Expand Down

0 comments on commit 0e4c719

Please sign in to comment.