Skip to content
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
2 changes: 0 additions & 2 deletions gradle/lib/dependabot/gradle/file_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ def subproject_buildfiles(root_dir)

sig { params(dir: String).returns(T::Array[DependencyFile]) }
def wrapper_files(dir)
return [] unless Experiments.enabled?(:gradle_wrapper_updater)

SUPPORTED_WRAPPER_FILES_PATH.filter_map do |filename|
file = fetch_file_if_present(File.join(dir, filename))
next unless file
Expand Down
6 changes: 2 additions & 4 deletions gradle/lib/dependabot/gradle/file_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,8 @@ def parse
script_plugin_files.each do |plugin_file|
dependency_set += buildfile_dependencies(plugin_file)
end
if Experiments.enabled?(:gradle_wrapper_updater)
wrapper_properties_file.each do |properties_file|
dependency_set += wrapper_properties_dependencies(properties_file)
end
wrapper_properties_file.each do |properties_file|
dependency_set += wrapper_properties_dependencies(properties_file)
end
version_catalog_file.each do |toml_file|
dependency_set += version_catalog_dependencies(toml_file)
Expand Down
10 changes: 4 additions & 6 deletions gradle/lib/dependabot/gradle/file_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,10 @@ def update_buildfiles_for_dependency(buildfiles:, dependency:)
end

# runs native updaters (e.g. wrapper, lockfile) on relevant build files updated
if Dependabot::Experiments.enabled?(:gradle_wrapper_updater)
buildfiles_processed.each_value do |buildfile|
wrapper_updater = WrapperUpdater.new(dependency_files: files, dependency: dependency)
updated_files = wrapper_updater.update_files(buildfile)
replace_updated_files(files, updated_files)
end
buildfiles_processed.each_value do |buildfile|
wrapper_updater = WrapperUpdater.new(dependency_files: files, dependency: dependency)
updated_files = wrapper_updater.update_files(buildfile)
replace_updated_files(files, updated_files)
end
if Dependabot::Experiments.enabled?(:gradle_lockfile_updater)
buildfiles_processed.each_value do |buildfile|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ def repositories

sig { returns(T.nilable(T::Array[T::Hash[String, T.untyped]])) }
def distribution_version_details
return nil unless Experiments.enabled?(:gradle_wrapper_updater)

DistributionsFetcher.available_versions.map do |info|
release_date = begin
Time.parse(info[:build_time])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ def update_dynamic_requirement(req_string)

sig { returns(T::Array[T::Hash[Symbol, T.untyped]]) }
def updated_distribution_requirements
return requirements unless Experiments.enabled?(:gradle_wrapper_updater)

distribution_url = T.let(nil, T.nilable(String))

requirements.map do |req|
Expand Down
24 changes: 19 additions & 5 deletions gradle/spec/dependabot/gradle/file_fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,19 @@ def stub_no_content_request(path)
.to_return(status: 404)
end

def stub_no_wrapper_files(prefix = "")
stub_no_content_request("#{prefix}gradle/wrapper?ref=sha")
stub_no_content_request("#{prefix}gradlew?ref=sha")
stub_no_content_request("#{prefix}gradlew.bat?ref=sha")
end

context "with a basic buildfile" do
before do
stub_no_content_request("gradle?ref=sha")
stub_content_request("?ref=sha", "contents_java.json")
stub_content_request("build.gradle?ref=sha", "contents_java_basic_buildfile.json")
stub_no_content_request("gradle.lockfile?ref=sha")
stub_no_wrapper_files
end

it "fetches the buildfile" do
Expand All @@ -64,7 +71,6 @@ def stub_no_content_request(path)

context "with gradle wrapper properties" do
before do
Dependabot::Experiments.register(:gradle_wrapper_updater, true)
stub_content_request("?ref=sha", "contents_wrapper.json")
stub_content_request("gradle/wrapper?ref=sha", "content_gradle_wrapper.json")
stub_content_request("gradlew?ref=sha", "gradlew.json")
Expand All @@ -73,10 +79,6 @@ def stub_no_content_request(path)
stub_content_request("gradle/wrapper/gradle-wrapper.properties?ref=sha", "gradle-wrapper.properties.json")
end

after do
Dependabot::Experiments.reset!
end

