Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle release plugin which stores version in build.gradle

I'm converting my application from maven to gradle, and I'm looking for maven-release-plugin alternative for gradle.

All I need from the plugin is:

  • remove '-SNAPSHOT' suffix from the version and commit to git repo
  • create new git tag on this commit
  • bump version in build.gradle (like pom.xml), and add '-SNASPHOT' suffix

I guess, the most popular one is Gradle Release Plugin (https://github.com/researchgate/gradle-release). It works just fine, however, it stores the version in a separate file "gradle.properties". I need to store this version in "build.gradle" file (like a version in pom.xml).

I also tested following plugins, but they don't store version in build.gradle too:

  • axion-release-plugin (https://github.com/allegro/axion-release-plugin)
  • Gradle-git (https://github.com/ajoberstar/gradle-git/wiki/Release-Plugins)
  • gradle-release-plugin (https://github.com/netzwerg/gradle-release-plugin)

Are there any Gradle plugins which can work with version in "build.gradle" file?

like image 267
baratali Avatar asked Feb 14 '17 13:02

baratali


People also ask

How do I find Gradle version in build Gradle?

In Android Studio, go to File > Project Structure. Then select the "project" tab on the left. Your Gradle version will be displayed here.

What does Gradle release do?

The gradle-release plugin is designed to work similar to the Maven release plugin. The gradle release task defines the following as the default release process: The plugin checks for any un-committed files (Added, modified, removed, or un-versioned). Checks for any incoming or outgoing changes.

Where does Gradle store plugin dependencies?

Gradle declares dependencies on JAR files inside your project's module_name /libs/ directory (because Gradle reads paths relative to the build.gradle file). This declares a dependency on version 12.3 of the "app-magic" library, inside the "com.example.android" namespace group.

How do I know which version of Gradle is installed?

Verify Gradle Installation. Now open the command prompt. In the command prompt, enter Gradle -version. It will display the current version of Gradle just installed on the screen.


1 Answers

You could e. g. make

plugins {
    id 'net.researchgate.release' version '2.4.0'
}

version = '1.2.3'

release {
    versionPropertyFile = 'build.gradle'
}

updateVersion.doLast {
    def buildGradle = file('build.gradle')
    buildGradle.text = buildGradle.text.replaceFirst(~/version = (\d++\.\d++\.\d++)/, 'version = \'$1\'')
}
like image 136
Vampire Avatar answered Oct 09 '22 13:10

Vampire