diff --git a/convention/src/main/kotlin/io/gitlab/jfronny/scripts/SemanticVersion.kt b/convention/src/main/kotlin/io/gitlab/jfronny/scripts/SemanticVersion.kt index 5ea9f49..71d2a11 100644 --- a/convention/src/main/kotlin/io/gitlab/jfronny/scripts/SemanticVersion.kt +++ b/convention/src/main/kotlin/io/gitlab/jfronny/scripts/SemanticVersion.kt @@ -18,7 +18,7 @@ data class SemanticVersion(val major: Int, val minor: Int, val patch: Int, val t override fun toString(): String { return "$major.$minor.$patch" + when (type) { - VersionType.RELEASE -> typeSupplement ?: "" + VersionType.RELEASE -> typeSupplement?.let { "-$it" } ?: "" else -> "-${type.semanticName}" + if(typeSupplement != null) ".$typeSupplement" else "" } + if (build == null) "" else "+$build" } @@ -34,6 +34,7 @@ data class SemanticVersion(val major: Int, val minor: Int, val patch: Int, val t } fun withType(versionType: VersionType, typeSupplement: String? = null) = SemanticVersion(major, minor, patch, versionType, typeSupplement, build) + fun withBuild(build: String?) = SemanticVersion(major, minor, patch, type, typeSupplement, build) companion object { private val identifier = Regex("[a-zA-Z1-9][a-zA-Z0-9]*") diff --git a/convention/src/main/kotlin/jf.autoversion.gradle.kts b/convention/src/main/kotlin/jf.autoversion.gradle.kts index dad5648..0bb5b02 100644 --- a/convention/src/main/kotlin/jf.autoversion.gradle.kts +++ b/convention/src/main/kotlin/jf.autoversion.gradle.kts @@ -38,7 +38,7 @@ if (File(projectDir, ".git").exists()) { .map { msg -> CommitType.from(msg) { logger.warn(it) } } .max { o1, o2 -> o1.compareTo(o2) } .getOrDefault(CommitType.FIX) - nextRelease = parsedVersion.incrementBy(type) + nextRelease = parsedVersion.incrementBy(type, nprop("buildClassifier")) } } else { changelog += "Commits after inception:\n"