Module: Glimmer::Package

Defined in:
lib/glimmer/package.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.javapackager_extra_argsObject

Returns the value of attribute javapackager_extra_args.



8
9
10
# File 'lib/glimmer/package.rb', line 8

def javapackager_extra_args
  @javapackager_extra_args
end

Class Method Details

.cleanObject



10
11
12
13
14
# File 'lib/glimmer/package.rb', line 10

def clean
  require 'fileutils'
  FileUtils.rm_rf('dist')
  FileUtils.rm_rf('packages')
end

.configObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/glimmer/package.rb', line 16

def config
  project_name = File.basename(File.expand_path('.'))
  if !File.exists?('config/warble.rb')
    puts 'Generating JAR configuration (config/warble.rb) to use with Warbler...'
    FileUtils.mkdir_p('config')
    system('warble config')
    new_config = File.read('config/warble.rb').split("\n").inject('') do |output, line|
      if line.include?('config.dirs =')
        line = line.sub('# ', '').sub(/=[^=\n]+$/, '= %w(app config db lib script bin docs fonts icons images sounds videos vendor)')
      end
      if line.include?('config.includes =')
        line = line.sub('# ', '').sub(/=[^=\n]+$/, "= FileList['LICENSE.txt', 'VERSION']")
      end
      if line.include?('config.autodeploy_dir =')
        line = line.sub('# ', '')
      end
      output + "\n" + line
    end
    File.write('config/warble.rb', new_config)
  end      
end

.jarObject



38
39
40
41
42
# File 'lib/glimmer/package.rb', line 38

def jar
  FileUtils.mkdir_p('dist')
  puts "Generating JAR with Warbler..."
  system('warble')      
end

.nativeObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/glimmer/package.rb', line 44

def native
  require 'facets/string/titlecase'
  require 'facets/string/underscore'
  project_name = File.basename(File.expand_path('.'))
  version_file = File.expand_path('./VERSION')
  version = (File.read(version_file).strip if File.exists?(version_file) && File.file?(version_file)) rescue nil
  license_file = File.expand_path('./LICENSE.txt')
  license = (File.read(license_file).strip if File.exists?(license_file) && File.file?(license_file)) rescue nil
  copyright = license.split("\n").first
  human_name = project_name.underscore.titlecase
  command = "javapackager -deploy -native -outdir packages -outfile \"#{project_name}\" -srcfiles \"dist/#{project_name}.jar\" -appclass JarMain -name \"#{human_name}\" -title \"#{human_name}\" -Bmac.CFBundleName=\"#{human_name}\" -Bmac.CFBundleIdentifier=\"org.#{project_name}.application.#{project_name}\" -Bmac.category=\"public.app-category.business\" -BinstalldirChooser=true -Bvendor=\"#{human_name}\" -Bwin.menuGroup=\"#{human_name}\" -BsystemWide=#{OS.mac?} "
  command += " -BjvmOptions=-XstartOnFirstThread " if OS.mac?
  command += " -BappVersion=#{version} -Bmac.CFBundleVersion=#{version} " if version
  command += " -srcfiles LICENSE.txt -BlicenseFile=LICENSE.txt " if license
  command += " -Bcopyright=\"#{copyright}\" " if copyright
  command += " #{javapackager_extra_args} " if javapackager_extra_args
  command += " #{ENV['JAVAPACKAGER_EXTRA_ARGS']} " if ENV['JAVAPACKAGER_EXTRA_ARGS']
  puts "Generating DMG/PKG/APP/JNLP with javapackager..."
  puts command
  system command      
end