Class: KPM::KillbillServerArtifact

Inherits:
BaseArtifact show all
Defined in:
lib/kpm/killbill_server_artifact.rb

Constant Summary

Constants inherited from BaseArtifact

BaseArtifact::KAUI_ARTIFACT_ID, BaseArtifact::KAUI_CLASSIFIER, BaseArtifact::KAUI_GROUP_ID, BaseArtifact::KAUI_PACKAGING, BaseArtifact::KILLBILL_ARTIFACT_ID, BaseArtifact::KILLBILL_CLASSIFIER, BaseArtifact::KILLBILL_GROUP_ID, BaseArtifact::KILLBILL_JAVA_PLUGIN_CLASSIFIER, BaseArtifact::KILLBILL_JAVA_PLUGIN_GROUP_ID, BaseArtifact::KILLBILL_JAVA_PLUGIN_PACKAGING, BaseArtifact::KILLBILL_PACKAGING, BaseArtifact::KILLBILL_RUBY_PLUGIN_CLASSIFIER, BaseArtifact::KILLBILL_RUBY_PLUGIN_GROUP_ID, BaseArtifact::KILLBILL_RUBY_PLUGIN_PACKAGING, BaseArtifact::KILLPAY_ARTIFACT_ID, BaseArtifact::KILLPAY_CLASSIFIER, BaseArtifact::KILLPAY_PACKAGING

Class Method Summary collapse

Methods inherited from BaseArtifact

nexus_defaults, nexus_remote, pull, pull_from_fs

Class Method Details

.info(version = 'LATEST', sha1_file = nil, force_download = false, verify_sha1 = true, overrides = {}, ssl_verify = true) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/kpm/killbill_server_artifact.rb', line 18

def info(version = 'LATEST', sha1_file = nil, force_download = false, verify_sha1 = true, overrides = {}, ssl_verify = true)
  logger = Logger.new(STDOUT)
  logger.level = Logger::ERROR

  # Initialize as early as possible (used in rescue block below)
  sha1_checker = sha1_file ? Sha1Checker.from_file(sha1_file) : nil

  version = KPM::Installer.get_kb_latest_stable_version if version == 'LATEST'

  versions = {}
  Dir.mktmpdir do |dir|
    # Retrieve the main Kill Bill pom
    kb_pom_info = pull(logger,
                       KPM::BaseArtifact::KILLBILL_GROUP_ID,
                       'killbill',
                       'pom',
                       nil,
                       version,
                       dir,
                       sha1_file,
                       force_download,
                       verify_sha1,
                       overrides,
                       ssl_verify)

    # Extract the killbill-oss-parent version
    pom = REXML::Document.new(File.new(kb_pom_info[:file_path]))
    oss_parent_version = pom.root.elements['parent/version'].text
    kb_version = pom.root.elements['version'].text

    versions['killbill'] = kb_version
    versions['killbill-oss-parent'] = oss_parent_version

    # Retrieve the killbill-oss-parent pom
    oss_pom_info = pull(logger,
                        KPM::BaseArtifact::KILLBILL_GROUP_ID,
                        'killbill-oss-parent',
                        'pom',
                        nil,
                        oss_parent_version,
                        dir,
                        sha1_file,
                        force_download,
                        verify_sha1,
                        overrides,
                        ssl_verify)

    pom = REXML::Document.new(File.new(oss_pom_info[:file_path]))
    properties_element = pom.root.elements['properties']
    %w[killbill-api killbill-plugin-api killbill-commons killbill-platform].each do |property|
      versions[property] = properties_element.elements["#{property}.version"].text
    end

    sha1_checker.cache_killbill_info(version, versions) if sha1_checker
  end
  versions
rescue StandardError => e
  # Network down? Hopefully, we have something in the cache
  cached_version = sha1_checker ? sha1_checker.killbill_info(version) : nil
  raise e if force_download || !cached_version

  # Use the cache
  cached_version
end

.versions(artifact_id, packaging = KPM::BaseArtifact::KILLBILL_PACKAGING, classifier = KPM::BaseArtifact::KILLBILL_CLASSIFIER, overrides = {}, ssl_verify = true) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/kpm/killbill_server_artifact.rb', line 9

def versions(artifact_id, packaging = KPM::BaseArtifact::KILLBILL_PACKAGING, classifier = KPM::BaseArtifact::KILLBILL_CLASSIFIER, overrides = {}, ssl_verify = true)
  coordinate_map = { group_id: KPM::BaseArtifact::KILLBILL_GROUP_ID, artifact_id: artifact_id, packaging: packaging, classifier: classifier }
  coordinates = KPM::Coordinates.build_coordinates(coordinate_map)
  response    = REXML::Document.new nexus_remote(overrides, ssl_verify).search_for_artifacts(coordinates)
  versions    = SortedSet.new
  response.elements.each('searchNGResponse/data/artifact/version') { |element| versions << element.text }
  versions
end