Module: Glimmer::RakeTask::Package
- Defined in:
- lib/glimmer/rake_task/package.rb
Class Attribute Summary collapse
-
.jpackage_extra_args ⇒ Object
Returns the value of attribute jpackage_extra_args.
Class Method Summary collapse
- .clean ⇒ Object
- .config ⇒ Object
- .gem ⇒ Object
- .gemspec ⇒ Object
- .jar ⇒ Object
- .lock_jars ⇒ Object
- .native(native_type = nil, native_extra_args) ⇒ Object
Class Attribute Details
.jpackage_extra_args ⇒ Object
Returns the value of attribute jpackage_extra_args.
29 30 31 |
# File 'lib/glimmer/rake_task/package.rb', line 29 def jpackage_extra_args @jpackage_extra_args end |
Class Method Details
.clean ⇒ Object
31 32 33 34 35 |
# File 'lib/glimmer/rake_task/package.rb', line 31 def clean require 'fileutils' FileUtils.rm_rf('dist') FileUtils.rm_rf('packages') end |
.config ⇒ Object
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/glimmer/rake_task/package.rb', line 53 def config project_name = File.basename(File.('.')) if !File.exists?('config/warble.rb') puts 'Generating JAR configuration (config/warble.rb) to use with Warbler...' FileUtils.mkdir_p('config') if OS.windows? system "jruby -S gem install warbler -v2.0.5 --no-document" unless warbler_exists? else system "bash -c '#{RVM_FUNCTION}\n cd .\n jruby -S gem install warbler -v2.0.5 --no-document\n'" unless warbler_exists? end if 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 bin config db docs fonts icons images lib package script sounds vendor videos)') 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) else puts 'Warbler executable "warble" is missing!' end end end |
.gem ⇒ Object
41 42 43 |
# File 'lib/glimmer/rake_task/package.rb', line 41 def gem system 'rake build' end |
.gemspec ⇒ Object
37 38 39 |
# File 'lib/glimmer/rake_task/package.rb', line 37 def gemspec system 'rake gemspec:generate' end |
.jar ⇒ Object
83 84 85 86 87 88 |
# File 'lib/glimmer/rake_task/package.rb', line 83 def jar FileUtils.mkdir_p('dist') puts "Generating JAR with Warbler..." system "jruby -S gem install warbler -v2.0.5 --no-document" unless warbler_exists? system('warble') end |
.lock_jars ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/glimmer/rake_task/package.rb', line 45 def lock_jars puts 'Locking gem jar-dependencies by downloading and storing in vendor/jars...' FileUtils.mkdir_p('vendor/jars') command = "lock_jars --vendor-dir vendor/jars" puts command system command end |
.native(native_type = nil, native_extra_args) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/glimmer/rake_task/package.rb', line 90 def native(native_type=nil, native_extra_args) puts "Generating native executable with jpackage..." java_version = `jruby -v` if java_version.include?('16.0.2') puts "Java Version 16.0.2 Detected!" else puts "WARNING! Glimmer Packaging Pre-Requisite Java Version 16.0.2 Is Not Found!" end require 'facets/string/titlecase' require 'facets/string/underscore' require 'facets/string/camelcase' project_name = File.basename(File.('.')) version_file = File.('./VERSION') version = (File.read(version_file).strip if File.exists?(version_file) && File.file?(version_file)) rescue nil license_file = File.('./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 icon = "icons/#{OS.mac? ? 'macosx' : (OS.linux? ? 'linux' : 'windows')}/#{human_name}.#{OS.mac? ? 'icns' : (OS.linux? ? 'png' : 'ico')}" native_type = 'app-image' if native_type.to_s.strip.empty? if (`jpackage`.to_s.include?('Usage: jpackage') rescue nil) FileUtils.rm_rf("packages/bundles") FileUtils.mkdir_p('packages/bundles') command = "jpackage" command += " --type #{native_type}" command += " --dest 'packages/bundles' --input 'dist' --main-class JarMain --main-jar '#{project_name}.jar' --java-options '-Dproject_name=#{project_name}' --name '#{human_name}' --vendor '#{human_name}' --icon '#{icon}' " command += " --win-per-user-install --win-dir-chooser --win-menu --win-menu-group '#{human_name}' " if OS.windows? && native_type != 'app-image' command += " --linux-menu-group '#{human_name}' " if OS.linux? && native_type != 'app-image' command += " --java-options '-XstartOnFirstThread' --mac-package-name '#{human_name}' --mac-package-identifier 'org.#{project_name}.application.#{project_name}' " if OS.mac? command += " --app-version \"#{version}\" " if version command += " --license-file LICENSE.txt " if license && native_type != 'app-image' command += " --copyright \"#{copyright}\" " if copyright else puts "jpackage does not exist in your Java installation. Please ensure jpackage is available in PATH environment variable." return end Rake.application.load_rakefile # make sure to load potential jpackage_extra_args config in app Rakefile command += " #{jpackage_extra_args} " if jpackage_extra_args command += " #{ENV['JPACKAGE_EXTRA_ARGS']} " if ENV['JPACKAGE_EXTRA_ARGS'] command += " #{native_extra_args} " if native_extra_args puts command system command end |