zbstof
zbstof

Reputation: 1072

How to took up artifact version built with Gradle from sources

When using Maven, it's easy to look up latest version of SNAPSHOT artifact by going to parent's pom.xml:

https://github.com/apache/maven-compiler-plugin/blob/master/pom.xml#L33

But where do I look to get the same in Gradle? For example I couldn't find any version in the sources here:

https://github.com/testcontainers/testcontainers-java

And if it's impossible, then why? How Gradle knows which version to build? Is this information external to the source code?

Upvotes: 0

Views: 673

Answers (1)

Mark Rotteveel
Mark Rotteveel

Reputation: 109012

It depends on the project setup. The project you link to, according to their RELEASING.md, use the tag name for the version.

  1. Create a new release on GitHub. The tag name is used as the version, so please keep the tag name plain (e.g. 1.2.3).

This is done by the Travis build script, .travis.yml, specifically the line

script: ./gradlew -Pversion=$TRAVIS_TAG release

Some projects will explicitly put a version=x.y.z in their gradle file, others will provide it explicitly on build (similar to the Travis script used).

The advantage of this setup is that the version is never in the script, and you can't get merge conflicts or accidental version overwrites on this.

Upvotes: 2

Related Questions