dependabot-gradle 0.384.0 → 0.386.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60a4e8bbe348c7bb7cbd6fbc275892a16a54bed033bd2668c483b1c8e905ad20
4
- data.tar.gz: 268f0b46c9fce142acc4f4b615803481e6e9a72844aafcaee0b18becccd471ef
3
+ metadata.gz: 3e13edb6e52c235438f37abde8da6e16acbf8af7c9ad353b1107d5e3640c452b
4
+ data.tar.gz: 3a3e95bec57181355b897de358e3de6bf713b96968cbe8c28cc2465a81aa6599
5
5
  SHA512:
6
- metadata.gz: '0093b562d15794bddca25d32a49a016c7728f2275c7c4e1b206c95ed570e2c4cb2f89b27e508f533371241d51d03bda0d58a47c9ea8939bf7fa47d857636d0cb'
7
- data.tar.gz: 06c419e20a01912105e76ec70577a27ab9fc091b37493b7d2481ae7e3383fc1d971004b6561b573f45db9bb0d54cfaafa35588e38b5e1aafd8f5c50cbc31f563
6
+ metadata.gz: ebe25caa251686e54aea6dddddfe590c400e7261eba31772dd43e8dece9a4d037dbfa530f67737521d2f3e7b4c1389e8219bda2aa52a6a6e46c79687d2d62e0b
7
+ data.tar.gz: e12a6f556feb7ba1883c1458fc5a1f482be3b60d0a268c1048b86d11470efe262caa70dd324eb7dc9a564b7bc71c0cc941c797ab527b1e1e5a91f4f8bf1c2bc6
@@ -81,7 +81,8 @@ module Dependabot
81
81
 
82
82
  sig { params(root_dir: String).returns(T::Array[DependencyFile]) }
83
83
  def all_buildfiles_in_build(root_dir)
84
- files = [buildfile(root_dir), settings_file(root_dir), version_catalog_file(root_dir), lockfile(root_dir)]
84
+ files = [buildfile(root_dir), settings_file(root_dir), version_catalog_file(root_dir), lockfile(root_dir),
85
+ properties_file(root_dir)]
85
86
  .compact
86
87
  files += wrapper_files(root_dir)
87
88
  files += subproject_buildfiles(root_dir)
@@ -251,6 +252,11 @@ module Dependabot
251
252
  fetch_file_if_present(File.join(dir, @lockfile_name))
252
253
  end
253
254
 
255
+ sig { params(dir: String).returns(T.nilable(DependencyFile)) }
256
+ def properties_file(dir)
257
+ fetch_file_if_present(File.join(dir, "gradle.properties"))
258
+ end
259
+
254
260
  sig { params(dir: String).returns(T.nilable(DependencyFile)) }
255
261
  def buildfile(dir)
256
262
  file = find_first(dir, SUPPORTED_BUILD_FILE_NAMES) || return
@@ -4,6 +4,7 @@
4
4
  require "sorbet-runtime"
5
5
 
6
6
  require "dependabot/gradle/file_parser"
7
+ require "dependabot/maven/shared/property_value_finding"
7
8
 
8
9
  module Dependabot
9
10
  module Gradle
@@ -11,6 +12,8 @@ module Dependabot
11
12
  class PropertyValueFinder
12
13
  extend T::Sig
13
14
 
15
+ include Dependabot::Maven::Shared::PropertyValueFinding
16
+
14
17
  # rubocop:disable Layout/LineLength
15
18
  SUPPORTED_BUILD_FILE_NAMES = %w(build.gradle build.gradle.kts).freeze
16
19
 
@@ -76,7 +79,8 @@ module Dependabot
76
79
  end
77
80
 
78
81
  sig do
79
- params(property_name: String, callsite_buildfile: Dependabot::DependencyFile)
82
+ override
83
+ .params(property_name: String, callsite_buildfile: Dependabot::DependencyFile)
80
84
  .returns(T.nilable(T::Hash[Symbol, String]))
81
85
  end
82
86
  def property_details(property_name:, callsite_buildfile:)
@@ -2,6 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "fileutils"
5
+ require "pathname"
5
6
  require "shellwords"
6
7
  require "sorbet-runtime"
7
8
 
@@ -41,14 +42,13 @@ module Dependabot
41
42
  write_init_script(init_script_path)
42
43
 
