Skip to content

Commit

Permalink
Also generate source jars for the zips
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Jul 22, 2017
1 parent d6dafec commit 1d38c49
Showing 1 changed file with 36 additions and 8 deletions.
44 changes: 36 additions & 8 deletions rake-tasks/buck.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,40 @@ def buck(*args, &block)
short = task.name[0..-5]

task.enhance do
dir, target = short[2..-1].split(':', 2)
working_dir = "buck-out/crazy-fun/#{dir}/#{target}_zip"

# Build the source zip
Buck::buck_cmd.call('query', ["kind(java_library, deps(#{short}))"]) do |output|
# Collect all the targets
to_build = []
output.lines do |line|
line.chomp!
to_build.push(line + "#src")
end

src_dir = "buck-out/crazy-fun/#{dir}/#{target}_src_zip"
src_out = "#{working_dir}/#{target}-#{version}-nodeps-sources.zip"
mkdir_p File.dirname(src_out)
rm_f src_out
rm_rf src_dir

mkdir_p src_dir
mkdir_p "#{working_dir}/lib"
mkdir_p "#{working_dir}/uber"

Buck::buck_cmd.call('build', ['--show-output'] + to_build) do |built|
built.lines do |line|
line.chomp!
line.split[1].each do |file|
next unless File.exists? file
sh "cd #{src_dir} && jar xf #{File.expand_path(file)}"
end
end
end
sh "cd #{src_dir} && jar cMf #{File.expand_path(src_out)} *"
end

# Figure out if this is an executable or a test target.
Buck::buck_cmd.call('audit', ['classpath', short]) do |output|
third_party = []
Expand All @@ -199,13 +233,6 @@ def buck(*args, &block)
end
end

dir, target = short[2..-1].split(':', 2)
working_dir = "buck-out/crazy-fun/#{dir}/#{target}_zip"
out = "buck-out/crazy-fun/#{dir}/#{target}.zip"
rm_rf working_dir
mkdir_p "#{working_dir}/lib"
mkdir_p "#{working_dir}/uber"

first_party.each do |jar|
sh "cd #{working_dir}/uber && jar xf #{jar}"
end
Expand All @@ -214,8 +241,9 @@ def buck(*args, &block)
version = File.open('SELENIUM_VERSION', &:gets).chomp
version = eval(version)

out = "buck-out/crazy-fun/#{dir}/#{target}.zip"

sh "cd #{working_dir}/uber && jar cMf ../#{target}-#{version}-nodeps.jar *"
# TODO: Get the sources of all deps too and build the -src.jar
rm_rf "#{working_dir}/uber"

third_party.each do |jar|
Expand Down

0 comments on commit 1d38c49

Please sign in to comment.