Skip to content
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

Add flag to update only explicitly listed dependencies #27

Merged
merged 1 commit into from
Jul 22, 2019

Conversation

isker
Copy link
Contributor

@isker isker commented Jun 30, 2019

In many larger projects, users often want to update only specific dependencies
as updating everything at once may be too large of a change. Provide such
functionality through a Gradle @option on the two task classes.

While this @option API exists only from 4.6 up, this is not a breaking change
for lower versions of Gradle as missing annotation types are simply ignored when
classes are being initialized (JLS §13.5.7).

@isker
Copy link
Contributor Author

isker commented Jul 11, 2019

@patrikerdes hi, can you take a look? Thanks!

@usr42
Copy link
Contributor

usr42 commented Jul 11, 2019

I really like this feature. Also having the option to ignore some dependencies would be really helpful.
Having the option to specify these lists in the build.gradle file would also be really nice!

@Brim-Bam
Copy link

@patrikerdes
Copy link
Owner

Hi!
Thanks for the pull request! It seems like a very reasonable feature to me. I have been on vacation and haven't had the time to have a look, but hopefully I'll be able to look at it sometime in the coming week or so.

@isker
Copy link
Contributor Author

isker commented Jul 13, 2019

Great, thanks.

Copy link
Owner

@patrikerdes patrikerdes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed your changed and tested this out and it has been working just fine for me so far, except for a minor comment related to the message when an update fails.

int failedCount = leftToUpdate.size()
int skippedCount = updateWhitelist.empty ? 0 :
leftToUpdate.count { !updateWhitelist.contains(it.groupAndName()) } as int
int failedCount = leftToUpdate.size() - skippedCount
if (failedCount > 0) {
println("useLatestVersions failed to update $failedCount ${deps(failedCount)} " +
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If one --update-dependency flag is used on the command line and that update fails, failedCount will be 1, but leftToUpdate could have more than one update that has not been done which is printed, e.g.

gradle-use-latest-versions-plugin\examples\localReadmeExample> .\gradlew useLatestVersionsCheck --update-dependency commons-lang:commons-lang
useLatestVersions failed to update 1 dependency to the latest version:
 - com.github.ben-manes.versions:com.github.ben-manes.versions.gradle.plugin [0.16.0 -> 0.21.0]
 - commons-codec:commons-codec [1.9 -> 1.12]
 - commons-lang:commons-lang [2.4 -> 2.6]
 - commons-logging:commons-logging [1.1.2 -> 1.2]
 - junit:junit [4.0 -> 4.13-beta-3]
useLatestVersions skipped updating 4 dependencies not in --dependency-update:
 - com.github.ben-manes.versions:com.github.ben-manes.versions.gradle.plugin [0.16.0 -> 0.21.0]
 - commons-codec:commons-codec [1.9 -> 1.12]
 - commons-logging:commons-logging [1.1.2 -> 1.2]
 - junit:junit [4.0 -> 4.13-beta-3]

This looks a bit strange to me. To me it would make more sense to only print the single update which was specified with --update-dependency and that failed in the first list:

gradle-use-latest-versions-plugin\examples\localReadmeExample> .\gradlew useLatestVersionsCheck --update-dependency commons-lang:commons-lang
useLatestVersions failed to update 1 dependency to the latest version:
 - commons-lang:commons-lang [2.4 -> 2.6]
useLatestVersions skipped updating 4 dependencies not in --dependency-update:
 - com.github.ben-manes.versions:com.github.ben-manes.versions.gradle.plugin [0.16.0 -> 0.21.0]
 - commons-codec:commons-codec [1.9 -> 1.12]
 - commons-logging:commons-logging [1.1.2 -> 1.2]
 - junit:junit [4.0 -> 4.13-beta-3]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Will fix.

In many larger projects, users often want to update only specific dependencies
as updating everything at once may be too large of a change.  Provide such
functionality through a Gradle @option on the two task classes.

While this @option API exists only from 4.6 up, this is not a breaking change
for lower versions of Gradle as missing annotation types are simply ignored when
classes are being initialized (JLS §13.5.7).
@isker isker force-pushed the add-update-whitelist branch from 7c9f15a to 35361c1 Compare July 14, 2019 16:29
@isker
Copy link
Contributor Author

isker commented Jul 19, 2019

How's that @patrikerdes?

@patrikerdes patrikerdes merged commit e4626e2 into patrikerdes:master Jul 22, 2019
@patrikerdes
Copy link
Owner

LGTM

@patrikerdes
Copy link
Owner

Released in 0.2.12

@usr42
Copy link
Contributor

usr42 commented Oct 24, 2019

I really like this feature. Also having the option to ignore some dependencies would be really helpful.
Having the option to specify these lists in the build.gradle file would also be really nice!

I've opened a PR for this: #35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants