lib/kpm/base_installer.rb in kpm-0.5.3 vs lib/kpm/base_installer.rb in kpm-0.6.0

- old
+ new

@@ -10,10 +10,11 @@ def initialize(logger, nexus_config = nil, nexus_ssl_verify = nil) @logger = logger @nexus_config = nexus_config @nexus_ssl_verify = nexus_ssl_verify + @trace_logger = KPM::TraceLogger.new end def install_killbill_server(specified_group_id=nil, specified_artifact_id=nil, specified_packaging=nil, specified_classifier=nil, specified_version=nil, specified_webapp_path=nil, bundles_dir=nil, force_download=false, verify_sha1=true) group_id = specified_group_id || KPM::BaseArtifact::KILLBILL_GROUP_ID artifact_id = specified_artifact_id || KPM::BaseArtifact::KILLBILL_ARTIFACT_ID @@ -22,12 +23,17 @@ version = specified_version || LATEST_VERSION webapp_path = specified_webapp_path || KPM::root bundles_dir = Pathname.new(bundles_dir || DEFAULT_BUNDLES_DIR).expand_path sha1_file = "#{bundles_dir}/#{SHA1_FILENAME}" + if version == LATEST_VERSION + latest_stable_version = KPM::Installer.get_kb_latest_stable_version + version = latest_stable_version unless latest_stable_version.nil? + end + @logger.debug("Installing Kill Bill server: group_id=#{group_id} artifact_id=#{artifact_id} packaging=#{packaging} classifier=#{classifier} version=#{version} webapp_path=#{webapp_path}") - KPM::KillbillServerArtifact.pull(@logger, + artifact_info = KPM::KillbillServerArtifact.pull(@logger, group_id, artifact_id, packaging, classifier, version, @@ -35,10 +41,14 @@ sha1_file, force_download, verify_sha1, @nexus_config, @nexus_ssl_verify) + # store trace info to be returned as JSON by the KPM::Installer.install method + @trace_logger.add('killbill', + 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_kaui(specified_group_id=nil, specified_artifact_id=nil, specified_packaging=nil, specified_classifier=nil, specified_version=nil, specified_webapp_path=nil, bundles_dir=nil, force_download=false, verify_sha1=true) group_id = specified_group_id || KPM::BaseArtifact::KAUI_GROUP_ID artifact_id = specified_artifact_id || KPM::BaseArtifact::KAUI_ARTIFACT_ID @@ -48,11 +58,11 @@ webapp_path = specified_webapp_path || KPM::root bundles_dir = Pathname.new(bundles_dir || DEFAULT_BUNDLES_DIR).expand_path sha1_file = "#{bundles_dir}/#{SHA1_FILENAME}" @logger.debug("Installing Kaui: group_id=#{group_id} artifact_id=#{artifact_id} packaging=#{packaging} classifier=#{classifier} version=#{version} webapp_path=#{webapp_path}") - KPM::KauiArtifact.pull(@logger, + artifact_info = KPM::KauiArtifact.pull(@logger, group_id, artifact_id, packaging, classifier, version, @@ -60,10 +70,16 @@ sha1_file, force_download, verify_sha1, @nexus_config, @nexus_ssl_verify) + # store trace info to be returned as JSON by the KPM::Installer.install method + @trace_logger.add('kaui', + 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) # plugin_key needs to exist @@ -136,10 +152,14 @@ sha1_file, force_download, verify_sha1, @nexus_config, @nexus_ssl_verify) + # store trace info to be returned as JSON by the KPM::Installer.install method + @trace_logger.add('plugins', plugin_key, + artifact_info.merge({'status'=> (artifact_info[:skipped] ? 'UP_TO_DATE': 'INSTALLED'), + :group_id => group_id, :artifact_id => artifact_id, :packaging => packaging, :classifier => classifier})) # Update with resolved version coordinate_map[:version] = artifact_info[:version] mark_as_active(plugins_dir, artifact_info, artifact_id) @@ -152,12 +172,16 @@ def install_plugin_from_fs(plugin_key, file_path, name, version, bundles_dir=nil, type='java') bundles_dir = Pathname.new(bundles_dir || DEFAULT_BUNDLES_DIR).expand_path plugins_dir = bundles_dir.join('plugins') + if version.nil? + version = Utils.get_version_from_file_path(file_path) + end + if type.to_s == 'java' - plugin_name = name.nil? ? Pathname.new(file_path).basename.to_s.split('-')[0] : name + 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') end @@ -166,10 +190,14 @@ mark_as_active(plugins_dir, artifact_info) update_plugin_identifier(plugins_dir, plugin_key, type.to_s, nil, artifact_info) + # store trace info to be returned as JSON by the KPM::Installer.install method + @trace_logger.add('plugins', plugin_key, + artifact_info.merge({'status'=>'INSTALLED'})) + artifact_info end def uninstall_plugin(plugin_name_or_key, plugin_version=nil, bundles_dir=nil) bundles_dir = Pathname.new(bundles_dir || DEFAULT_BUNDLES_DIR).expand_path @@ -215,9 +243,13 @@ sha1_file, force_download, verify_sha1, @nexus_config, @nexus_ssl_verify) + + @trace_logger.add('default_bundles', + 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 unless info[:skipped] File.rename Dir.glob("#{destination}/killbill-platform-osgi-bundles-jruby-*.jar").first, destination.join('jruby.jar')