module Spigoter::CLI::Compile
Module for compiling Spigot @author Daniel Ramos Acosta <danielramosacosta@hotmail.com>
Public Class Methods
compile()
click to toggle source
# File lib/spigoter/cli/cli_compile.rb, line 11 def self.compile ->(*) { main } end
compile_spigot(opts)
click to toggle source
# File lib/spigoter/cli/cli_compile.rb, line 53 def self.compile_spigot(opts) Log.info "Compiling spigot version #{opts[:spigot_version]}" exit_status = system("java -jar BuildTools.jar --rev #{opts[:spigot_version]}") if exit_status != true Log.error 'There was an error while compiling Spigot' exit(1) end end
dependencies()
click to toggle source
# File lib/spigoter/cli/cli_compile.rb, line 30 def self.dependencies if Spigoter::Utils.which('javac').nil? || Spigoter::Utils.which('git').nil? Log.error "You don't have javac or git in PATH" exit(1) end end
download_buildtools()
click to toggle source
# File lib/spigoter/cli/cli_compile.rb, line 44 def self.download_buildtools unless File.exist?('BuildTools.jar') file = Spigoter::Utils.download('https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar') File.open('BuildTools.jar', 'wb') do |f| f.write(file) end end end
import_opts()
click to toggle source
# File lib/spigoter/cli/cli_compile.rb, line 37 def self.import_opts Spigoter::Utils.fill_opts_config rescue Log.error 'There is an error in spigoter.yml' exit(1) end
main(*)
click to toggle source
# File lib/spigoter/cli/cli_compile.rb, line 15 def self.main(*) Log.info 'Compiling Spigot!' dependencies opts = import_opts FileUtils.mkdir_p 'build' Dir.chdir('build') do download_buildtools FileUtils.rm_rf(Dir.glob('spigot*.jar')) compile_spigot(opts) end FileUtils.cp(Dir['build/spigot*.jar'].first, 'spigot.jar') end