Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support updating dependencies on settings file #4374

Merged
merged 6 commits into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gradle/lib/dependabot/gradle/file_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def self.required_files_message
def fetch_files
fetched_files = []
fetched_files << buildfile if buildfile
fetched_files << settings_file if settings_file
anatawa12 marked this conversation as resolved.
Show resolved Hide resolved
fetched_files += subproject_buildfiles
fetched_files += dependency_script_plugins
check_required_files_present
Expand Down
2 changes: 1 addition & 1 deletion gradle/lib/dependabot/gradle/file_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FileParser < Dependabot::FileParsers::Base
require "dependabot/file_parsers/base/dependency_set"
require_relative "file_parser/property_value_finder"

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

PROPERTY_REGEX =
/
Expand Down
16 changes: 8 additions & 8 deletions gradle/spec/dependabot/gradle/file_fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ def stub_content_request(path, fixture)
end

it "fetches the main buildfile and subproject buildfile" do
expect(file_fetcher_instance.files.count).to eq(2)
expect(file_fetcher_instance.files.count).to eq(3)
expect(file_fetcher_instance.files.map(&:name)).
to match_array(%w(build.gradle app/build.gradle))
to match_array(%w(build.gradle settings.gradle app/build.gradle))
jurre marked this conversation as resolved.
Show resolved Hide resolved
end

context "when the subproject can't fe found" do
Expand All @@ -73,9 +73,9 @@ def stub_content_request(path, fixture)
end

it "fetches the main buildfile" do
expect(file_fetcher_instance.files.count).to eq(1)
expect(file_fetcher_instance.files.count).to eq(2)
expect(file_fetcher_instance.files.map(&:name)).
to match_array(%w(build.gradle))
to match_array(%w(build.gradle settings.gradle))
end
end
end
Expand All @@ -89,9 +89,9 @@ def stub_content_request(path, fixture)
end

it "fetches the main buildfile and subproject buildfile" do
expect(file_fetcher_instance.files.count).to eq(1)
expect(file_fetcher_instance.files.count).to eq(2)
expect(file_fetcher_instance.files.map(&:name)).
to match_array(%w(app/build.gradle))
to match_array(%w(settings.gradle app/build.gradle))
end
end

Expand All @@ -118,9 +118,9 @@ def stub_content_request(path, fixture)
end

it "fetches the main buildfile and subproject buildfile" do
expect(file_fetcher_instance.files.count).to eq(2)
expect(file_fetcher_instance.files.count).to eq(3)
expect(file_fetcher_instance.files.map(&:name)).
to match_array(%w(build.gradle.kts app/build.gradle.kts))
to match_array(%w(build.gradle.kts settings.gradle.kts app/build.gradle.kts))
end
end
end
Expand Down
30 changes: 30 additions & 0 deletions gradle/spec/dependabot/gradle/file_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,21 @@
end
end

describe "settings script" do
let(:files) { [buildfile, settings_file] }
let(:settings_file) do
Dependabot::DependencyFile.new(
name: "settings.gradle",
content: fixture("settings_files", settings_file_fixture_name)
)
end
let(:settings_file_fixture_name) { "buildscript_dependencies_settings.gradle" }

subject(:dependencies) { parser.parse }

its(:length) { is_expected.to eq(20) }
end

context "with kotlin" do
let(:buildfile) do
Dependabot::DependencyFile.new(
Expand Down Expand Up @@ -751,6 +766,21 @@
end
end
end

describe "kotlin settings script" do
let(:files) { [buildfile, settings_file] }
let(:settings_file) do
Dependabot::DependencyFile.new(
name: "settings.gradle.kts",
content: fixture("settings_files", settings_file_fixture_name)
)
end
let(:settings_file_fixture_name) { "buildscript_dependencies_settings.gradle.kts" }

subject(:dependencies) { parser.parse }

its(:length) { is_expected.to eq(20) }
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.ow2.asm:asm:9.2'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.ow2.asm:asm:9.2")
}
}