How to use dynamic versions of Gradle and avoid beta versions?

I have this on my build.gradle:

testCompile(group: 'junit', name: 'junit', version: '4.+')

It permits:

junit:junit:4.+ -> 4.12-beta-1

I do not want to use beta versions, but at the same time I want to use dynamic version. in this case I want to depend on 4.11.

Is it possible? How?

Note: Maven "versions" plugin - how to exclude alpha / beta versions from a response? has an answer for maven, but I'm not sure how to do this in Gradle.

+4
source share
2 answers

You can use ComponentMeta to set the status:

dependencies {
   components {
     eachComponent { ComponentMetadataDetails details ->
         def version = details.id.version
         if (version.contains("beta") || version.contains("alpha")) {
             details.status = "milestone" // default in Gradle
         }
     }
   }
 }

Then use the state range syntax for your dependency:

testCompile(group: 'junit', name: 'junit', version: 'latest.release')

Gradle - "", , , 4.12--1. 4.x, .. 5.2 .

+3

Gradle .

+1

All Articles