Created
August 13, 2021 22:35
-
-
Save mustafayigitt/64bbcf9c8a1213ccaee94d26ebf02a33 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+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