This gradle plugin adds a :generateBuildversionProps
task to your gradle project.
When :generateBuildversionProps
task is run, the output file src/main/resources/config/buildversion.properties
is generated with the following contents:
# buildversion.properties
# SAMPLE CONTENTS
projectVersion.number=0.1 # Uses the value of svnbuildversion.projectVersion
built.number=9 # Numer of times this revision was built. This resets to 1 for when svnRevision.number changes
svnRevision.number=109 # The current svn revision number. 'NaN' if project is not svn-managed
- Add the plugin.
// build.gradle
buildscript {
...
}
plugins {
id "com.github.bytehala.gradle-svnbuildversion" version "1.X"
}
svnbuildversion.projectVersion = 1.0 // Your project's version
//svnbuildversion.outputDir = 'src/main/resources/config/'
//svnbuildversion.useCommittedRevision = false
- Run
gradle generateBuildversionProps
The plugin adds the following variable which you can use in your projects build.gradle
- svnbuildversion.projectVersion - to pass your project's version into the plugin
- svnbuildversion.outputDir - where buildversion.properties will be generated
- svnbuildversion.useCommittedRevision - whether to use the working revision (default) or committed revision of project directory
Use the committed revision if the SVN repository hosts multiple projects and you don't want the global revision in buildversion.properties
.
These steps guide you through building this plugin on your own and using the jar file in your project.
-
git clone https://github.com/bytehala/gradle-svnbuildversion.git
-
(optional) To test what the output file will look like for your svn-managed project, edit
SvnBuildVersionPluginTest.groovy
by pointingsvnbuildversion.projectRoot
to your project's root directory -
Run
gradle clean build
. The binaries will be inbuild/libs/gradle-svnbuildversion-X.X.jar
-
Copy
gradle-svnbuildversion-X.X.jar
into your project (e.g. myProject/libs/) -
Configure build.gradle in your project
buildscript {
...
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.3.RELEASE")
classpath("org.tmatesoft.svnkit:svnkit:1.9.3") // The jar file depends on this library
classpath("com.github.bytehala:gradle-svnbuildversion:1.X")
}
}
svnbuildversion.projectVersion = 1.0 // Your project's version
//svnbuildversion.outputDir = 'src/main/resources/config/'
- Run
gradle generateBuildversionProps