Class: Thrust::Android::Tools

Inherits:
Object
  • Object
show all
Defined in:
lib/thrust/android/tools.rb

Instance Method Summary collapse

Constructor Details

#initialize(out = $stdout, thrust_executor = Thrust::Executor.new) ⇒ Tools

Returns a new instance of Tools.



6
7
8
9
# File 'lib/thrust/android/tools.rb', line 6

def initialize(out = $stdout, thrust_executor = Thrust::Executor.new)
  @thrust_executor = thrust_executor
  @out = out
end

Instance Method Details

#build_signed_releaseObject



23
24
25
26
27
# File 'lib/thrust/android/tools.rb', line 23

def build_signed_release
  verify_android_installed!
  @thrust_executor.system_or_exit('mvn clean package -Prelease')
  Dir.glob('target/*-signed-aligned.apk').first or raise 'Signed APK was not generated'
end

#change_build_number(version_code, version_name) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/thrust/android/tools.rb', line 11

def change_build_number(version_code, version_name)
  @thrust_executor.system_or_exit(
    "sed -i ''" +
      " -e 's/android:versionCode=\"[0-9]*\"/android:versionCode=\"#{version_code}\"/'" +
      " -e 's/android:versionName=\"\\([^ \"]*\\)[^\"]*\"/android:versionName=\"\\1 (#{version_name})\"/'" +
      " AndroidManifest.xml")
  @thrust_executor.system_or_exit(
    "sed -i ''" +
      " '1,/<version>/s/<version>\\([^- <]*\\)[^<]*<\\/version>/<version>\\1 (#{version_name})<\\/version>/'" +
      " pom.xml")
end