From 3fc0dcb73b1685409cec67849f4ba03b528be570 Mon Sep 17 00:00:00 2001 From: Thomas Foyle Date: Mon, 14 Mar 2022 10:23:44 +0000 Subject: [PATCH] Remove String check to support semantic-release version numbers Signed-off-by: Tom Foyle --- .../com/ibm/cics/cbgp/BuildBundleTask.kt | 8 +++--- .../com/ibm/cics/cbgp/GoldenPathTests.groovy | 15 +++++++++++ src/test/resources/version/build.gradle | 25 +++++++++++++++++++ src/test/resources/version/settings.gradle | 1 + 4 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 src/test/resources/version/build.gradle create mode 100644 src/test/resources/version/settings.gradle diff --git a/src/main/kotlin/com/ibm/cics/cbgp/BuildBundleTask.kt b/src/main/kotlin/com/ibm/cics/cbgp/BuildBundleTask.kt index 245942a..4d6104a 100644 --- a/src/main/kotlin/com/ibm/cics/cbgp/BuildBundleTask.kt +++ b/src/main/kotlin/com/ibm/cics/cbgp/BuildBundleTask.kt @@ -110,11 +110,9 @@ open class BuildBundleTask : DefaultTask() { private fun getProjectVersionNumber(): VersionNumber { val pv = project.version - if (pv is String) { - val versionNumber = VersionNumber.parse(pv.toString()) - if (!VersionNumber.UNKNOWN.equals(versionNumber)) { - return versionNumber - } + val versionNumber = VersionNumber.parse(pv.toString()) + if (!VersionNumber.UNKNOWN.equals(versionNumber)) { + return versionNumber } throw GradleException("Project version number '$pv' could not be parsed into MAJOR.MINOR.MICRO.PATCH format") } diff --git a/src/test/groovy/com/ibm/cics/cbgp/GoldenPathTests.groovy b/src/test/groovy/com/ibm/cics/cbgp/GoldenPathTests.groovy index 072a3dd..8da9518 100644 --- a/src/test/groovy/com/ibm/cics/cbgp/GoldenPathTests.groovy +++ b/src/test/groovy/com/ibm/cics/cbgp/GoldenPathTests.groovy @@ -49,6 +49,21 @@ class GoldenPathTests extends AbstractTest { checkBundleArchiveFile() } + def "Test version number"() { + + given: + rootProjectName = bundleProjectName = "version" + projectVersion = "1.2.3" + + copyTestProject() + + when: + runGradleAndSucceed([BundlePlugin.DEPLOY_TASK_NAME]) + + then: + checkBundleArchiveFile() + } + @Unroll def "Test standalone #type project"(String type) { diff --git a/src/test/resources/version/build.gradle b/src/test/resources/version/build.gradle new file mode 100644 index 0000000..c252181 --- /dev/null +++ b/src/test/resources/version/build.gradle @@ -0,0 +1,25 @@ +plugins { + id 'com.ibm.cics.bundle' +} + +version = new org.gradle.util.VersionNumber(1, 2, 3, null) + +repositories { + mavenCentral() +} + +cicsBundle { + build { + defaultJVMServer = project.jvmsWlp + } + deploy { + url = project.url + cicsplex = project.cicsplex + region = project.region + bunddef = 'GRADLEV' + csdgroup = project.csdgroup + username = project.username + password = project.password + insecure = project.insecure + } +} \ No newline at end of file diff --git a/src/test/resources/version/settings.gradle b/src/test/resources/version/settings.gradle new file mode 100644 index 0000000..66c24d3 --- /dev/null +++ b/src/test/resources/version/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'version' \ No newline at end of file