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 =
%w(build.gradle build.gradle.kts).freeze
- SUPPORTED_SETTINGS_FILE_NAMES =
%w(settings.gradle settings.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"
- 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.
32 33 34 35 36 |
# File 'lib/dependabot/gradle/file_parser/repositories_finder.rb', line 32 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_urls ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/dependabot/gradle/file_parser/repositories_finder.rb', line 38 def repository_urls repository_urls = [] repository_urls += inherited_repository_urls(top_level_buildfile) FileParser.find_includes(top_level_buildfile, dependency_files).each do |dependency_file| repository_urls += inherited_repository_urls(dependency_file) 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 |