-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Added Gradle Wrapper support #12891
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
Merged
Merged
Added Gradle Wrapper support #12891
Changes from 14 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
d1e1ac6
Added Gradle Wrapper support
gmazzo 037bc89
Targeting smoke tests from fork
gmazzo 8ec500d
Updated `DISTRIBUTION_URL_REGEX` with multiple literal
gmazzo d8d437a
Multi-directory support
gmazzo 7c07184
Fixed broken smoke tests
gmazzo a8048f8
Put changes under `gradle_wrapper_updater` feature flag
gmazzo a6ac9ee
Fixed broken requirements logic when multiple wrappers
gmazzo aafaa8a
Renamed `lockfile_updater.rb` to `gradle_updater_base.rb`
gmazzo caaf009
Updating Gradle binaries support
gmazzo 09a8761
Iterated distributions regex to catch any url
gmazzo 06d21c8
Applied new RuboCop rules
gmazzo 120892e
Merge branch 'main' into gradle-wrapper-support
kbukum1 77c8568
Merge branch 'main' into gradle-wrapper-support
kbukum1 8d34b8a
Allow repo variables to target forks on smoke tests
gmazzo d6fbfde
Reverted the changes on `smoke.yml` workflow
gmazzo 9876c01
Merge branch 'main' into gradle-wrapper-support
gmazzo d676815
Added `released_at` field to Gradle Distribution versions
gmazzo 39ad031
Reverted changes on `lockfile_updater.rb`
gmazzo 71f0ceb
Unified `wrapper_updater.rb`
gmazzo d4259fb
Integrated available distributions into `package_details_fetcher.rb`
gmazzo 52fdd02
Moved expected resolved versions to a fixture file
gmazzo 5b97c70
Merge branch 'main' into gradle-wrapper-support
kbukum1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # typed: strict | ||
| # frozen_string_literal: true | ||
|
|
||
| module Dependabot | ||
| module Gradle | ||
| module Distributions | ||
| extend T::Sig | ||
|
|
||
| DISTRIBUTION_DEPENDENCY_TYPE = "gradle-distribution" | ||
|
|
||
| sig { params(requirements: T::Array[T::Hash[Symbol, T.untyped]]).returns(T::Boolean) } | ||
| def self.distribution_requirements?(requirements) | ||
| requirements.any? do |req| | ||
| req.dig(:source, :type) == DISTRIBUTION_DEPENDENCY_TYPE | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
gradle/lib/dependabot/gradle/file_parser/distributions_finder.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| # typed: strong | ||
| # frozen_string_literal: true | ||
|
|
||
| require "dependabot/gradle/file_parser" | ||
| require "dependabot/gradle/distributions" | ||
| require "sorbet-runtime" | ||
|
|
||
| module Dependabot | ||
| module Gradle | ||
| class FileParser | ||
| class DistributionsFinder | ||
| extend T::Sig | ||
|
|
||
| DISTRIBUTION_URL_REGEX = | ||
| /.*?(?<version>(\d+(?:\.\d+){1,3}(?:-(?!bin|all)\w++)*(?:\+\w++)*))(?:-bin|-all)?.*?/ | ||
|
|
||
| sig { params(properties_file: DependencyFile).returns(T.nilable(Dependency)) } | ||
| def self.resolve_dependency(properties_file) # rubocop:disable Metrics/MethodLength | ||
| content = properties_file.content | ||
| return nil unless content | ||
|
|
||
| distribution_url, checksum = load_properties(content) | ||
| match = distribution_url&.match(DISTRIBUTION_URL_REGEX)&.named_captures | ||
| return nil unless match | ||
|
|
||
| version = match.fetch("version") | ||
|
|
||
| requirements = T.let( | ||
| [{ | ||
| requirement: version, | ||
| file: properties_file.name, | ||
| source: { | ||
| type: Distributions::DISTRIBUTION_DEPENDENCY_TYPE, | ||
| url: distribution_url, | ||
| property: "distributionUrl" | ||
| }, | ||
| groups: [] | ||
| }], | ||
| T::Array[T::Hash[Symbol, T.untyped]] | ||
| ) | ||
|
|
||
| if checksum | ||
| requirements << { | ||
| requirement: checksum, | ||
| file: properties_file.name, | ||
| source: { | ||
| type: Distributions::DISTRIBUTION_DEPENDENCY_TYPE, | ||
| url: "#{distribution_url}.sha256", | ||
| property: "distributionSha256Sum" | ||
| }, | ||
| groups: [] | ||
| } | ||
| end | ||
|
|
||
| Dependency.new( | ||
| name: "gradle-wrapper", | ||
| version: version, | ||
| requirements: requirements, | ||
| package_manager: "gradle" | ||
| ) | ||
| end | ||
|
|
||
| sig { params(properties_content: String).returns(T::Array[T.nilable(String)]) } | ||
| def self.load_properties(properties_content) | ||
| distribution_url = T.let(nil, T.nilable(String)) | ||
| checksum = T.let(nil, T.nilable(String)) | ||
|
|
||
| properties_content.lines.each do |line| | ||
| (key, value) = line.split("=", 2).map(&:strip) | ||
| next unless key && value | ||
|
|
||
| case key | ||
| when "distributionUrl" | ||
| distribution_url = value.gsub("\\:", ":") | ||
| when "distributionSha256Sum" | ||
| checksum = value | ||
| else | ||
| next | ||
| end | ||
| break if distribution_url && checksum | ||
| end | ||
|
|
||
| [distribution_url, checksum] | ||
| end | ||
|
|
||
| private_class_method :load_properties | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.