it "fetches the wrapper files" do
expect(file_fetcher_instance.files.map(&:name)).to eq(
%w(
Expand Down Expand Up @@ -152,6 +154,7 @@ def stub_no_content_request(path)
stub_content_request("buildSrc?ref=sha", "contents_java.json")
stub_content_request("buildSrc/build.gradle?ref=sha", "contents_java_basic_buildfile.json")
stub_no_content_request("buildSrc/gradle.lockfile?ref=sha")
stub_no_wrapper_files("buildSrc/")
end

context "when the buildSrc is implicitly included" do
Expand Down Expand Up @@ -184,6 +187,7 @@ def stub_no_content_request(path)
stub_content_request("included?ref=sha", "contents_java.json")
stub_content_request("included/build.gradle?ref=sha", "contents_java_basic_buildfile.json")
stub_no_content_request("included/gradle.lockfile?ref=sha")
stub_no_wrapper_files("included/")
end

it "doesn't fetch buildSrc buildfiles twice" do
Expand Down Expand Up @@ -213,6 +217,7 @@ def stub_no_content_request(path)
stub_no_content_request("included/gradle.lockfile?ref=sha")
stub_content_request("included/app/build.gradle?ref=sha", "contents_java_basic_buildfile.json")
stub_no_content_request("included/app/gradle.lockfile?ref=sha")
stub_no_wrapper_files("included/")
end

it "fetches all buildfiles" do
Expand Down Expand Up @@ -248,6 +253,8 @@ def stub_no_content_request(path)
stub_content_request("included2/settings.gradle?ref=sha", "contents_java_simple_settings.json")
stub_content_request("included2/app/build.gradle?ref=sha", "contents_java_basic_buildfile.json")
stub_no_content_request("included2/app/gradle.lockfile?ref=sha")
stub_no_wrapper_files("included/")
stub_no_wrapper_files("included2/")
end

it "fetches all buildfiles" do
Expand Down Expand Up @@ -296,6 +303,10 @@ def stub_no_content_request(path)
"included/included/included/buildSrc/build.gradle?ref=sha",
"contents_java_basic_buildfile.json"
)
stub_no_wrapper_files("included/")
stub_no_wrapper_files("included/included/")
stub_no_wrapper_files("included/included/included/")
stub_no_wrapper_files("included/included/included/buildSrc/")
end

it "fetches all buildfiles transitively" do
Expand Down Expand Up @@ -328,6 +339,7 @@ def stub_no_content_request(path)
stub_content_request("included/build.gradle?ref=sha", "contents_java_buildfile_with_script_plugins.json")
stub_no_content_request("included/gradle.lockfile?ref=sha")
stub_content_request("included/gradle/dependencies.gradle?ref=sha", "contents_java_simple_settings.json")
stub_no_wrapper_files("included/")
end

it "fetches script plugin of main and included build" do
Expand Down Expand Up @@ -412,6 +424,7 @@ def stub_no_content_request(path)
stub_content_request("?ref=sha", "contents_java.json")
stub_content_request("build.gradle?ref=sha", "contents_java_buildfile_with_script_plugins.json")
stub_content_request("gradle/dependencies.gradle?ref=sha", "contents_java_simple_settings.json")
stub_no_wrapper_files
end

it "fetches the buildfile and the dependencies script" do
Expand Down Expand Up @@ -461,6 +474,7 @@ def stub_no_content_request(path)
body: "[]",
headers: { "content-type" => "application/json" }
)
stub_no_wrapper_files
end

it "raises dependency file not found" do
Expand Down
8 changes: 0 additions & 8 deletions gradle/spec/dependabot/gradle/file_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -832,14 +832,6 @@
]
end

before do
Dependabot::Experiments.register(:gradle_wrapper_updater, true)
end

after do
Dependabot::Experiments.reset!
end

its(:length) { is_expected.to eq(1) }

describe "check dependency" do
Expand Down
1 change: 0 additions & 1 deletion gradle/spec/dependabot/gradle/file_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
raise "Unexpected shell command: #{command}"
end

Dependabot::Experiments.register(:gradle_wrapper_updater, true)
Dependabot::Experiments.register(:gradle_lockfile_updater, true)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,19 +321,13 @@

context "when the details come from gradle distributions" do
before do
Dependabot::Experiments.register(:gradle_wrapper_updater, true)

stub_request(:get, "https://services.gradle.org/versions/all")
.to_return(
status: 200,
body: fixture("gradle_distributions_metadata", "versions_all.json")
)
end

after do
Dependabot::Experiments.reset!
end

describe "the last version" do
subject { versions.last }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,10 @@
end

before do
Dependabot::Experiments.register(:gradle_wrapper_updater, true)

stub_request(:get, "https://services.gradle.org/distributions/gradle-9.0.0-all.zip.sha256")
.to_return(status: 200, body: "f759b8dd5204e2e3fa4ca3e73f452f087153cf81bac9561eeb854229cc2c5365")
end

after do
Dependabot::Experiments.reset!
end

it "updates url and checksum" do
expect(updater.updated_requirements).not_to eq(requirements)
expect(updater.updated_requirements).to eq(
Expand Down
Loading