Skip to content

Commit

Permalink
Fix #85: Tweaking names, adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GladeDiviney committed Oct 30, 2020
1 parent 92480b8 commit 54dac43
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ class AndroidGitVersion implements Plugin<Project> {
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()
}
Expand Down Expand Up @@ -441,4 +441,4 @@ class AndroidGitVersionExtension {
return code * Math.pow(10, width) + digits
}
}
}
}
15 changes: 15 additions & 0 deletions src/test/groovy/com/gladed/androidgitversion/MainTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 54dac43

Please sign in to comment.