Class: Dependabot::Gradle::FileUpdater::WrapperUpdater
- Inherits:
-
Object
- Object
- Dependabot::Gradle::FileUpdater::WrapperUpdater
- Extended by:
- T::Sig
- Includes:
- Distributions
- Defined in:
- lib/dependabot/gradle/file_updater/wrapper_updater.rb
Constant Summary
Constants included from Distributions
Distributions::DISTRIBUTION_DEPENDENCY_TYPE, Distributions::DISTRIBUTION_REPOSITORY_URL
Instance Method Summary collapse
-
#initialize(dependency_files:, dependency:) ⇒ WrapperUpdater
constructor
A new instance of WrapperUpdater.
- #update_files(build_file) ⇒ Object
Methods included from Distributions
Constructor Details
#initialize(dependency_files:, dependency:) ⇒ WrapperUpdater
Returns a new instance of WrapperUpdater.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/dependabot/gradle/file_updater/wrapper_updater.rb', line 17 def initialize(dependency_files:, dependency:) @dependency_files = dependency_files @dependency = dependency @target_files = T.let( %w( /gradlew /gradlew.bat /gradle/wrapper/gradle-wrapper.properties /gradle/wrapper/gradle-wrapper.jar ), T::Array[String] ) @build_files = T.let( %w( build.gradle build.gradle.kts settings.gradle settings.gradle.kts ), T::Array[String] ) end |
Instance Method Details
#update_files(build_file) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/dependabot/gradle/file_updater/wrapper_updater.rb', line 41 def update_files(build_file) # We only run this updater if it's a distribution dependency return [] unless Distributions.distribution_requirements?(dependency.requirements) local_files = dependency_files.select do |file| file.directory == build_file.directory && target_file?(file) end # If we don't have any files in the build files don't generate one return [] unless local_files.any? updated_files = dependency_files.dup SharedHelpers.in_a_temporary_directory do |temp_dir| populate_temp_directory(temp_dir) cwd = File.join(temp_dir, base_path(build_file)) # Create gradle.properties file with proxy settings # Would prefer to use command line arguments, but they don't work. properties_filename = File.join(temp_dir, build_file.directory, "gradle.properties") write_properties_file(properties_filename) command_parts = %w(gradle --no-daemon --stacktrace) + command_args command = Shellwords.join(command_parts) Dir.chdir(cwd) do SharedHelpers.run_shell_command(command, cwd: cwd) update_files_content(temp_dir, local_files, updated_files) rescue SharedHelpers::HelperSubprocessFailed => e puts "Failed to update files: #{e.}" return updated_files end end updated_files end |