Class: Deployand::Command::Build

Inherits:
Deployand::Command show all
Defined in:
lib/deployand/command/build.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Build

Returns a new instance of Build.



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/deployand/command/build.rb', line 29

def initialize(argv)
  @build_type = argv.shift_argument || 'release'
  @release = argv.flag?('release', true)
  @debug = argv.flag?('debug')
  @clean = argv.flag?('clean')
  @sign = argv.flag?('sign', true)
  @output = argv.option('output')
  @flavor = argv.option('flavor')
  @arch = argv.option('arch')
  super
end

Class Method Details

.optionsObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/deployand/command/build.rb', line 17

def self.options
  [
    ['--release', 'Build in release mode (default)'],
    ['--debug', 'Build in debug mode'],
    ['--clean', 'Clean build artifacts before building'],
    ['--sign', 'Sign the APK/AAB with release keystore'],
    ['--output=PATH', 'Specify output directory'],
    ['--flavor=FLAVOR', 'Build specific flavor/variant'],
    ['--arch=ARCH', 'Target architecture (arm64-v8a, armeabi-v7a, x86_64)']
  ].concat(super)
end

Instance Method Details

#runObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/deployand/command/build.rb', line 52

def run
  print_info "Starting build process..."
  print_info "Build type: #{@build_type}"
  print_info "Flavor: #{@flavor}" if @flavor
  print_info "Architecture: #{@arch}" if @arch
  
  clean_build if @clean
  detect_project_type
  build_project
  sign_build if @sign && @release
  optimize_build if @release
  
  print_success "Build completed successfully!"
  print_info "Output location: #{build_output_path}"
end

#validate!Object



41
42
43
44
45
46
47
48
49
50
# File 'lib/deployand/command/build.rb', line 41

def validate!
  super
  
  valid_build_types = %w[release debug]
  unless valid_build_types.include?(@build_type)
    help! "Invalid build type '#{@build_type}'. Valid types: #{valid_build_types.join(', ')}"
  end
  
  @release = false if @debug
end