43
44
  command_parts = [
44
- "gradle",
45
+ gradle_executable_for(cwd: cwd, workspace_root: temp_dir.to_s),
45
46
  "--init-script", init_script_path,
46
47
  INIT_SCRIPT_TASK_NAME,
47
48
  "--write-locks",
48
49
  "--no-daemon"
49
50
  ]
50
51
  command = Shellwords.join(command_parts)
51
-
52
52
  SharedHelpers.run_shell_command(command, cwd: cwd)
53
53
 
54
54
  update_lockfiles_content(temp_dir, lockfiles, updated_files)
@@ -176,7 +176,7 @@ module Dependabot
176
176
  relative_dir = file.directory == "/" ? "" : file.directory
177
177
  in_path_name = File.join(temp_dir, relative_dir, file.name)
178
178
  FileUtils.mkdir_p(File.dirname(in_path_name))
179
- File.write(in_path_name, file.content)
179
+ File.binwrite(in_path_name, file.decoded_content)
180
180
  end
181
181
  end
182
182
 
@@ -191,12 +191,16 @@ module Dependabot
191
191
  http_proxy_port = http_split&.fetch(2) || "1080"
192
192
  https_proxy_port = https_split&.fetch(2) || "1080"
193
193
 
194
- properties_content = "
194
+ existing_content = File.exist?(file_name) ? File.read(file_name) : ""
195
+
196
+ proxy_properties = "
195
197
  systemProp.http.proxyHost=#{http_proxy_host}
196
198
  systemProp.http.proxyPort=#{http_proxy_port}
197
199
  systemProp.https.proxyHost=#{https_proxy_host}
198
200
  systemProp.https.proxyPort=#{https_proxy_port}"
199
- File.write(file_name, properties_content)
201
+
202
+ separator = !existing_content.empty? && !existing_content.end_with?("\n") ? "\n" : ""
203
+ File.write(file_name, existing_content + separator + proxy_properties)
200
204
  end
201
205
 
202
206
  sig { params(file_name: String).void }
@@ -217,6 +221,34 @@ systemProp.https.proxyPort=#{https_proxy_port}"
217
221
  File.write(file_name, script_content)
218
222
  end
219
223
 
224
+ sig { params(cwd: String, workspace_root: String).returns(String) }
225
+ def gradle_executable_for(cwd:, workspace_root:)
226
+ cwd_path = Pathname.new(cwd).expand_path
227
+ workspace_root_path = Pathname.new(workspace_root).expand_path
228
+
229
+ return "gradle" unless cwd_path == workspace_root_path || cwd_path.to_s.start_with?("#{workspace_root_path}/")
230
+
231
+ search_path = cwd_path
232
+
233
+ loop do
234
+ wrapper_script = search_path.join("gradlew")
235
+ if File.file?(wrapper_script)
236
+ wrapper_script_path = wrapper_script.to_s
237
+ FileUtils.chmod("+x", wrapper_script_path)
238
+
239
+ relative_path = wrapper_script.relative_path_from(cwd_path).to_s
240
+ return relative_path.start_with?(".") ? relative_path : "./#{relative_path}"
241
+ end
242
+
243
+ parent_path = search_path.parent
244
+ break if parent_path == search_path || search_path == workspace_root_path
245
+
246
+ search_path = parent_path
247
+ end
248
+
249
+ "gradle"
250
+ end
251
+
220
252
  sig { params(build_file: Dependabot::DependencyFile).returns(T.nilable(Dependabot::DependencyFile)) }
221
253
  def find_settings_file(build_file)
222
254
  settings_files = dependency_files.select do |f|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-gradle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.384.0
4
+ version: 0.386.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
@@ -15,28 +15,28 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 0.384.0
18
+ version: 0.386.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 0.384.0
25
+ version: 0.386.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: dependabot-maven
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
30
  - - '='
31
31
  - !ruby/object:Gem::Version
32
- version: 0.384.0
32
+ version: 0.386.0
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - '='
38
38
  - !ruby/object:Gem::Version
39
- version: 0.384.0
39
+ version: 0.386.0
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: debug
42
42
  requirement: !ruby/object:Gem::Requirement
@@ -291,7 +291,7 @@ licenses:
291
291
  - MIT
292
292
  metadata:
293
293
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
294
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.384.0
294
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.386.0
295
295
  rdoc_options: []
296
296
  require_paths:
297
297
  - lib