Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Buildr uberjar example concatenting spring meta data
assembly_dir = 'target/assembly'
main_class = 'com.something.something.Blah'
artifacts.each do |artifact|
Unzip.new( _(assembly_dir) => artifact ).extract
# Create a concatenation of all the spring.schemas for each spring jars
if File.exist?( "#{_(assembly_dir)}/META-INF/spring.schemas" )
new_schema = IO.read("#{_(assembly_dir)}/META-INF/spring.schemas")
File.open( "#{_(assembly_dir)}/META-INF/master_spring.schemas", 'a') do |f|
f.write( new_schema )
f.write("\n")
end
# remove jar's spring.schema
FileUtils.rm( "#{_(assembly_dir)}/META-INF/spring.schemas" )
end
# Create a concatenation of all the spring.handlers for each spring jars
if File.exist?( "#{_(assembly_dir)}/META-INF/spring.handlers" )
new_handler = IO.read("#{_(assembly_dir)}/META-INF/spring.handlers")
master_handler = File.open( "#{_(assembly_dir)}/META-INF/master_spring.handlers", 'a') do |f|
f.write( new_handler )
f.write("\n")
end
# remove jar's spring.handlers
FileUtils.rm( "#{_(assembly_dir)}/META-INF/spring.handlers" )
end
# Create a concatenation of all the spring.tooling for each spring jars
if File.exist?( "#{_(assembly_dir)}/META-INF/spring.tooling" )
new_handler = IO.read("#{_(assembly_dir)}/META-INF/spring.tooling")
master_handler = File.open( "#{_(assembly_dir)}/META-INF/master_spring.tooling", 'a') do |f|
f.write( new_handler )
f.write("\n")
end
# remove jar's spring.handlers
FileUtils.rm( "#{_(assembly_dir)}/META-INF/spring.tooling" )
end
end
FileUtils.mv( "#{_(assembly_dir)}/META-INF/master_spring.schemas", "#{_(assembly_dir)}/META-INF/spring.schemas" )
FileUtils.mv( "#{_(assembly_dir)}/META-INF/master_spring.handlers", "#{_(assembly_dir)}/META-INF/spring.handlers" )
FileUtils.mv( "#{_(assembly_dir)}/META-INF/master_spring.tooling", "#{_(assembly_dir)}/META-INF/spring.tooling" )
# remove dirs from assembly that should not be in uberjar
FileUtils.rm_rf( "#{_(assembly_dir)}/example/package" )
FileUtils.rm_rf( "#{_(assembly_dir)}/example/dir" )
# create manifest file
File.open( _("#{assembly_dir}/META-INF/MANIFEST.MF"), 'w') do |f|
f.write("Implementation-Title: Uberjar Exampleh\n")
f.write("Implementation-Version: #{project_version}\n")
f.write("Main-Class: #{main_class}\n")
f.write("Created-By: Buildr\n")
end
present_dir = Dir.pwd
Dir.chdir _(assembly_dir)
puts "Creating #{_("target/#{project.name}-#{project.version}.jar")}"
`jar -cfm #{_("target/#{project.name}-#{project.version}.jar")} #{_(assembly_dir)}/META-INF/MANIFEST.MF .`
Dir.chdir present_dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.