ben-manes / gradle-versions-plugin

Gradle plugin to discover dependency updates
Apache License 2.0
3.88k stars 201 forks source link

Not sure how -Drevision=release works? #149

Closed palto-blubek closed 7 years ago

palto-blubek commented 7 years ago

Hi! I am trying to only warn only if "release" (stable) versions of my dependencies exist, and so I use the -Drevision=release flag, but I don't see the difference with when I don't use it:

------------------------------------------------------------
: Project Dependency Updates (report to plain text file)
------------------------------------------------------------

The following dependencies are using the latest milestone version:
 - com.squareup.retrofit2:adapter-rxjava2:2.2.0
 - com.android.databinding:adapters:1.3.1
 - com.android.support:appcompat-v7:25.3.0
 - com.android.support.constraint:constraint-layout:1.0.2
 - com.squareup.retrofit2:converter-gson:2.2.0
 - com.android.support:design:25.3.0
 - org.greenrobot:eventbus:3.0.0
 - com.google.firebase:firebase-core:10.2.0
 - com.google.firebase:firebase-messaging:10.2.0
 - com.google.gms:google-services:3.0.0
 - me.tatarka:gradle-retrolambda:3.6.0
 - com.github.ben-manes:gradle-versions-plugin:0.14.0
 - junit:junit:4.12
 - com.android.databinding:library:1.3.1
 - com.google.android.gms:play-services-location:10.2.0
 - com.pubnub:pubnub-gson:4.6.0
 - com.squareup.retrofit2:retrofit:2.2.0
 - io.reactivex.rxjava2:rxandroid:2.0.1
 - io.reactivex.rxjava2:rxjava:2.0.7
 - com.jakewharton.timber:timber:4.5.1

The following dependencies have later milestone versions:
 - com.android.databinding:baseLibrary [2.3.0 -> 2.5.0-alpha-preview-01]
 - com.android.databinding:compiler [2.3.0 -> 2.5.0-alpha-preview-01]
 - com.google.dagger:dagger [2.9 -> 2.10-rc4]
 - com.google.dagger:dagger-compiler [2.9 -> 2.10-rc4]
 - com.android.support.test.espresso:espresso-core [2.2.2 -> 2.3-alpha]
 - com.google.firebase:firebase-core [9.0.0 -> 10.2.0]
 - com.android.tools.build:gradle [2.3.0 -> 2.5.0-alpha-preview-01]
 - javax.annotation:jsr250-api [1.0 -> 1.0-20050927.133100]

There's probably a way to not warn about these alpha / alpha-preview / rc4 versions, but I didn't really understand how.

Thanks a lot!

ben-manes commented 7 years ago

Gradle used to resolve using Apache Ivy which has this concept. It was the only toggle exposed to filter snapshots in the resolution process. Later Gradle wrote their own resolver and added resolutionStrategy to allow users to reject candidates. That's supported so that you can write one to exclude betas. Maven doesn't have these concepts which is why a milestone is also considered a release.

ben-manes commented 7 years ago

In the README.md there's an example using a resolutionStrategy to do what you want. You can add more qualifiers, e.g. alpha and preview.

dependencyUpdates.resolutionStrategy = {
  componentSelection { rules ->
    rules.all { ComponentSelection selection ->
      boolean rejected = ['alpha', 'beta', 'rc', 'cr', 'm'].any { qualifier ->
        selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-]*/
      }
      if (rejected) {
        selection.reject('Release candidate')
      }
    }
  }
}
BoD commented 7 years ago

I should have mentioned that I tried the snippet shown in the README.md but it didn't work - but I now understand, it's just that the regexp was not matching my cases. I simplified/tweaked it a bit like this, and it works now :)

                selection.candidate.version ==~ /.*-${qualifier}.*/

Thanks a lot!