Skip to content

Error Messages Explained

Roberto Perez Alcolea edited this page Feb 24, 2020 · 2 revisions

org.gradle.api.GradleException: Inferred version cannot be lower than nearest. Required by selected strategy.

Example error:

 Inferred project: my-project, version: 1.0.2-dev.7+pull.17.512ba90

 FAILURE: Build completed with 2 failures.

 1: Task failed with an exception.
 * What went wrong:
 A problem occurred evaluating root project 'my-project'.
 > Failed to apply plugin [id 'org.gradle.java']
    > Could not create task ':my-project:javadoc'.
       > Inferred version (1.0.2-dev.7+pull.17.512ba90) cannot be lower than nearest (1.1.0-rc.1). Required by selected strategy.

It is possible that you are publishing a devSnapshot with patch scope as follows:

./gradlew --stacktrace clean -Prelease.scope=patch devSnapshot

This means that if the latest tag on the master branch is a release candidate, e.g. v1.1.0-rc.1, then the version inferred on the build will use the last stable release, e.g. v1.0.1, and increment by the patch, so the inferred version becomes v1.0.2-dev.+<sha>.

We still don’t have a right solution for this.

What we recommend for multiple release trains:

  • Keep in master the major release, for example 1.1.0 release train so you latest is 1.1.0-rc.1.
  • If you need to do 1.0.x release, do it in another branch which is not aware of 1.0.x. So essentially, branch off from the last release of 1.0.x.

At the end it really depends on the tags that are visible to your branch when you do devSnapshot.