class Fastlane::Actions::SetGradlePropertyAction
Public Class Methods
available_options()
click to toggle source
@!group Documentation
# File lib/fastlane/plugin/bowl/actions/set_gradle_property_action.rb, line 39 def self.available_options [ FastlaneCore::ConfigItem.new(key: :app_project_dir, env_name: "BOWL_APP_PROJECT_DIR", description: "The path to the application source folder in the Android project (default: android/app)", optional: true, type: String, default_value: "android/app"), FastlaneCore::ConfigItem.new(key: :key, description: "The property key", type: String), FastlaneCore::ConfigItem.new(key: :value, description: "The property value", type: String) ] end
description()
click to toggle source
# File lib/fastlane/plugin/bowl/actions/set_gradle_property_action.rb, line 56 def self.description "Set the value of your project" end
details()
click to toggle source
# File lib/fastlane/plugin/bowl/actions/set_gradle_property_action.rb, line 60 def self.details [ "This action will set the value directly in build.gradle . " ].join("\n") end
is_supported?(platform)
click to toggle source
# File lib/fastlane/plugin/bowl/actions/set_gradle_property_action.rb, line 70 def self.is_supported?(platform) platform == :android end
run(params)
click to toggle source
# File lib/fastlane/plugin/bowl/actions/set_gradle_property_action.rb, line 9 def self.run(params) app_project_dir ||= params[:app_project_dir] regex = Regexp.new(/(?<key>#{params[:key]}\s+)(?<eql>=\s+)?(?<left>[\'\"]?)(?<value>[a-zA-Z0-9\.\_]*)(?<right>[\'\"]?)(?<comment>.*)/) found = false Dir.glob("#{app_project_dir}/build.gradle") do |path| begin temp_file = Tempfile.new('versioning') File.open(path, 'r') do |file| file.each_line do |line| unless line.match(regex) and !found temp_file.puts line next end line = line.gsub regex, "\\k<key>\\k<eql>\\k<left>#{params[:value]}\\k<right>\\k<comment>" found = true temp_file.puts line end file.close end temp_file.rewind temp_file.close FileUtils.mv(temp_file.path, path) temp_file.unlink end end end