Class: Dependabot::Gradle::FileParser::RepositoriesFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/gradle/file_parser/repositories_finder.rb

Constant Summary collapse

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

The Central Repo doesn’t have special status for Gradle, but until we’re confident we’re selecting repos correctly it’s wise to include it as a default.

"https://repo.maven.apache.org/maven2"
REPOSITORIES_BLOCK_START =
/(?:^|\s)repositories\s*\{/.freeze
GROOVY_MAVEN_REPO_REGEX =
/maven\s*\{[^\}]*\surl[\s\(]=?\s*['"](?<url>[^'"]+)['"]/.freeze
KOTLIN_MAVEN_REPO_REGEX =
/maven\((url\s?\=\s?)?["](?<url>[^"]+)["]\)/.freeze
MAVEN_REPO_REGEX =
/(#{KOTLIN_MAVEN_REPO_REGEX}|#{GROOVY_MAVEN_REPO_REGEX})/.freeze

Instance Method Summary collapse

Constructor Details

#initialize(dependency_files:, target_dependency_file:) ⇒ RepositoriesFinder

Returns a new instance of RepositoriesFinder.



27
28
29
30
31
# File 'lib/dependabot/gradle/file_parser/repositories_finder.rb', line 27

def initialize(dependency_files:, target_dependency_file:)
  @dependency_files = dependency_files
  @target_dependency_file = target_dependency_file
  raise "No target file!" unless target_dependency_file
end

Instance Method Details

#repository_urlsObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/dependabot/gradle/file_parser/repositories_finder.rb', line 33

def repository_urls
  repository_urls = []
  repository_urls += inherited_repository_urls
  repository_urls += own_buildfile_repository_urls
  repository_urls = repository_urls.uniq

  return repository_urls unless repository_urls.empty?

  [CENTRAL_REPO_URL]
end