# How to get latest release version in an Range?

**URL:** <https://discuss.gradle.org/t/how-to-get-latest-release-version-in-an-range/5814>\
**Category:** Old Forum Archive\
**Created:** [July 25, 2014, 7:29am UTC](https://discuss.gradle.org/t/how-to-get-latest-release-version-in-an-range/5814 "2014-07-25T07:29:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kavin\_kankeshwar](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/kavin_kankeshwar/32/624_2.png) [@kavin\_kankeshwar](https://discuss.gradle.org/u/kavin_kankeshwar)\
**Post date:** [July 25, 2014, 7:29am UTC](https://discuss.gradle.org/t/how-to-get-latest-release-version-in-an-range/5814/1 "2014-07-25T07:29:00Z")

</div>

Looks like there is a GRADLE-3097 which always get snapshots, Is there way by providing ranges , we can select if its a snapshot or release ?

latest.integration and latest.release does not help, because there might be changes were 2 branches diverge and they have to resolve dependencies .

---

<div class="post-metadata">

**Author:** ![daz](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/daz/32/2475_2.png) [@daz](https://discuss.gradle.org/u/daz)\
**Post date:** [July 25, 2014, 5:14pm UTC](https://discuss.gradle.org/t/how-to-get-latest-release-version-in-an-range/5814/2 "2014-07-25T17:14:00Z")

</div>

There’s not an easy way to declare a dependency requirement that combines a version range with a SNAPSHOT dependency or a check for ivy status (release vs integration).  
  
It’s possible you could build something using [component metadata rules](http://www.gradle.org/docs/current/dsl/org.gradle.api.artifacts.dsl.ComponentMetadataHandler.html "Link: http://www.gradle.org/docs/current/dsl/org.gradle.api.artifacts.dsl.ComponentMetadataHandler.html"), where you use ‘latest.release’ as the dependency requirement, and maintain the required version range separately. You could then use a rule to force the status to be ‘integration’ for any version that doesn’t match the range.&nbsp;

---

<div class="post-metadata">

**Author:** ![kavin\_kankeshwar](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/kavin_kankeshwar/32/624_2.png) [@kavin\_kankeshwar](https://discuss.gradle.org/u/kavin_kankeshwar)\
**Post date:** [July 25, 2014, 6:04pm UTC](https://discuss.gradle.org/t/how-to-get-latest-release-version-in-an-range/5814/3 "2014-07-25T18:04:00Z")

</div>

Thanks! I have been using

```gradle
latest.integration

```

and

```gradle
latest.release

```

but i have not setting any status,

Our repositories are Maven repositories, So my question is will latest.integration and latest.release work to get latest snapshot/release builds?

Also component metadata rules seems very interesting, Is there an example i can look which sets the status when uploading snapshot or releases and then it can be used in metadata rules so right build is selected.

---

<div class="post-metadata">

**Author:** ![daz](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/daz/32/2475_2.png) [@daz](https://discuss.gradle.org/u/daz)\
**Post date:** [July 26, 2014, 2:28am UTC](https://discuss.gradle.org/t/how-to-get-latest-release-version-in-an-range/5814/4 "2014-07-26T02:28:00Z")

</div>

Gradle considers every external module to have a ‘status’. For Ivy modules, this value is read from the ivy.xml. For Maven, SNAPSHOT modules have a status of ‘integration’, while other Maven modules have a status of 'release.  
  
Component metadata rules apply at resolution-time, and can override the status that is determined for the module. You can read more about them here:&nbsp;[http://www.gradle.org/docs/nightly/userguide/dependency\_management.html#component\_metadata\_rules](http://www.gradle.org/docs/nightly/userguide/dependency_management.html#component_metadata_rules)  
  
If you can wait, we’re currently working on a mechanism that let’s you choose whether a particular module matches a version selector. This will let you hook in whatever logic you want. Expect to see something in the next month.
