lib/kpm/base_installer.rb in kpm-0.10.6 vs lib/kpm/base_installer.rb in kpm-0.11.0
- old
+ new
@@ -77,11 +77,11 @@
@trace_logger.add('kaui', nil,
artifact_info.merge('status' => (artifact_info[:skipped] ? 'UP_TO_DATE' : 'INSTALLED'),
:group_id => group_id, :artifact_id => artifact_id, :packaging => packaging, :classifier => classifier))
end
- def install_plugin(plugin_key, raw_kb_version = nil, specified_group_id = nil, specified_artifact_id = nil, specified_packaging = nil, specified_classifier = nil, specified_version = nil, bundles_dir = nil, specified_type = nil, force_download = false, verify_sha1 = true, verify_jruby_jar = false)
+ def install_plugin(plugin_key, raw_kb_version = nil, specified_group_id = nil, specified_artifact_id = nil, specified_packaging = nil, specified_classifier = nil, specified_version = nil, bundles_dir = nil, specified_type = nil, force_download = false, verify_sha1 = true)
# plugin_key needs to exist
raise ArgumentError, 'Aborting installation: User needs to specify a pluginKey' if plugin_key.nil?
# Lookup artifact and perform validation against input
looked_up_group_id, looked_up_artifact_id, looked_up_packaging, looked_up_classifier, looked_up_version, looked_up_type = KPM::PluginsDirectory.lookup(plugin_key, true, raw_kb_version)
@@ -92,11 +92,10 @@
validate_installation_arg!(plugin_key, 'classifier', specified_classifier, looked_up_classifier)
# If there is no entry in plugins_directory.yml and the group_id is not the killbill default group_id, the key provided must be a user key and must have a namespace
if looked_up_artifact_id.nil? &&
specified_group_id != KPM::BaseArtifact::KILLBILL_JAVA_PLUGIN_GROUP_ID &&
- specified_group_id != KPM::BaseArtifact::KILLBILL_RUBY_PLUGIN_GROUP_ID &&
plugin_key.split(':').size == 1
raise ArgumentError, "Aborting installation: pluginKey = #{plugin_key} does not exist in plugin_directory.yml so format of the key must have a user namespace (e.g namespace:key)"
end
# Specified parameters have always precedence except for the artifact_id (to map stripe to stripe-plugin)
@@ -112,18 +111,11 @@
packaging = specified_packaging || looked_up_packaging || KPM::BaseArtifact::KILLBILL_JAVA_PLUGIN_PACKAGING
classifier = specified_classifier || looked_up_classifier || KPM::BaseArtifact::KILLBILL_JAVA_PLUGIN_CLASSIFIER
version = specified_version || looked_up_version || LATEST_VERSION
destination = plugins_dir.join('java').join(artifact_id).join(version)
else
-
- warn_if_jruby_jar_missing(bundles_dir) if verify_jruby_jar
-
- group_id = specified_group_id || looked_up_group_id || KPM::BaseArtifact::KILLBILL_RUBY_PLUGIN_GROUP_ID
- packaging = specified_packaging || looked_up_packaging || KPM::BaseArtifact::KILLBILL_RUBY_PLUGIN_PACKAGING
- classifier = specified_classifier || looked_up_classifier || KPM::BaseArtifact::KILLBILL_RUBY_PLUGIN_CLASSIFIER
- version = specified_version || looked_up_version || LATEST_VERSION
- destination = plugins_dir.join('ruby')
+ raise ArgumentError, "Aborting installation: plugin type #{type} unsupported"
end
sha1_file = "#{bundles_dir}/#{SHA1_FILENAME}"
plugins_manager = PluginsManager.new(plugins_dir, @logger)
_, plugin_name = plugins_manager.get_plugin_key_and_name(plugin_key)
@@ -176,11 +168,11 @@
if type.to_s == 'java'
plugin_name = name.nil? ? Utils.get_plugin_name_from_file_path(file_path) : name
destination = plugins_dir.join('java').join(plugin_name).join(version)
else
- destination = plugins_dir.join('ruby')
+ raise ArgumentError, "Aborting installation: plugin type #{type} unsupported"
end
artifact_info = KPM::KillbillPluginArtifact.pull_from_fs(@logger, file_path, destination)
artifact_info[:version] ||= version
@@ -243,14 +235,10 @@
@trace_logger.add('default_bundles', nil,
info.merge('status' => (info[:skipped] ? 'UP_TO_DATE' : 'INSTALLED'),
:group_id => group_id, :artifact_id => artifact_id, :packaging => packaging, :classifier => classifier))
- # The special JRuby bundle needs to be called jruby.jar
- # TODO .first - code smell
- File.rename Dir.glob("#{destination}/killbill-platform-osgi-bundles-jruby-*.jar").first, destination.join('jruby.jar') unless info[:skipped]
-
info
end
private
@@ -278,38 +266,8 @@
def mark_as_active(plugins_dir, artifact_info, _artifact_id = nil)
# Mark this bundle as active
plugins_manager = PluginsManager.new(plugins_dir, @logger)
plugins_manager.set_active(artifact_info[:bundle_dir])
- end
-
- def warn_if_jruby_jar_missing(bundles_dir)
- platform_dir = bundles_dir.join('platform')
- jruby_jar = platform_dir.join('jruby.jar')
- if !File.exist?(jruby_jar)
- @logger.warn(" Missing installation for jruby.jar under #{platform_dir}. This is required for ruby plugin installation")
- else
- version = extract_jruby_jar_version(jruby_jar)
- if version
- @logger.info(" Detected jruby.jar version #{version}")
- else
- @logger.warn(" Failed to detect jruby.jar version for #{jruby_jar}")
- end
- end
- end
-
- def extract_jruby_jar_version(jruby_jar)
- selected_entries = Zip::File.open(jruby_jar) do |zip_file|
- zip_file.select do |entry|
- entry.name == 'META-INF/maven/org.kill-bill.billing/killbill-platform-osgi-bundles-jruby/pom.properties'
- end
- end
-
- if selected_entries && selected_entries.size == 1
- zip_entry = selected_entries[0]
- content = zip_entry.get_input_stream.read
- return content.split("\n").select { |e| e.start_with?('version') }[0].split('=')[1]
- end
- nil
end
end
end