From 92480b888f3f89c7264f1d6eaf2d794426ae48a4 Mon Sep 17 00:00:00 2001 From: ferrugem Date: Sat, 10 Oct 2020 00:02:04 -0300 Subject: [PATCH 1/2] An improvement for tasks group --- .../com/gladed/androidgitversion/AndroidGitVersion.groovy | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/groovy/com/gladed/androidgitversion/AndroidGitVersion.groovy b/src/main/groovy/com/gladed/androidgitversion/AndroidGitVersion.groovy index 26cf128..3b6faa9 100644 --- a/src/main/groovy/com/gladed/androidgitversion/AndroidGitVersion.groovy +++ b/src/main/groovy/com/gladed/androidgitversion/AndroidGitVersion.groovy @@ -22,17 +22,23 @@ class AndroidGitVersion implements Plugin { void apply(Project project) { project.extensions.create("androidGitVersion", AndroidGitVersionExtension, project) project.task('androidGitVersion') { + group = 'androidGitVersion' + description = 'Task for generate both values [versionCode, versionName]' doLast { println "androidGitVersion.name\t${project.extensions.androidGitVersion.name()}" println "androidGitVersion.code\t${project.extensions.androidGitVersion.code()}" } } project.task('androidGitVersionName') { + group = 'androidGitVersion' + description = 'Task for generate the [versionName] of your project' doLast { println project.extensions.androidGitVersion.name() } } project.task('androidGitVersionCode') { + group = 'androidGitVersion' + description = 'Task for generate the [versionCode] of your project' doLast { println project.extensions.androidGitVersion.code() } @@ -435,4 +441,4 @@ class AndroidGitVersionExtension { return code * Math.pow(10, width) + digits } } -} +} \ No newline at end of file From 54dac43786bad721c630752c741bd72992441a41 Mon Sep 17 00:00:00 2001 From: Glade Diviney Date: Fri, 30 Oct 2020 10:44:39 -0700 Subject: [PATCH 2/2] Fix #85: Tweaking names, adding tests --- .../androidgitversion/AndroidGitVersion.groovy | 14 +++++++------- .../com/gladed/androidgitversion/MainTest.groovy | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/main/groovy/com/gladed/androidgitversion/AndroidGitVersion.groovy b/src/main/groovy/com/gladed/androidgitversion/AndroidGitVersion.groovy index 3b6faa9..4b72819 100644 --- a/src/main/groovy/com/gladed/androidgitversion/AndroidGitVersion.groovy +++ b/src/main/groovy/com/gladed/androidgitversion/AndroidGitVersion.groovy @@ -22,23 +22,23 @@ class AndroidGitVersion implements Plugin { void apply(Project project) { project.extensions.create("androidGitVersion", AndroidGitVersionExtension, project) project.task('androidGitVersion') { - group = 'androidGitVersion' - description = 'Task for generate both values [versionCode, versionName]' + group = 'Build' + description = 'Print version name and version code' doLast { println "androidGitVersion.name\t${project.extensions.androidGitVersion.name()}" println "androidGitVersion.code\t${project.extensions.androidGitVersion.code()}" } } project.task('androidGitVersionName') { - group = 'androidGitVersion' - description = 'Task for generate the [versionName] of your project' + group = 'Build' + description = 'Print version name' doLast { println project.extensions.androidGitVersion.name() } } project.task('androidGitVersionCode') { - group = 'androidGitVersion' - description = 'Task for generate the [versionCode] of your project' + group = 'Build' + description = 'Print version code' doLast { println project.extensions.androidGitVersion.code() } @@ -441,4 +441,4 @@ class AndroidGitVersionExtension { return code * Math.pow(10, width) + digits } } -} \ No newline at end of file +} diff --git a/src/test/groovy/com/gladed/androidgitversion/MainTest.groovy b/src/test/groovy/com/gladed/androidgitversion/MainTest.groovy index 0f8d5f1..4f0e03a 100644 --- a/src/test/groovy/com/gladed/androidgitversion/MainTest.groovy +++ b/src/test/groovy/com/gladed/androidgitversion/MainTest.groovy @@ -168,4 +168,19 @@ class MainTest extends AndroidGitVersionTest { plugin.flush() assertEquals(1002004, plugin.code()) } + + void testTaskNames() { + plugin // Touch the plugin so it's loaded + def androidGitVersion = project.getTasksByName("androidGitVersion", true).first() + assertEquals("Build", androidGitVersion.group) + assertEquals("Print version name and version code", androidGitVersion.description) + + def androidGitVersionName = project.getTasksByName("androidGitVersionName", true).first() + assertEquals("Build", androidGitVersionName.group) + assertEquals("Print version name", androidGitVersionName.description) + + def androidGitVersionCode = project.getTasksByName("androidGitVersionCode", true).first() + assertEquals("Build", androidGitVersionCode.group) + assertEquals("Print version code", androidGitVersionCode.description) + } }