I have this on my build.gradle:
testCompile(group: 'junit', name: 'junit', version: '4.+')
It resolves to:
junit:junit:4.+ -> 4.12-beta-1
I don't want to use beta releases but at the same time I want to use the 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 reponse? has an answer for maven but I'm not sure how to translate this in Gradle.
You can specify the Gradle version in either the File > Project Structure > Project menu in Android Studio, or update your Gradle version using the command line. The preferred way is to use the Gradle Wrapper command line tool, which updates the gradlew scripts.
Transitive dependencyA variant of a component can have dependencies on other modules to work properly, so-called transitive dependencies. Releases of a module hosted on a repository can provide metadata to declare those transitive dependencies. By default, Gradle resolves transitive dependencies automatically.
In most cases, a project relies on reusable functionality in the form of libraries or is broken up into individual components to compose a modularized system. Dependency management is a technique for declaring, resolving and using dependencies required by the project in an automated fashion.
You could 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 status range syntax for your dependency:
testCompile(group: 'junit', name: 'junit', version: 'latest.release')
Now Gradle won't consider your beta a "release", and hence it won't match 4.12-beta-1. This won't let you only pick 4.x releases though, i.e. a 5.2 release would also apply.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With