Reputation: 770
I have found 3 ways to define my project version. In the documentation http://www.gradle.org/docs/current/userguide/dependency_management.html they talk to specify it in the manifest or the foldername (which already contains the project name). Coming from a maven project I'm used to defining my version in my pom.xml and I have found project that also define their version in the gradle.build file in the version property
I'm looking for the correct way to handle my project version, so I can also depend on a certain version of my project.
Upvotes: 0
Views: 10210
Reputation: 4236
Add a gradle.properties
file in the root directory of your project (same level as build.gradle
) with this content:
version=0.0.1-SNAPSHOT
Upvotes: -2
Reputation: 205
The link that you have shared talks more about dependency management, and about good practises for versioning your artifacts.
There is a one-to-one relationship between a Project and a build.gradle file. Also your build.gradle gives you a property:
version - The version of this project. Gradle always uses the toString() value of the version. The version defaults to unspecified.
This fits in for the project version. You can set it directly in build.gradle, but depending on your use case you could pass it externally - using gradle.properties for example in multi-project builds.
You can also directly add properties to your project objects using properties files. You can place a gradle.properties file in the Gradle user home directory (defaults to USER_HOME/.gradle) or in your project directory. For multi-project builds you can place gradle.properties files in any subproject directory. The properties of the gradle.properties can be accessed via the project object. The properties file in the user's home directory has precedence over property files in the project directories.
Check for more details: http://www.gradle.org/docs/current/dsl/org.gradle.api.Project.html#org.gradle.api.Project:configurations%28groovy.lang.Closure%29
Upvotes: 1