Class: Pindo::TaskSystem::BuildTask
- Defined in:
- lib/pindo/module/task/model/build_task.rb
Overview
BuildTask 抽象基类提供构建任务的通用框架和工厂方法
Direct Known Subclasses
Instance Attribute Summary collapse
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#output_path ⇒ Object
readonly
Returns the value of attribute output_path.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
-
#project_path ⇒ Object
readonly
Returns the value of attribute project_path.
Attributes inherited from PindoTask
#callbacks_setup, #context, #created_at, #dependencies, #error, #finished_at, #id, #max_retry_count, #metadata, #name, #priority, #result, #retry_count, #retry_delay, #retry_mode, #skip_count, #started_at, #status, #task_key, #task_manager, #type
Class Method Summary collapse
-
.create_android_task(mode, options) ⇒ Object
创建 Android 构建任务.
-
.create_ios_task(mode, options) ⇒ Object
创建 iOS 构建任务.
-
.create_task(platform:, mode:, options: {}) ⇒ BuildTask
根据 platform 和 mode 创建对应的构建任务实例.
-
.create_web_task(mode, options) ⇒ Object
创建 Web 构建任务.
- .default_retry_count ⇒ Object
- .default_retry_delay ⇒ Object
-
.default_retry_mode ⇒ Object
重试配置.
-
.normalize_mode(mode) ⇒ Object
标准化构建模式.
-
.normalize_platform(platform) ⇒ Object
标准化平台名称.
-
.task_type ⇒ Object
任务类型.
-
.task_type_name ⇒ Object
任务类型显示名称.
Instance Method Summary collapse
-
#initialize(name, options = {}) ⇒ BuildTask
constructor
实例方法 ==========.
-
#required_resources ⇒ Object
声明所需资源 - 添加通用的 build 资源锁 确保同一项目(git 仓库或目录)下的所有构建任务串行执行.
Methods inherited from PindoTask
#before_retry, #cancel, #cancelled?, #check_cancelled!, #data_param, #do_task, #execution_time, #finished?, #get_all_data_params, #get_all_data_params_by_key, #get_all_dependencies_results, #get_data_param, #get_data_param_by_key, #get_dependency_result, #get_dependency_task, #on, #primary_data_param, #release_resource, #release_resources, #reset_for_retry, #retryable?, #running?, #should_retry?, task_key, #validate, #with_resource, #with_resources
Constructor Details
#initialize(name, options = {}) ⇒ BuildTask
实例方法 ==========
146 147 148 149 150 151 152 153 |
# File 'lib/pindo/module/task/model/build_task.rb', line 146 def initialize(name, = {}) @platform = [:platform] @mode = [:mode] @project_path = [:project_path] || Dir.pwd @output_path = nil super(name, ) end |
Instance Attribute Details
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
10 11 12 |
# File 'lib/pindo/module/task/model/build_task.rb', line 10 def mode @mode end |
#output_path ⇒ Object (readonly)
Returns the value of attribute output_path.
10 11 12 |
# File 'lib/pindo/module/task/model/build_task.rb', line 10 def output_path @output_path end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
10 11 12 |
# File 'lib/pindo/module/task/model/build_task.rb', line 10 def platform @platform end |
#project_path ⇒ Object (readonly)
Returns the value of attribute project_path.
10 11 12 |
# File 'lib/pindo/module/task/model/build_task.rb', line 10 def project_path @project_path end |
Class Method Details
.create_android_task(mode, options) ⇒ Object
创建 Android 构建任务
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/pindo/module/task/model/build_task.rb', line 114 def self.create_android_task(mode, ) require_relative 'build/android_build_dev_task' require_relative 'build/android_build_adhoc_task' require_relative 'build/android_build_gplay_task' case mode when :dev, :debug AndroidBuildDevTask.new() when :adhoc AndroidBuildAdhocTask.new() when :release AndroidBuildGPlayTask.new() else raise ArgumentError, "不支持的 Android 构建模式: #{mode}" end end |
.create_ios_task(mode, options) ⇒ Object
创建 iOS 构建任务
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/pindo/module/task/model/build_task.rb', line 96 def self.create_ios_task(mode, ) require_relative 'build/ios_build_dev_task' require_relative 'build/ios_build_adhoc_task' require_relative 'build/ios_build_appstore_task' case mode when :dev IosBuildDevTask.new() when :adhoc IosBuildAdhocTask.new() when :release IosBuildAppStoreTask.new() else raise ArgumentError, "不支持的 iOS 构建模式: #{mode}" end end |
.create_task(platform:, mode:, options: {}) ⇒ BuildTask
根据 platform 和 mode 创建对应的构建任务实例
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/pindo/module/task/model/build_task.rb', line 49 def self.create_task(platform:, mode:, options: {}) normalized_platform = normalize_platform(platform) normalized_mode = normalize_mode(mode) case normalized_platform when :ios create_ios_task(normalized_mode, ) when :android create_android_task(normalized_mode, ) when :web create_web_task(normalized_mode, ) else raise ArgumentError, "不支持的平台: #{platform}" end end |
.create_web_task(mode, options) ⇒ Object
创建 Web 构建任务
132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/pindo/module/task/model/build_task.rb', line 132 def self.create_web_task(mode, ) require_relative 'build/web_build_dev_task' case mode when :dev, :debug, :release # Web 目前只有一个构建任务类 WebBuildDevTask.new() else raise ArgumentError, "不支持的 Web 构建模式: #{mode}" end end |
.default_retry_count ⇒ Object
27 28 29 |
# File 'lib/pindo/module/task/model/build_task.rb', line 27 def self.default_retry_count 0 end |
.default_retry_delay ⇒ Object
31 32 33 |
# File 'lib/pindo/module/task/model/build_task.rb', line 31 def self.default_retry_delay 10 end |
.default_retry_mode ⇒ Object
重试配置
23 24 25 |
# File 'lib/pindo/module/task/model/build_task.rb', line 23 def self.default_retry_mode RetryMode::DELAYED end |
.normalize_mode(mode) ⇒ Object
标准化构建模式
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/pindo/module/task/model/build_task.rb', line 81 def self.normalize_mode(mode) mode_str = mode.to_s.downcase case mode_str when 'dev', 'debug', 'development' :dev when 'adhoc', 'ad-hoc' :adhoc when 'release', 'production', 'deploy' :release else raise ArgumentError, "未知构建模式: #{mode}" end end |
.normalize_platform(platform) ⇒ Object
标准化平台名称
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/pindo/module/task/model/build_task.rb', line 66 def self.normalize_platform(platform) platform_str = platform.to_s.downcase case platform_str when 'ios', 'ipa' :ios when 'android', 'apk', 'aab' :android when 'web', 'html', 'webgl' :web else raise ArgumentError, "未知平台: #{platform}" end end |
.task_type ⇒ Object
任务类型
13 14 15 |
# File 'lib/pindo/module/task/model/build_task.rb', line 13 def self.task_type :build end |
.task_type_name ⇒ Object
任务类型显示名称
18 19 20 |
# File 'lib/pindo/module/task/model/build_task.rb', line 18 def self.task_type_name "编译构建" end |
Instance Method Details
#required_resources ⇒ Object
声明所需资源 - 添加通用的 build 资源锁确保同一项目(git 仓库或目录)下的所有构建任务串行执行
37 38 39 40 |
# File 'lib/pindo/module/task/model/build_task.rb', line 37 def required_resources build_lock_dir = get_build_lock_directory (super || []) + [{ type: :build, directory: build_lock_dir }] end |