Skip to content

Commit

Permalink
Error when build war file
Browse files Browse the repository at this point in the history
  • Loading branch information
tungleduyxyz committed Dec 18, 2023
1 parent f2fc47e commit 332140c
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions config/warble.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: true


Warbler::Config.new do |config|
# Don't use gemjar, it seems it makes Gem load paths leak outside of the war
Expand All @@ -21,20 +21,26 @@
config.jar_name = 'killbill-admin-ui-standalone'
end

module FixInit
class Warbler::Jar
def add_init_file(config)
super
return unless @files[config.init_filename]

contents = @files[config.init_filename].read
add_before = "require 'bundler/shared_helpers'"
line_to_add = "Gem.paths = ENV\n"
@files[config.init_filename] = StringIO.new(contents.gsub(add_before, "#{line_to_add}\\0"))
end
end

module Warbler
class Jar
prepend FixInit
if config.init_contents
contents = ''
config.init_contents.each do |file|
if file.respond_to?(:read)
contents << file.read
elsif File.extname(file) == '.erb'
contents << expand_erb(file, config).read
else
contents << File.read(file)
end
end
@files[config.init_filename] = StringIO.new(contents)
end
if @files[config.init_filename]
contents = @files[config.init_filename].read
add_before = "require 'bundler/shared_helpers'"
line_to_add = "Gem.paths = ENV\n"
@files[config.init_filename] = StringIO.new(contents.gsub(add_before, "#{line_to_add}\\0"))
end
end
end

0 comments on commit 332140c

Please sign in to comment.