class KPM::System

def get_killbill_version(killbill_web_path = nil)

def get_killbill_version(killbill_web_path = nil)
  killbill_search_default_dir = killbill_web_path.nil? ? DEFAULT_KILLBILL_SEARCH_BASE_DIR : Dir[killbill_web_path][0]
  killbill_search_default_dir.gsub!('.war','')
  killbill_search_default_dir.gsub!('webapps','**')
  file =  Dir[killbill_search_default_dir + File::SEPARATOR + 'META-INF' +  File::SEPARATOR + '**' + File::SEPARATOR + 'pom.properties']
  version = nil
  if not file[0].nil?
    absolute_file_path = File.absolute_path(file[0])
    version = open(absolute_file_path) do |f|
      f.each_line.detect do |line|
          version = /(\d+)\.(\d+)\.(\d+)/.match(line)
          if not version.nil?
            break;
          end
      end
      version
    end
  end
  version
end