Class: Fastlane::Actions::FlutterBuildAction

Inherits:
Action
  • Object
show all
Extended by:
FlutterActionBase
Defined in:
lib/fastlane/plugin/flutter/actions/flutter_build_action.rb

Constant Summary collapse

FASTLANE_PLATFORM_TO_BUILD =
{
  ios: 'ios',
  android: 'apk',
}

Class Method Summary collapse

Methods included from FlutterActionBase

authors, is_supported?

Class Method Details

.available_optionsObject



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
# File 'lib/fastlane/plugin/flutter/actions/flutter_build_action.rb', line 103

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :build,
      env_name: 'FL_FLUTTER_BUILD',
      description: 'Type of Flutter build (e.g. apk, appbundle, ios)',
      optional: true,
      type: String,
    ),
    FastlaneCore::ConfigItem.new(
      key: :debug,
      env_name: 'FL_FLUTTER_DEBUG',
      description: 'Build a Debug version of the app if true',
      optional: true,
      type: Boolean,
      default_value: false,
    ),
    FastlaneCore::ConfigItem.new(
      key: :codesign,
      env_name: 'FL_FLUTTER_CODESIGN',
      description: 'Set to false to skip iOS app signing. This may be ' \
      'useful e.g. on CI or when signed later by Fastlane "sigh"',
      optional: true,
      type: Boolean,
    ),
    FastlaneCore::ConfigItem.new(
      key: :build_number,
      env_name: 'FL_FLUTTER_BUILD_NUMBER',
      description: 'Override build number specified in pubspec.yaml',
      optional: true,
      type: Integer,
    ),
    FastlaneCore::ConfigItem.new(
      key: :build_name,
      env_name: 'FL_FLUTTER_BUILD_NAME',
      description: "        Override build name specified in pubspec.yaml.\n        NOTE: for App Store, build name must be in the format of at most 3\n              integeres separated by a dot (\".\").\n      DESCRIPTION\n      optional: true,\n    ),\n    FastlaneCore::ConfigItem.new(\n      key: :build_args,\n      description: 'An array of extra arguments for \"flutter build\"',\n      optional: true,\n      type: Array,\n    ),\n  ]\nend\n",

.categoryObject



95
96
97
# File 'lib/fastlane/plugin/flutter/actions/flutter_build_action.rb', line 95

def self.category
  :building
end

.descriptionObject



91
92
93
# File 'lib/fastlane/plugin/flutter/actions/flutter_build_action.rb', line 91

def self.description
  'Run "flutter build" to build a Flutter application'
end

.process_deprecated_params(params, build_args) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/fastlane/plugin/flutter/actions/flutter_build_action.rb', line 73

def self.process_deprecated_params(params, build_args)
  unless params[:codesign].nil?
    UI.deprecated("flutter_build parameter \"codesign\" is deprecated. Use\n\n  flutter_build(\n    build_args: [\"--\#{params[:codesign] == false ? 'no-' : ''}codesign\"]\n  )\n\nform instead.\n    MESSAGE\n\n    if params[:codesign] == false\n      build_args.push('--no-codesign')\n    end\n  end\nend\n")

.return_valueObject



99
100
101
# File 'lib/fastlane/plugin/flutter/actions/flutter_build_action.rb', line 99

def self.return_value
  'A path to the built file, if available'
end

.run(params) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/fastlane/plugin/flutter/actions/flutter_build_action.rb', line 19

def self.run(params)
  # "flutter build" args list.
  build_args = []

  if params[:build]
    build_args.push(params[:build])
  else
    if fastlane_platform = (lane_context[SharedValues::PLATFORM_NAME] ||
                            lane_context[SharedValues::DEFAULT_PLATFORM])
      build_args.push(FASTLANE_PLATFORM_TO_BUILD[fastlane_platform])
    else
      UI.user_error!('flutter_build action "build" parameter is not ' \
      'specified and cannot be inferred from Fastlane context.')
    end
  end

  process_deprecated_params(params, build_args)

  if params[:debug]
    build_args.push('--debug')
  end

  if build_number = (params[:build_number] ||
                     lane_context[SharedValues::BUILD_NUMBER])
    build_args.push('--build-number', build_number.to_s)
  end

  if build_name = (params[:build_name] ||
                   lane_context[SharedValues::VERSION_NUMBER])
    build_args.push('--build-name', build_name.to_s)
  end

  build_args += params[:build_args] || []

  Helper::FlutterHelper.flutter('build', *build_args) do |status, res|
    if status.success?
      if res =~ /^Built (.*?)(:? \([^)]*\))?\.$/
        lane_context[SharedValues::FLUTTER_OUTPUT] =
          File.absolute_path($1)
      else
        UI.important('Cannot parse built file path from "flutter build"')
      end
    else
      # Print stdout from "flutter build" because it may contain useful
      # details about failures, and it's normally not very verbose.
      UI.command_output(res)
    end
    # Tell upstream to NOT ignore error.
    false
  end

  lane_context[SharedValues::FLUTTER_OUTPUT]
end