Skip to content

Instantly share code, notes, and snippets.

@mustafayigitt
Created August 13, 2021 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mustafayigitt/64bbcf9c8a1213ccaee94d26ebf02a33 to your computer and use it in GitHub Desktop.
Save mustafayigitt/64bbcf9c8a1213ccaee94d26ebf02a33 to your computer and use it in GitHub Desktop.
+import org.gradle.api.DefaultTask
+import org.gradle.api.tasks.Input
+import org.gradle.api.tasks.TaskAction
+import org.gradle.api.tasks.options.Option
+
+/**
+ * Created by Mustafa YIGIT on 13.08.2021.
+ * mustafa.yt65@gmail.com
+ */
+
+open class VersionIncrementer : DefaultTask() {
+ private var versionName: String = ""
+
+ private var versionCode: String = ""
+ @Option(option = "versionName", description = "Configures the versionName.")
+ fun setVersionName(versionName: String) {
+ this.versionName = versionName
+ }
+
+ @Option(option = "versionCode", description = "Configures the versionCode.")
+ fun setVersionCode(versionCode: String) {
+ this.versionCode = versionCode
+ }
+
+ @Input
+ fun getVersionCode() = versionCode
+
+ @Input
+ fun getVersionName() = versionName
+
+
+ @TaskAction
+ fun setNewVersion() {
+ if (versionName.isEmpty()) {
+ println("VersionName not set!")
+ return
+ }
+ if (versionCode.isEmpty()) {
+ println("VersionCode not set!")
+ return
+ }
+ println("New Version: $versionName - $versionCode")
+
+ }
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment