Class: Dependabot::Gradle::FileUpdater

Inherits:
FileUpdaters::Base
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/gradle/file_updater.rb,
lib/dependabot/gradle/file_updater/dependency_set_updater.rb,
lib/dependabot/gradle/file_updater/property_value_updater.rb

Defined Under Namespace

Classes: DependencySetUpdater, PropertyValueUpdater

Constant Summary collapse

SUPPORTED_BUILD_FILE_NAMES =
%w(build.gradle build.gradle.kts).freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.updated_files_regexObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dependabot/gradle/file_updater.rb', line 20

def self.updated_files_regex
  [
    # Matches build.gradle or build.gradle.kts in root directory
    %r{(^|.*/)build\.gradle(\.kts)?$},
    # Matches gradle/libs.versions.toml in root or any subdirectory
    %r{(^|.*/)?gradle/libs\.versions\.toml$},
    # Matches settings.gradle or settings.gradle.kts in root or any subdirectory
    %r{(^|.*/)settings\.gradle(\.kts)?$},
    # Matches dependencies.gradle in root or any subdirectory
    %r{(^|.*/)dependencies\.gradle$}
  ]
end

Instance Method Details

#updated_dependency_filesObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/dependabot/gradle/file_updater.rb', line 33

def updated_dependency_files
  updated_files = buildfiles.dup

  # Loop through each of the changed requirements, applying changes to
  # all buildfiles for that change. Note that the logic is different
  # here to other languages because Java has property inheritance across
  # files (although we're not supporting it for gradle yet).
  dependencies.each do |dependency|
    updated_files = update_buildfiles_for_dependency(
      buildfiles: updated_files,
      dependency: dependency
    )
  end

  updated_files = updated_files.reject { |f| buildfiles.include?(f) }

  raise "No files changed!" if updated_files.none?

  updated_files
end