Class: Fastlane::Actions::UnityAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/unity/actions/unity_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



46
47
48
# File 'lib/fastlane/plugin/unity/actions/unity_action.rb', line 46

def self.authors
  ['safu9']
end

.available_optionsObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/fastlane/plugin/unity/actions/unity_action.rb', line 59

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :unity_path,
      env_name: 'FL_UNITY_PATH',
      description: 'Path to Unity executable',
      optional: true,
      conflicting_options: [:unity_version]
    ),

    FastlaneCore::ConfigItem.new(
      key: :unity_version,
      env_name: 'FL_UNITY_VERSION',
      description: 'Unity version to execute',
      optional: true,
      conflicting_options: [:unity_path]
    ),

    FastlaneCore::ConfigItem.new(
      key: :project_path,
      env_name: 'FL_UNITY_PROJECT_PATH',
      description: 'Path to Unity project',
      default_value: Dir.pwd,
      optional: true
    ),

    FastlaneCore::ConfigItem.new(
      key: :batchmode,
      env_name: 'FL_UNITY_BATCHMODE',
      description: 'Run command in batch mode',
      default_value: true,
      is_string: false
    ),

    FastlaneCore::ConfigItem.new(
      key: :nographics,
      env_name: 'FL_UNITY_NOGRAPHICS',
      description: 'Do not initialize the graphics device',
      default_value: true,
      is_string: false
    ),

    FastlaneCore::ConfigItem.new(
      key: :quit,
      env_name: 'FL_UNITY_QUIT',
      description: 'Quit the Unity after command execution',
      default_value: true,
      is_string: false
    ),

    FastlaneCore::ConfigItem.new(
      key: :logfile,
      env_name: 'FL_UNITY_LOGFILE',
      description: 'Path to output log file (Default is console)',
      optional: true,
      default_value: '-'
    ),

    FastlaneCore::ConfigItem.new(
      key: :username,
      env_name: 'FL_UNITY_USERNAME',
      description: 'Username to log in',
      optional: true
    ),

    FastlaneCore::ConfigItem.new(
      key: :password,
      env_name: 'FL_UNITY_PASSWORD',
      description: 'Password to log in',
      optional: true
    ),

    FastlaneCore::ConfigItem.new(
      key: :build_target,
      env_name: 'FL_UNITY_BUILD_TARGET',
      description: 'Active build target',
      optional: true
    ),

    FastlaneCore::ConfigItem.new(
      key: :execute_method,
      env_name: 'FL_UNITY_EXECUTE_METHOD',
      description: 'Static method to execute',
      optional: true
    ),

    FastlaneCore::ConfigItem.new(
      key: :enable_cache_server,
      env_name: 'FL_UNITY_ENABLE_CACHE_SERVER',
      description: 'Enable usage of Accelerator Cache Server',
      default_value: false,
      is_string: false
    ),

    FastlaneCore::ConfigItem.new(
      key: :cache_server_endpoint,
      env_name: 'FL_UNITY_CACHE_SERVER_ENDPOINT',
      description: 'Endpoint address of Accelerator Cache Server',
      optional: true
    ),

    FastlaneCore::ConfigItem.new(
      key: :cache_server_namespace_prefix,
      env_name: 'FL_UNITY_CACHE_SERVER_NAMESPACE_PREFIX',
      description: 'Namespace prefix for Accelerator Cache Server',
      optional: true
    ),

    FastlaneCore::ConfigItem.new(
      key: :cache_server_enable_download,
      env_name: 'FL_UNITY_CACHE_SERVER_ENABLE_DOWNLOAD',
      description: 'Enable downloading from Accelerator Cache Server',
      optional: true,
      default_value: nil,
      is_string: false
    ),

    FastlaneCore::ConfigItem.new(
      key: :cache_server_enable_upload,
      env_name: 'FL_UNITY_CACHE_SERVER_ENABLE_UPLOAD',
      description: 'Enable uploading to Accelerator Cache Server',
      optional: true,
      default_value: nil,
      is_string: false
    ),

    FastlaneCore::ConfigItem.new(
      key: :extra_args,
      env_name: 'FL_UNITY_EXTRA_ARGS',
      description: 'Extra arguments',
      optional: true
    )
  ]
end

.descriptionObject



42
43
44
# File 'lib/fastlane/plugin/unity/actions/unity_action.rb', line 42

def self.description
  'Fastlane plugin for Unity'
end

.detailsObject



54
55
56
57
# File 'lib/fastlane/plugin/unity/actions/unity_action.rb', line 54

def self.details
  # Optional:
  'Fastlane plugin for Unity. Easily run Unity to build, test and execute method from fastlane.'
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


194
195
196
197
198
199
200
# File 'lib/fastlane/plugin/unity/actions/unity_action.rb', line 194

def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
  #
  # [:ios, :mac, :android].include?(platform)
  true
end

.return_valueObject



50
51
52
# File 'lib/fastlane/plugin/unity/actions/unity_action.rb', line 50

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fastlane/plugin/unity/actions/unity_action.rb', line 7

def self.run(params)
  unity_path = params[:unity_path]
  unity_path ||= Helper::UnityHelper.find_unity_path(params[:unity_version])
  UI.user_error!('Cannot find path to unity executable!') unless unity_path

  cmd = "\"#{unity_path}\""
  cmd << " -projectPath \"#{params[:project_path]}\"" if params[:project_path]
  cmd << ' -batchmode' if params[:batchmode]
  cmd << ' -nographics' if params[:nographics]
  cmd << ' -quit' if params[:quit]

  cmd << ' -logfile -' if params[:logfile] == '-'
  cmd << " -logfile \"#{params[:logfile]}\"" if params[:logfile] && params[:logfile] != '-'

  cmd << " -username #{params[:username]}" if params[:username]
  cmd << " -password #{params[:password]}" if params[:password]

  cmd << " -buildTarget #{params[:build_target]}" if params[:build_target]
  cmd << " -executeMethod #{params[:execute_method]}" if params[:execute_method]

  cmd << ' -adb2 -EnableCacheServer' if params[:enable_cache_server]
  cmd << " -cacheServerEndpoint #{params[:cache_server_endpoint]}" if params[:cache_server_endpoint]
  cmd << " -cacheServerNamespacePrefix #{params[:cache_server_namespace_prefix]}" if params[:cache_server_namespace_prefix]
  cmd << " -cacheServerEnableDownload #{params[:cache_server_enable_download]}" unless params[:cache_server_enable_download].nil?
  cmd << " -cacheServerEnableUpload #{params[:cache_server_enable_upload]}" unless params[:cache_server_enable_upload].nil?

  cmd << " #{params[:extra_args]}" if params[:extra_args]

  FastlaneCore::CommandExecutor.execute(
    command: cmd,
    print_all: true,
    print_command: true
  )
end