Class: Dependabot::Gradle::FileParser::RepositoriesFinder
- Inherits:
-
Object
- Object
- Dependabot::Gradle::FileParser::RepositoriesFinder
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/gradle/file_parser/repositories_finder.rb
Constant Summary collapse
- SUPPORTED_BUILD_FILE_NAMES =
T.let(%w(build.gradle build.gradle.kts).freeze, T::Array[String])
- SUPPORTED_SETTINGS_FILE_NAMES =
T.let(%w(settings.gradle settings.gradle.kts).freeze, T::Array[String])
- 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"- GOOGLE_MAVEN_REPO =
"https://maven.google.com"- GRADLE_PLUGINS_REPO =
"https://plugins.gradle.org/m2"- REPOSITORIES_BLOCK_START =
/(?:^|\s)repositories\s*\{/- GROOVY_MAVEN_REPO_REGEX =
/maven\s*\{[^\}]*\surl[\s\(]=?[^'"]*['"](?<url>[^'"]+)['"]/- KOTLIN_MAVEN_REPO_REGEX =
/maven\((url\s?\=\s?)?["](?<url>[^"]+)["]\)/- MAVEN_REPO_REGEX =
/(#{KOTLIN_MAVEN_REPO_REGEX}|#{GROOVY_MAVEN_REPO_REGEX})/
Instance Method Summary collapse
-
#initialize(dependency_files:, target_dependency_file:) ⇒ RepositoriesFinder
constructor
A new instance of RepositoriesFinder.
- #repository_urls ⇒ Object
Constructor Details
#initialize(dependency_files:, target_dependency_file:) ⇒ RepositoriesFinder
Returns a new instance of RepositoriesFinder.
38 39 40 41 42 43 |
# File 'lib/dependabot/gradle/file_parser/repositories_finder.rb', line 38 def initialize(dependency_files:, target_dependency_file:) @dependency_files = T.let(dependency_files, T::Array[Dependabot::DependencyFile]) raise "No target file!" unless target_dependency_file @target_dependency_file = T.let(target_dependency_file, Dependabot::DependencyFile) end |
Instance Method Details
#repository_urls ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/dependabot/gradle/file_parser/repositories_finder.rb', line 46 def repository_urls repository_urls = T.let([], T::Array[String]) repository_urls += inherited_repository_urls(top_level_buildfile) if top_level_buildfile FileParser.find_includes(T.must(top_level_buildfile), dependency_files).each do |dependency_file| repository_urls += inherited_repository_urls(dependency_file) end end repository_urls += own_buildfile_repository_urls repository_urls += settings_file_repository_urls(top_level_settings_file) repository_urls = repository_urls.uniq return repository_urls unless repository_urls.empty? [CENTRAL_REPO_URL] end |