Module: Dependabot::Gradle::FileUpdater::Wrapper::ExecutingVersionDetector
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/gradle/file_updater/wrapper/executing_version_detector.rb
Overview
Detects the Gradle version that will actually execute the wrapper task.
The wrapper task runs under whatever Gradle the project currently resolves to (the OLD distribution), not the target version. Knowing that version lets CommandBuilder decide which version-gated CLI flags are safe to pass.
Constant Summary collapse
- DISTRIBUTION_URL_VERSION_REGEX =
Matches the version embedded in a Gradle distribution URL, e.g. services.gradle.org/distributions/gradle-9.5.0-bin.zip Anchored to the ‘gradle-<version>-(bin|all).zip` filename so host/port numbers in custom mirror URLs are never mistaken for the version. The captured token is validated with Version.correct? so non-version matches (and RC/milestone names) are handled safely.
T.let( /gradle-(?<version>.+?)-(?:bin|all)\.zip/, Regexp )
- GRADLE_VERSION_OUTPUT_REGEX =
Matches the version printed by ‘gradle –version`, e.g. “Gradle 9.2.1”.
T.let(/^Gradle\s+(?<version>\d+(?:\.\d+){1,2}(?:-[\w.]+)?)/, Regexp)
Class Method Summary collapse
- .build_version(captured) ⇒ Object
- .from_distribution_url(distribution_url) ⇒ Object
- .from_version_output(output) ⇒ Object
Class Method Details
.build_version(captured) ⇒ Object
51 52 53 54 55 |
# File 'lib/dependabot/gradle/file_updater/wrapper/executing_version_detector.rb', line 51 def self.build_version(captured) return nil if captured.nil? || !Dependabot::Gradle::Version.correct?(captured) T.cast(Dependabot::Gradle::Version.new(captured), Dependabot::Gradle::Version) end |
.from_distribution_url(distribution_url) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/dependabot/gradle/file_updater/wrapper/executing_version_detector.rb', line 35 def self.from_distribution_url(distribution_url) return nil if distribution_url.nil? captured = distribution_url.match(DISTRIBUTION_URL_VERSION_REGEX)&.named_captures&.fetch("version", nil) build_version(captured) end |
.from_version_output(output) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/dependabot/gradle/file_updater/wrapper/executing_version_detector.rb', line 43 def self.from_version_output(output) return nil if output.nil? captured = output.match(GRADLE_VERSION_OUTPUT_REGEX)&.named_captures&.fetch("version", nil) build_version(captured) end |