Class: Dependabot::UpdateCheckers::Java::Gradle

Inherits:
Base
  • Object
show all
Defined in:
lib/dependabot/update_checkers/java/gradle.rb,
lib/dependabot/update_checkers/java/gradle/version_finder.rb,
lib/dependabot/update_checkers/java/gradle/multi_dependency_updater.rb

Defined Under Namespace

Classes: MultiDependencyUpdater, VersionFinder

Instance Attribute Summary

Attributes inherited from Base

#credentials, #dependency, #dependency_files, #ignored_versions, #requirements_update_strategy

Instance Method Summary collapse

Methods inherited from Base

#can_update?, #initialize, #requirement_class, #up_to_date?, #updated_dependencies, #version_class

Constructor Details

This class inherits a constructor from Dependabot::UpdateCheckers::Base

Instance Method Details

#latest_resolvable_versionObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/dependabot/update_checkers/java/gradle.rb', line 18

def latest_resolvable_version
  # TODO: Resolve the build.gradle to find the latest version we could
  # update to without updating any other dependencies at the same time.
  #
  # The above is hard. Currently we just return the latest version and
  # hope (hence this package manager is in beta!)
  return nil if version_comes_from_multi_dependency_property?
  return nil if version_comes_from_dependency_set?

  latest_version
end

#latest_resolvable_version_with_no_unlockObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/dependabot/update_checkers/java/gradle.rb', line 30

def latest_resolvable_version_with_no_unlock
  # Irrelevant, since Gradle has a single dependency file.
  #
  # For completeness we ought to resolve the build.gradle and return the
  # latest version that satisfies the current constraint AND any
  # constraints placed on it by other dependencies. Seeing as we're
  # never going to take any action as a result, though, we just return
  # nil.
  nil
end

#latest_versionObject



14
15
16
# File 'lib/dependabot/update_checkers/java/gradle.rb', line 14

def latest_version
  latest_version_details&.fetch(:version)
end

#requirements_unlocked_or_can_be?Boolean

Returns:

  • (Boolean)


54
55
56
57
58
# File 'lib/dependabot/update_checkers/java/gradle.rb', line 54

def requirements_unlocked_or_can_be?
  # If the dependency version come from a property we couldn't
  # interpolate then there's nothing we can do.
  !dependency.version.include?("$")
end

#updated_requirementsObject



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/dependabot/update_checkers/java/gradle.rb', line 41

def updated_requirements
  property_names =
    declarations_using_a_property.
    map { |req| req.dig(:metadata, :property_name) }

  Maven::RequirementsUpdater.new(
    requirements: dependency.requirements,
    latest_version: latest_version&.to_s,
    source_url: latest_version_details&.fetch(:source_url),
    properties_to_update: property_names
  ).updated_requirements
end