Class: JLauncher::FullConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/jlauncher.rb

Overview

The full configuration needed to start a program has a manifest plus an optional extra_class_path element, which contains either maven coordinates or a local file containing a jar

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(manifest, extra_class_path, start_coordinates) ⇒ FullConfig

Returns a new instance of FullConfig.



149
150
151
152
153
154
# File 'lib/jlauncher.rb', line 149

def initialize(manifest, extra_class_path, start_coordinates)
  @manifest = manifest
  @extra_class_path = extra_class_path
  @start_coordinates = start_coordinates

end

Instance Attribute Details

#manifestObject (readonly)

Returns the value of attribute manifest.



147
148
149
# File 'lib/jlauncher.rb', line 147

def manifest
  @manifest
end

#start_coordinatesObject (readonly)

Returns the value of attribute start_coordinates.



147
148
149
# File 'lib/jlauncher.rb', line 147

def start_coordinates
  @start_coordinates
end

Instance Method Details

#launch_config(resolver) ⇒ Object



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/jlauncher.rb', line 157

def launch_config(resolver)
  class_path_from_manifest = @manifest.dependencies.map {
      |c| resolver.get(c)
  }

  if @extra_class_path
    split_index = @extra_class_path.index(":")
    protocol = @extra_class_path[0..split_index - 1]
    value = @extra_class_path[split_index + 1..-1]
    extra_element = case protocol
                    when "file"
                      value
                    when "maven"
                      resolver.get(Coordinates.new(value))
                    end
    class_path_from_manifest = class_path_from_manifest << extra_element
  end

  JvmLaunchConfig.new(
      class_path_from_manifest,
      @manifest.main_class
  )
end