Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Commit

Permalink
Merge branch 'tmpdir-build'
Browse files Browse the repository at this point in the history
  • Loading branch information
iconara committed Sep 18, 2015
2 parents b58bc26 + 08e8217 commit 150184e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/puck/jar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def create

Dir.mktmpdir do |tmp_dir|
output_path = File.join(@configuration[:build_dir], @configuration[:jar_name])
temporary_output_path = File.join(Dir.mktmpdir, @configuration[:jar_name])
project_dir = Pathname.new(@configuration[:app_dir]).expand_path.cleanpath
extra_files = @configuration[:extra_files] || []
jruby_complete_path = @configuration[:jruby_complete]
Expand All @@ -101,7 +102,7 @@ def create

ant = Ant.new(output_level: 1)
begin
ant.jar(destfile: output_path) do
ant.jar(destfile: temporary_output_path) do
manifest do
attribute name: 'Main-Class', value: 'org.jruby.JarBootstrapMain'
attribute name: 'Created-By', value: "Puck v#{Puck::VERSION}"
Expand Down Expand Up @@ -140,8 +141,12 @@ def create
end
end
end

FileUtils.mv(temporary_output_path, output_path)
rescue Java::OrgApacheToolsAnt::BuildException => e
raise PuckError, sprintf('Error when building JAR: %s (%s)', e.message, e.class), e.backtrace
ensure
FileUtils.rm_rf(File.dirname(temporary_output_path))
end
output_path
end
Expand Down

0 comments on commit 150184e

Please sign in to comment.