Sha256: 4d960b057ccd79ad651c97eaf8a2445fa194df7258dadacee95eb8814f32b96a

Contents?: true

Size: 1.73 KB

Versions: 1159

Compression:

Stored size: 1.73 KB

Contents

module Fastlane
  module Helper
    class GradleTask
      attr_accessor :title

      attr_accessor :description

      def initialize(title: nil, description: nil)
        self.title = title
        self.description = description
      end
    end

    class GradleHelper
      # Path to the gradle script
      attr_accessor :gradle_path

      # Read-only path to the shell-escaped gradle script, suitable for use in shell commands
      attr_reader :escaped_gradle_path

      # All the available tasks
      attr_accessor :tasks

      def initialize(gradle_path: nil)
        self.gradle_path = gradle_path
      end

      # Run a certain action
      def trigger(task: nil, flags: nil, serial: nil, print_command: true, print_command_output: true)
        android_serial = (serial != "") ? "ANDROID_SERIAL=#{serial}" : nil
        command = [android_serial, escaped_gradle_path, task, flags].compact.join(" ")
        Action.sh(command, print_command: print_command, print_command_output: print_command_output)
      end

      def task_available?(task)
        load_all_tasks
        return tasks.collect(&:title).include?(task)
      end

      def gradle_path=(gradle_path)
        @gradle_path = gradle_path
        @escaped_gradle_path = gradle_path.shellescape
      end

      private

      def load_all_tasks
        self.tasks = []

        command = [escaped_gradle_path, "tasks", "--console=plain"].join(" ")
        output = Action.sh(command, print_command: false, print_command_output: false)
        output.split("\n").each do |line|
          if (result = line.match(/(\w+)\s\-\s([\w\s]+)/))
            self.tasks << GradleTask.new(title: result[1], description: result[2])
          end
        end

        self.tasks
      end
    end
  end
end

Version data entries

1,159 entries across 1,159 versions & 5 rubygems

Version Path
fastlane-2.129.0.beta.20190723200012 fastlane/lib/fastlane/helper/gradle_helper.rb
fastlane-2.128.0 fastlane/lib/fastlane/helper/gradle_helper.rb
fastlane-2.128.0.beta.20190722200021 fastlane/lib/fastlane/helper/gradle_helper.rb
fastlane-2.128.0.beta.20190721200024 fastlane/lib/fastlane/helper/gradle_helper.rb
fastlane-2.128.0.beta.20190720200049 fastlane/lib/fastlane/helper/gradle_helper.rb
fastlane_iac_publish-0.1.5 fastlane/lib/fastlane/helper/gradle_helper.rb
fastlane-2.127.2 fastlane/lib/fastlane/helper/gradle_helper.rb
fastlane-2.128.0.beta.20190719200019 fastlane/lib/fastlane/helper/gradle_helper.rb
fastlane-2.128.0.beta.20190718200101 fastlane/lib/fastlane/helper/gradle_helper.rb
fastlane-2.128.0.beta.20190717200026 fastlane/lib/fastlane/helper/gradle_helper.rb
fastlane-2.128.0.beta.20190716200022 fastlane/lib/fastlane/helper/gradle_helper.rb
fastlane-2.128.0.beta.20190715200056 fastlane/lib/fastlane/helper/gradle_helper.rb
fastlane-2.128.0.beta.20190714200028 fastlane/lib/fastlane/helper/gradle_helper.rb
fastlane-2.128.0.beta.20190713200107 fastlane/lib/fastlane/helper/gradle_helper.rb
fastlane-2.128.0.beta.20190712200059 fastlane/lib/fastlane/helper/gradle_helper.rb
fastlane-2.128.0.beta.20190711200117 fastlane/lib/fastlane/helper/gradle_helper.rb
fastlane-2.127.1 fastlane/lib/fastlane/helper/gradle_helper.rb
fastlane-2.128.0.beta.20190710200106 fastlane/lib/fastlane/helper/gradle_helper.rb
fastlane-2.127.0 fastlane/lib/fastlane/helper/gradle_helper.rb
fastlane-2.127.0.beta.20190709200015 fastlane/lib/fastlane/helper/gradle_helper.rb