Class: Dependabot::Sbt::FileFetcher

Inherits:
FileFetchers::Base
  • Object
show all
Extended by:
T::Helpers, T::Sig
Defined in:
lib/dependabot/sbt/file_fetcher.rb

Constant Summary collapse

BUILD_SBT_FILENAME =
"build.sbt"
PLUGINS_SBT_FILENAME =
"project/plugins.sbt"
BUILD_PROPERTIES_FILENAME =
"project/build.properties"
NON_SUBPROJECT_DIRS =

Directories that are part of the SBT build structure, not subprojects

T.let(%w(project target .git .github).freeze, T::Array[String])

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.required_files_in?(filenames) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/dependabot/sbt/file_fetcher.rb', line 23

def self.required_files_in?(filenames)
  filenames.any? { |name| name.end_with?(BUILD_SBT_FILENAME) }
end

.required_files_messageObject



28
29
30
# File 'lib/dependabot/sbt/file_fetcher.rb', line 28

def self.required_files_message
  "Repo must contain a build.sbt file."
end

Instance Method Details

#ecosystem_versionsObject



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/dependabot/sbt/file_fetcher.rb', line 56

def ecosystem_versions
  return nil unless build_properties

  sbt_version = parse_sbt_version(T.must(build_properties).content)
  return nil unless sbt_version

  {
    package_managers: {
      "sbt" => sbt_version
    }
  }
end

#fetch_filesObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/dependabot/sbt/file_fetcher.rb', line 33

def fetch_files
  unless allow_beta_ecosystems?
    raise Dependabot::DependencyFileNotFound.new(
      nil,
      "Sbt support is currently in beta. Enable the beta ecosystems experiment to use it " \
      "(for example, run bin/dry-run.rb --enable-beta-ecosystems)."
    )
  end

  fetched_files = T.let([], T::Array[DependencyFile])

  fetched_files << build_sbt
  fetched_files << T.must(plugins_sbt) if plugins_sbt
  fetched_files << T.must(build_properties) if build_properties
  fetched_files += subproject_build_files
  fetched_files += project_scala_files

  fetched_files.reject do |file|
    Dependabot::FileFiltering.should_exclude_path?(file.name, "file from final collection", @exclude_paths)
  end
end