Class: Dependabot::Gradle::FileParser

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

Defined Under Namespace

Classes: PropertyValueFinder, RepositoriesFinder

Constant Summary collapse

SUPPORTED_BUILD_FILE_NAMES =
%w(build.gradle build.gradle.kts).freeze
PROPERTY_REGEX =
/
  (?:\$\{property\((?<property_name>[^:\s]*?)\)\})|
  (?:\$\{(?<property_name>[^:\s]*?)\})|
  (?:\$(?<property_name>[^:\s"']*))
/x.freeze
PART =
%r{[^\s,@'":/\\]+}.freeze
VSN_PART =
%r{[^\s,'":/\\]+}.freeze
DEPENDENCY_DECLARATION_REGEX =
/(?:\(|\s)\s*['"](?<declaration>#{PART}:#{PART}:#{VSN_PART})['"]/.
freeze
DEPENDENCY_SET_DECLARATION_REGEX =
/(?:^|\s)dependencySet\((?<arguments>[^\)]+)\)\s*\{/.freeze
DEPENDENCY_SET_ENTRY_REGEX =
/entry\s+['"](?<name>#{PART})['"]/.freeze
PLUGIN_BLOCK_DECLARATION_REGEX =
/(?:^|\s)plugins\s*\{/.freeze
PLUGIN_ID_REGEX =
/['"](?<id>#{PART})['"]/.freeze

Instance Method Summary collapse

Instance Method Details

#parseObject



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

def parse
  dependency_set = DependencySet.new
  buildfiles.each do |buildfile|
    dependency_set += buildfile_dependencies(buildfile)
  end
  script_plugin_files.each do |plugin_file|
    dependency_set += buildfile_dependencies(plugin_file)
  end
  dependency_set.dependencies
end