Class: Dependabot::Gradle::FileUpdater::Wrapper::CommandBuilder

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/gradle/file_updater/wrapper/command_builder.rb

Overview

Builds the argument list for Gradle’s ‘wrapper` task.

The output file is reconciled afterwards (see PropertiesReconciler), so these arguments do not need to fully reproduce the user’s file. We still forward the user’s gated, run-relevant settings (networkTimeout/retries/retryBackOffMs) when the executing Gradle version supports them, both to honor the user’s configuration during the run and to align with the wrapper task’s intended usage. Options unsupported by the executing version are omitted so the run never aborts on an unknown flag.

Constant Summary collapse

STEERED_OPTIONS =

Maps an existing properties key to its wrapper CLI option and the capability key used to decide whether the executing Gradle version understands the flag.

T.let(
  [
    ["networkTimeout", "--network-timeout", GradleVersionCapabilities::NETWORK_TIMEOUT],
    ["retries", "--retries", GradleVersionCapabilities::RETRIES],
    ["retryBackOffMs", "--retry-back-off-ms", GradleVersionCapabilities::RETRY_BACK_OFF_MS]
  ].freeze,
  T::Array[[String, String, String]]
)

Instance Method Summary collapse

Constructor Details

#initialize(requirements:, original_properties:, gradle_version:) ⇒ CommandBuilder

Returns a new instance of CommandBuilder.



43
44
45
46
47
# File 'lib/dependabot/gradle/file_updater/wrapper/command_builder.rb', line 43

def initialize(requirements:, original_properties:, gradle_version:)
  @requirements = requirements
  @original_properties = original_properties
  @gradle_version = gradle_version
end

Instance Method Details

#buildObject



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/dependabot/gradle/file_updater/wrapper/command_builder.rb', line 50

def build
  args = %W(wrapper --gradle-version #{version})

  # Dependabot's proxy cannot satisfy the HEAD request Gradle issues to validate the
  # distribution URL, so we always skip validation. The user's original
  # `validateDistributionUrl` value is preserved by reconciliation.
  args += %w(--no-validate-url)

  args += steered_args
  args += %W(--distribution-type #{distribution_type}) if distribution_type
  args += %W(--gradle-distribution-sha256-sum #{checksum}) if checksum
  args
end